From db502d7054139247fdf2b9145ce6621288c9785f Mon Sep 17 00:00:00 2001 From: Michael Vetter Date: Fri, 3 Apr 2020 11:56:30 +0200 Subject: db: log "from" resource --- src/database.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/database.c') diff --git a/src/database.c b/src/database.c index 6b94e1e5..d65565b2 100644 --- a/src/database.c +++ b/src/database.c @@ -45,7 +45,7 @@ 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* @@ -162,7 +162,7 @@ _log_database_add_incoming(ProfMessage *message, const char * const type) const char *jid = connection_get_fulljid(); 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); } @@ -197,7 +197,7 @@ _log_database_add_outgoing(const char * const type, const char * const id, const const char *jid = connection_get_fulljid(); 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); message_free(msg); @@ -222,7 +222,7 @@ log_database_add_outgoing_muc_pm(const char * const id, const char * const barej } 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) { 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(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')", - from_jid, - "test" /*message->jid->resourcepart*/, + from_jid->barejid, + from_jid->resourcepart, + //"test" /*message->jid->resourcepart*/, to_jid, message->plain, date_fmt, -- cgit 1.4.1-2-gfad0