forked from cory/tildefriends
To calculate an ID, take the utf-8 message, convert it to utf-16, and then throw away the high bytes. Of course.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3834 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
11
src/ssb.db.c
11
src/ssb.db.c
@ -545,14 +545,21 @@ bool _tf_ssb_update_message_id(sqlite3* db, const char* old_id, const char* new_
|
||||
return success;
|
||||
}
|
||||
|
||||
bool tf_ssb_db_check(sqlite3* db)
|
||||
bool tf_ssb_db_check(sqlite3* db, const char* check_author)
|
||||
{
|
||||
JSRuntime* runtime = JS_NewRuntime();
|
||||
JSContext* context = JS_NewContext(runtime);
|
||||
|
||||
sqlite3_stmt* statement = NULL;
|
||||
if (sqlite3_prepare(db, "SELECT id, previous, author, sequence, timestamp, hash, content, signature, sequence_before_author FROM messages ORDER BY author, sequence", -1, &statement, NULL) == SQLITE_OK)
|
||||
int result = check_author ?
|
||||
sqlite3_prepare(db, "SELECT id, previous, author, sequence, timestamp, hash, content, signature, sequence_before_author FROM messages WHERE author = ? ORDER BY author, sequence", -1, &statement, NULL) :
|
||||
sqlite3_prepare(db, "SELECT id, previous, author, sequence, timestamp, hash, content, signature, sequence_before_author FROM messages ORDER BY author, sequence", -1, &statement, NULL);
|
||||
if (result == SQLITE_OK)
|
||||
{
|
||||
if (check_author)
|
||||
{
|
||||
sqlite3_bind_text(statement, 1, check_author, -1, NULL);
|
||||
}
|
||||
char previous_id[k_id_base64_len];
|
||||
while (sqlite3_step(statement) == SQLITE_ROW)
|
||||
{
|
||||
|
Reference in New Issue
Block a user