Fix docs.

This commit is contained in:
Cory McWilliams 2024-05-12 08:37:14 -04:00
parent 93ce253d1e
commit 27b275548e
2 changed files with 23 additions and 16 deletions

View File

@ -737,12 +737,11 @@ bool tf_ssb_db_blob_store(tf_ssb_t* ssb, const uint8_t* blob, size_t size, char*
}
bool tf_ssb_db_get_message_by_author_and_sequence(tf_ssb_t* ssb, const char* author, int64_t sequence, char* out_message_id, size_t out_message_id_size, char* out_previous,
size_t out_previous_size, char* out_author, size_t out_author_size, double* out_timestamp, char** out_content, char* out_hash, size_t out_hash_size, char* out_signature,
size_t out_signature_size, int* out_flags)
size_t out_previous_size, double* out_timestamp, char** out_content, char* out_hash, size_t out_hash_size, char* out_signature, size_t out_signature_size, int* out_flags)
{
bool found = false;
sqlite3_stmt* statement;
const char* query = "SELECT id, previous, author, timestamp, json(content), hash, signature, flags FROM messages WHERE author = ?1 AND sequence = ?2";
const char* query = "SELECT id, previous, timestamp, json(content), hash, signature, flags FROM messages WHERE author = ?1 AND sequence = ?2";
sqlite3* db = tf_ssb_acquire_db_reader(ssb);
if (sqlite3_prepare(db, query, -1, &statement, NULL) == SQLITE_OK)
{
@ -766,29 +765,25 @@ bool tf_ssb_db_get_message_by_author_and_sequence(tf_ssb_t* ssb, const char* aut
snprintf(out_previous, out_previous_size, "%s", (const char*)sqlite3_column_text(statement, 1));
}
}
if (out_author)
{
snprintf(out_author, out_author_size, "%s", (const char*)sqlite3_column_text(statement, 2));
}
if (out_timestamp)
{
*out_timestamp = sqlite3_column_double(statement, 3);
*out_timestamp = sqlite3_column_double(statement, 2);
}
if (out_content)
{
*out_content = tf_strdup((const char*)sqlite3_column_text(statement, 4));
*out_content = tf_strdup((const char*)sqlite3_column_text(statement, 3));
}
if (out_hash)
{
snprintf(out_hash, out_hash_size, "%s", (const char*)sqlite3_column_text(statement, 5));
snprintf(out_hash, out_hash_size, "%s", (const char*)sqlite3_column_text(statement, 4));
}
if (out_signature)
{
snprintf(out_signature, out_signature_size, "%s", (const char*)sqlite3_column_text(statement, 6));
snprintf(out_signature, out_signature_size, "%s", (const char*)sqlite3_column_text(statement, 5));
}
if (out_flags)
{
*out_flags = sqlite3_column_int(statement, 7);
*out_flags = sqlite3_column_int(statement, 6);
}
found = true;
}
@ -1834,8 +1829,8 @@ bool tf_ssb_db_verify(tf_ssb_t* ssb, const char* id)
char hash[32];
char signature[256];
int flags = 0;
if (tf_ssb_db_get_message_by_author_and_sequence(ssb, id, i, message_id, sizeof(message_id), previous, sizeof(previous), NULL, 0, &timestamp, &content, hash,
sizeof(hash), signature, sizeof(signature), &flags))
if (tf_ssb_db_get_message_by_author_and_sequence(
ssb, id, i, message_id, sizeof(message_id), previous, sizeof(previous), &timestamp, &content, hash, sizeof(hash), signature, sizeof(signature), &flags))
{
JSValue message = tf_ssb_format_message(context, previous, id, i, timestamp, hash, content, signature, flags);
char calculated_id[k_id_base64_len];

View File

@ -122,13 +122,19 @@ JSValue tf_ssb_db_get_message_by_id(tf_ssb_t* ssb, const char* id, bool is_keys)
** @param sequence The message sequence number.
** @param[out] out_message_id Populated with the message identifier.
** @param out_message_id_size The size of the out_message_id buffer.
** @param[out] out_previous Populated with the previous message identifier.
** @param out_previous_size The size of the out_previous buffer.
** @param[out] out_timestamp Populated with the timestamp.
** @param[out] out_content Populated with the message content. Free with tf_free().
** @param[out] out_hash Populated with the message hash format.
** @param out_hash_size The size of the out_hash buffer.
** @param[out] out_signature Populated with the message signature.
** @param out_signature_size The size of the out_signature buffer.
** @param[out] out_flags Populated with flags describing the format of the message.
** @return True if the message was found and retrieved.
*/
bool tf_ssb_db_get_message_by_author_and_sequence(tf_ssb_t* ssb, const char* author, int64_t sequence, char* out_message_id, size_t out_message_id_size, char* out_previous,
size_t out_previous_size, char* out_author, size_t out_author_size, double* out_timestamp, char** out_content, char* out_hash, size_t out_hash_size, char* out_signature,
size_t out_signature_size, int* out_flags);
size_t out_previous_size, double* out_timestamp, char** out_content, char* out_hash, size_t out_hash_size, char* out_signature, size_t out_signature_size, int* out_flags);
/**
** Get information about the last message from an author.
@ -380,6 +386,12 @@ bool tf_ssb_db_set_property(tf_ssb_t* ssb, const char* id, const char* key, cons
*/
void tf_ssb_db_resolve_index_async(tf_ssb_t* ssb, const char* host, void (*callback)(const char* path, void* user_data), void* user_data);
/**
** Verify an author's feed.
** @param ssb The SSB instance.
** @param id The author'd identity.
** @return true If the feed verified successfully.
*/
bool tf_ssb_db_verify(tf_ssb_t* ssb, const char* id);
/**