mirror of
https://github.com/profanity-im/profanity.git
synced 2025-07-26 12:14:28 -04:00
Fix error in getting previous chatlog
Our search was too broad, and thus incorrect. One of the various mistakes it can cause was https://github.com/profanity-im/profanity/issues/1308 Fix https://github.com/profanity-im/profanity/issues/1308
This commit is contained in:
parent
e1b8fb24c3
commit
b2eea969db
@ -215,12 +215,16 @@ log_database_get_previous_chat(const gchar *const contact_barejid)
|
|||||||
{
|
{
|
||||||
sqlite3_stmt *stmt = NULL;
|
sqlite3_stmt *stmt = NULL;
|
||||||
char *query;
|
char *query;
|
||||||
|
const char *jid = connection_get_fulljid();
|
||||||
|
Jid *myjid = jid_create(jid);
|
||||||
|
|
||||||
if (asprintf(&query, "SELECT * FROM (SELECT `message`, `timestamp`, `from_jid`, `type` from `ChatLogs` WHERE `from_jid` = '%s' OR `to_jid` = '%s' ORDER BY `timestamp` DESC LIMIT 10) ORDER BY `timestamp` ASC;", contact_barejid, contact_barejid) == -1) {
|
if (asprintf(&query, "SELECT * FROM (SELECT `message`, `timestamp`, `from_jid`, `type` from `ChatLogs` WHERE (`from_jid` = '%s' AND `to_jid` = '%s') OR (`from_jid` = '%s' AND `to_jid` = '%s') ORDER BY `timestamp` DESC LIMIT 10) ORDER BY `timestamp` ASC;", contact_barejid, myjid->barejid, myjid->barejid, contact_barejid) == -1) {
|
||||||
log_error("log_database_get_previous_chat(): SQL query. could not allocate memory");
|
log_error("log_database_get_previous_chat(): SQL query. could not allocate memory");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
jid_destroy(myjid);
|
||||||
|
|
||||||
int rc = sqlite3_prepare_v2(g_chatlog_database, query, -1, &stmt, NULL);
|
int rc = sqlite3_prepare_v2(g_chatlog_database, query, -1, &stmt, NULL);
|
||||||
if( rc!=SQLITE_OK ) {
|
if( rc!=SQLITE_OK ) {
|
||||||
log_error("log_database_get_previous_chat(): unknown SQLite error");
|
log_error("log_database_get_previous_chat(): unknown SQLite error");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user