about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2020-04-03 12:09:16 +0200
committerMichael Vetter <jubalh@iodoru.org>2020-04-06 10:50:20 +0200
commit20850eb4db580ea9cb6193f420b9724a29ee63ea (patch)
treede0a70436888e6ec83654ebde487213b14db0aa6
parent9b1aac04813423c27a5d1057b38c760219799809 (diff)
downloadprofani-tty-20850eb4db580ea9cb6193f420b9724a29ee63ea.tar.gz
db: log encryption type
-rw-r--r--src/database.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/database.c b/src/database.c
index 6715356a..988bfeae 100644
--- a/src/database.c
+++ b/src/database.c
@@ -229,12 +229,28 @@ _add_to_db(ProfMessage *message, const char * const type, const Jid * const from
         return;
     }
 
+    char *enc;
+    switch (message->enc) {
+        case PROF_MSG_ENC_PGP:
+            enc = "pgp";
+            break;
+        case PROF_MSG_ENC_OTR:
+            enc = "otr";
+            break;
+        case PROF_MSG_ENC_OMEMO:
+            enc = "omemo";
+            break;
+        case PROF_MSG_ENC_NONE:
+        default:
+            enc = "none";
+    }
+
     char *err_msg;
     char *query;
 
     //gchar *date_fmt = g_date_time_format_iso8601(message->timestamp);
     gchar *date_fmt = g_date_time_format(message->timestamp, "%Y/%m/%d %H:%M:%S");
-    if (asprintf(&query, "INSERT INTO `ChatLogs` (`from_jid`, `from_resource`, `to_jid`, `to_resource`, `message`, `timestamp`, `stanza_id`, `replace_id`, `type`) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",
+    if (asprintf(&query, "INSERT INTO `ChatLogs` (`from_jid`, `from_resource`, `to_jid`, `to_resource`, `message`, `timestamp`, `stanza_id`, `replace_id`, `type`, `encryption`) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",
                 from_jid->barejid,
                 from_jid->resourcepart ? from_jid->resourcepart : "",
                 to_jid->barejid,
@@ -243,7 +259,8 @@ _add_to_db(ProfMessage *message, const char * const type, const Jid * const from
                 date_fmt,
                 message->id ? message->id : "",
                 message->replace_id ? message->replace_id : "",
-                type) == -1) {
+                type,
+                enc) == -1) {
         log_error("log_database_add(): could not allocate memory");
         return;
     }