1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

db: log "from" resource

This commit is contained in:
Michael Vetter 2020-04-03 11:56:30 +02:00
parent 9224331df3
commit db502d7054

View File

@ -45,7 +45,7 @@
static sqlite3 *g_chatlog_database; static sqlite3 *g_chatlog_database;
static void _add_to_db(ProfMessage *message, const char * const type, const char * const from_jid, const char * const to_jid); static void _add_to_db(ProfMessage *message, const char * const type, const Jid * const from_jid, const char * const to_jid);
static char* _get_db_filename(ProfAccount *account); static char* _get_db_filename(ProfAccount *account);
static char* static char*
@ -162,7 +162,7 @@ _log_database_add_incoming(ProfMessage *message, const char * const type)
const char *jid = connection_get_fulljid(); const char *jid = connection_get_fulljid();
Jid *myjid = jid_create(jid); Jid *myjid = jid_create(jid);
_add_to_db(message, type, message->jid->barejid, myjid->barejid); _add_to_db(message, type, message->jid, myjid->barejid);
jid_destroy(myjid); jid_destroy(myjid);
} }
@ -197,7 +197,7 @@ _log_database_add_outgoing(const char * const type, const char * const id, const
const char *jid = connection_get_fulljid(); const char *jid = connection_get_fulljid();
Jid *myjid = jid_create(jid); Jid *myjid = jid_create(jid);
_add_to_db(msg, type, myjid->barejid, msg->jid->barejid); _add_to_db(msg, type, myjid, msg->jid->barejid);
jid_destroy(myjid); jid_destroy(myjid);
message_free(msg); message_free(msg);
@ -222,7 +222,7 @@ log_database_add_outgoing_muc_pm(const char * const id, const char * const barej
} }
static void static void
_add_to_db(ProfMessage *message, const char * const type, const char * const from_jid, const char * const to_jid) _add_to_db(ProfMessage *message, const char * const type, const Jid * const from_jid, const char * const to_jid)
{ {
if (!g_chatlog_database) { if (!g_chatlog_database) {
log_debug("log_database_add() called but db is not initialized"); log_debug("log_database_add() called but db is not initialized");
@ -235,8 +235,9 @@ _add_to_db(ProfMessage *message, const char * const type, const char * const fro
//gchar *date_fmt = g_date_time_format_iso8601(message->timestamp); //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"); 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`, `message`, `timestamp`, `stanza_id`, `replace_id`, `type`) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')", if (asprintf(&query, "INSERT INTO `ChatLogs` (`from_jid`, `from_resource`, `to_jid`, `message`, `timestamp`, `stanza_id`, `replace_id`, `type`) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",
from_jid, from_jid->barejid,
"test" /*message->jid->resourcepart*/, from_jid->resourcepart,
//"test" /*message->jid->resourcepart*/,
to_jid, to_jid,
message->plain, message->plain,
date_fmt, date_fmt,