diff options
author | MarcoPolo-PasTonMolo <marcopolopastonmolo@protonmail.com> | 2022-07-10 11:16:19 +0300 |
---|---|---|
committer | MarcoPolo-PasTonMolo <marcopolopastonmolo@protonmail.com> | 2022-07-10 11:17:35 +0300 |
commit | a2f79a19b9b2720b7f14462a994d4cd54bbd079e (patch) | |
tree | 2a336ee3304eea777fa93c0cf9050dd92f06a268 /src | |
parent | 85aaf40432d50a99c50ae8d1baa7c02ff5ae43ba (diff) | |
download | profani-tty-a2f79a19b9b2720b7f14462a994d4cd54bbd079e.tar.gz |
Fix duplicate sent messages in db
Diffstat (limited to 'src')
-rw-r--r-- | src/database.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/database.c b/src/database.c index 80effb71..46cda38d 100644 --- a/src/database.c +++ b/src/database.c @@ -366,7 +366,7 @@ _add_to_db(ProfMessage* message, char* type, const Jid* const from_jid, const Ji type = (char*)_get_message_type_str(message->type); } - query = sqlite3_mprintf("INSERT INTO `ChatLogs` (`from_jid`, `from_resource`, `to_jid`, `to_resource`, `message`, `timestamp`, `stanza_id`, `archive_id`, `replace_id`, `type`, `encryption`) SELECT '%q', '%q', '%q', '%q', '%q', '%q', '%q', '%q', '%q', '%q', '%q' WHERE NOT EXISTS (SELECT 1 FROM `ChatLogs` WHERE `archive_id` = '%q' AND `archive_id` != '')", + query = sqlite3_mprintf("INSERT INTO `ChatLogs` (`from_jid`, `from_resource`, `to_jid`, `to_resource`, `message`, `timestamp`, `stanza_id`, `archive_id`, `replace_id`, `type`, `encryption`) SELECT '%q', '%q', '%q', '%q', '%q', '%q', '%q', '%q', '%q', '%q', '%q' WHERE NOT EXISTS (SELECT 1 FROM `ChatLogs` WHERE (`archive_id` = '%q' AND `archive_id` != '') OR (`stanza_id` = '%q' AND `stanza_id` != ''))", from_jid->barejid, from_jid->resourcepart ? from_jid->resourcepart : "", to_jid->barejid, @@ -378,7 +378,8 @@ _add_to_db(ProfMessage* message, char* type, const Jid* const from_jid, const Ji message->replace_id ? message->replace_id : "", type ? type : "", enc ? enc : "", - message->stanzaid ? message->stanzaid : ""); + message->stanzaid ? message->stanzaid : "", + message->id ? message->id : ""); if (!query) { log_error("log_database_add(): SQL query. could not allocate memory"); return; |