Fix multiple issues getting identity info.

This commit is contained in:
Cory McWilliams 2024-05-11 10:23:07 -04:00
parent 427ca3f265
commit ca00c4fb5d

View File

@ -399,10 +399,11 @@ static void _tf_ssb_getIdentityInfo_visit(const char* identity, void* data)
identity_info_work_t* request = data;
request->identities = tf_resize_vec(request->identities, (request->count + 1) * sizeof(char*));
request->names = tf_resize_vec(request->names, (request->count + 1) * sizeof(char*));
request->identities[request->count] = tf_strdup(identity);
char buffer[k_id_base64_len];
snprintf(buffer, sizeof(buffer), "@%s", identity);
request->identities[request->count] = tf_strdup(buffer);
request->names[request->count] = NULL;
request->count++;
;
}
static void _tf_ssb_getIdentityInfo_work(tf_ssb_t* ssb, void* user_data)
@ -419,8 +420,8 @@ static void _tf_ssb_getIdentityInfo_work(tf_ssb_t* ssb, void* user_data)
" RANK() OVER (PARTITION BY messages.author ORDER BY messages.sequence DESC) AS author_rank, "
" messages.content ->> 'name' AS name "
" FROM messages "
" JOIN identities ON messages.author = ids.value "
" WHERE WHERE identities.user = ? AND json_extract(messages.content, '$.type') = 'about' AND content ->> 'about' = messages.author AND name IS NOT NULL) "
" JOIN identities ON messages.author = ('@' || identities.public_key) "
" WHERE identities.user = ? AND json_extract(messages.content, '$.type') = 'about' AND content ->> 'about' = messages.author AND name IS NOT NULL) "
"WHERE author_rank = 1 ",
-1, &statement, NULL);
if (request->result == SQLITE_OK)
@ -428,7 +429,7 @@ static void _tf_ssb_getIdentityInfo_work(tf_ssb_t* ssb, void* user_data)
if (sqlite3_bind_text(statement, 1, request->name, -1, NULL) == SQLITE_OK)
{
int r = SQLITE_OK;
while ((r = sqlite3_step(statement)) == SQLITE_OK)
while ((r = sqlite3_step(statement)) == SQLITE_ROW)
{
for (int i = 0; i < request->count; i++)
{
@ -444,6 +445,10 @@ static void _tf_ssb_getIdentityInfo_work(tf_ssb_t* ssb, void* user_data)
}
sqlite3_finalize(statement);
}
else
{
tf_printf("prepare failed: %s.\n", sqlite3_errmsg(db));
}
tf_ssb_db_identity_get_active(db, request->name, request->package_owner, request->package_name, request->active_identity, sizeof(request->active_identity));
if (!*request->active_identity && request->count)