Produce user info for the server identity for admin users.

This commit is contained in:
Cory McWilliams 2024-09-19 12:22:38 -04:00
parent f83863ef01
commit e5f58c2898

View File

@ -637,9 +637,9 @@ static void _tf_ssb_getIdentityInfo_visit(const char* identity, void* data)
static void _tf_ssb_getIdentityInfo_work(tf_ssb_t* ssb, void* user_data) static void _tf_ssb_getIdentityInfo_work(tf_ssb_t* ssb, void* user_data)
{ {
identity_info_work_t* request = user_data; identity_info_work_t* request = user_data;
char id[k_id_base64_len] = "";
if (tf_ssb_db_user_has_permission(ssb, request->name, "administration")) if (tf_ssb_db_user_has_permission(ssb, request->name, "administration"))
{ {
char id[k_id_base64_len] = "";
if (tf_ssb_whoami(ssb, id, sizeof(id))) if (tf_ssb_whoami(ssb, id, sizeof(id)))
{ {
_tf_ssb_getIdentityInfo_visit(*id == '@' ? id + 1 : id, request); _tf_ssb_getIdentityInfo_visit(*id == '@' ? id + 1 : id, request);
@ -657,12 +657,15 @@ static void _tf_ssb_getIdentityInfo_work(tf_ssb_t* ssb, void* user_data)
" messages.content ->> 'name' AS name " " messages.content ->> 'name' AS name "
" FROM messages " " FROM messages "
" JOIN identities ON messages.author = ('@' || identities.public_key) " " 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 "
" (identities.user = ? OR identities.public_key = ?) AND "
" json_extract(messages.content, '$.type') = 'about' AND "
" content ->> 'about' = messages.author AND name IS NOT NULL) "
"WHERE author_rank = 1 ", "WHERE author_rank = 1 ",
-1, &statement, NULL); -1, &statement, NULL);
if (request->result == SQLITE_OK) if (request->result == SQLITE_OK)
{ {
if (sqlite3_bind_text(statement, 1, request->name, -1, NULL) == SQLITE_OK) if (sqlite3_bind_text(statement, 1, request->name, -1, NULL) == SQLITE_OK && sqlite3_bind_text(statement, 2, *id == '@' ? id + 1 : id, -1, NULL) == SQLITE_OK)
{ {
int r = SQLITE_OK; int r = SQLITE_OK;
while ((r = sqlite3_step(statement)) == SQLITE_ROW) while ((r = sqlite3_step(statement)) == SQLITE_ROW)