ssb: Dust off the verify command.

This commit is contained in:
2025-04-09 19:32:38 -04:00
parent f7270987ea
commit 38d746b310
3 changed files with 63 additions and 7 deletions

View File

@ -1204,9 +1204,38 @@ static int _tf_command_verify(const char* file, int argc, char* argv[])
return EXIT_FAILURE;
}
tf_printf("Verifying %s...\n", identity);
bool verified = false;
tf_ssb_t* ssb = tf_ssb_create(NULL, NULL, db_path, NULL);
bool verified = tf_ssb_db_verify(ssb, identity);
if (identity)
{
tf_printf("Verifying %s...\n", identity);
verified = tf_ssb_db_verify(ssb, identity, true);
}
else
{
sqlite3* db = tf_ssb_acquire_db_reader(ssb);
sqlite3_stmt* statement = NULL;
if (sqlite3_prepare(db, "SELECT DISTINCT author FROM messages ORDER BY author", -1, &statement, NULL) == SQLITE_OK)
{
verified = true;
while (sqlite3_step(statement) == SQLITE_ROW)
{
const char* identity = (const char*)sqlite3_column_text(statement, 0);
tf_printf("Verifying %s...", identity);
if (tf_ssb_db_verify(ssb, identity, true))
{
tf_printf("success.\n");
}
else
{
tf_printf("fail.\n");
verified = false;
}
}
sqlite3_finalize(statement);
}
tf_ssb_release_db_reader(ssb, db);
}
tf_ssb_destroy(ssb);
tf_free((void*)default_db_path);
return verified ? EXIT_SUCCESS : EXIT_FAILURE;