diff options
author | tomsmeding <tom.smeding@gmail.com> | 2017-07-05 20:10:14 +0200 |
---|---|---|
committer | tomsmeding <tom.smeding@gmail.com> | 2017-07-05 20:10:14 +0200 |
commit | 7c30c3f9c9312500bbb86a98f81ce15982b6907a (patch) | |
tree | 71568b921176263b6ec209bc177bbc748d6720f5 /db.c | |
parent | 2738029aa23666674cc1310ac467027d952ada68 (diff) |
server: INCOMPATIBLE: send message id's in history log
Diffstat (limited to 'db.c')
-rw-r--r-- | db.c | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -304,9 +304,11 @@ void db_create_message(i64 roomid,i64 userid,i64 timestamp,const char *message){ } struct db_message_list db_get_messages(i64 roomid,i64 count){ + assert(count>=0); + sqlite3_stmt *stmt; SQLITE(prepare_v2,database, - "select user, time, message " + "select id, user, time, message " "from Messages " "where room = ? " "order by time desc " @@ -325,10 +327,11 @@ struct db_message_list db_get_messages(i64 roomid,i64 count){ if(ml.count==cap){ die("sqlite gave too many rows while 'limit %" PRIi64 "' was present",count); } + ml.list[ml.count].msgid=sqlite3_column_int64(stmt,0); ml.list[ml.count].roomid=roomid; - ml.list[ml.count].userid=sqlite3_column_int64(stmt,0); - ml.list[ml.count].timestamp=sqlite3_column_int64(stmt,1); - ml.list[ml.count].message=strdup((const char*)sqlite3_column_text(stmt,2)); + ml.list[ml.count].userid=sqlite3_column_int64(stmt,1); + ml.list[ml.count].timestamp=sqlite3_column_int64(stmt,2); + ml.list[ml.count].message=strdup((const char*)sqlite3_column_text(stmt,3)); ml.count++; } |