|
Tilde Friends
|
Classes | |
| struct | _tf_ssb_following_t |
| struct | _tf_ssb_db_stored_connection_t |
| struct | _tf_ssb_identity_info_t |
Typedefs | |
| typedef struct _tf_ssb_t | tf_ssb_t |
| typedef struct sqlite3_stmt | sqlite3_stmt |
| typedef void() | tf_ssb_db_blob_get_callback_t(bool found, const uint8_t *data, size_t size, void *user_data) |
| typedef void() | tf_ssb_db_store_message_callback_t(const char *id, bool stored, void *user_data) |
| typedef void() | tf_ssb_db_blob_store_callback_t(const char *id, bool is_new, void *user_data) |
| typedef struct _tf_ssb_following_t | tf_ssb_following_t |
| typedef struct _tf_ssb_db_stored_connection_t | tf_ssb_db_stored_connection_t |
| typedef struct _tf_ssb_identity_info_t | tf_ssb_identity_info_t |
Functions | |
| void | tf_ssb_db_init (tf_ssb_t *ssb) |
| void | tf_ssb_db_init_reader (sqlite3 *db) |
| bool | tf_ssb_db_blob_has (sqlite3 *db, const char *id) |
| bool | tf_ssb_db_blob_get (tf_ssb_t *ssb, const char *id, uint8_t **out_blob, size_t *out_size) |
| bool | tf_ssb_db_blob_get_from_db (sqlite3 *db, const char *id, uint8_t **out_blob, size_t *out_size) |
| void | tf_ssb_db_blob_get_async (tf_ssb_t *ssb, const char *id, tf_ssb_db_blob_get_callback_t *callback, void *user_data) |
| void | tf_ssb_db_store_message (tf_ssb_t *ssb, JSContext *context, const char *id, JSValue val, const char *signature, int flags, tf_ssb_db_store_message_callback_t *callback, void *user_data) |
| void | tf_ssb_db_blob_store_async (tf_ssb_t *ssb, const uint8_t *blob, size_t size, tf_ssb_db_blob_store_callback_t *callback, void *user_data) |
| bool | tf_ssb_db_blob_store (tf_ssb_t *ssb, const uint8_t *blob, size_t size, char *out_id, size_t out_id_size, bool *out_new) |
| bool | tf_ssb_db_get_message_by_author_and_sequence (tf_ssb_t *ssb, const char *author, int32_t sequence, char *out_message_id, size_t out_message_id_size, char *out_previous, 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 | tf_ssb_db_get_latest_message_by_author (sqlite3 *db, sqlite3_stmt **in_out_statement, const char *author, int32_t *out_sequence, char *out_message_id, size_t out_message_id_size) |
| JSValue | tf_ssb_db_visit_query (tf_ssb_t *ssb, const char *query, const JSValue binds, void(*callback)(JSValue row, void *user_data), void *user_data) |
| bool | tf_ssb_db_check (sqlite3 *db, const char *author) |
| int | tf_ssb_db_identity_get_count_for_user (tf_ssb_t *ssb, const char *user) |
| bool | tf_ssb_db_identity_create (tf_ssb_t *ssb, const char *user, uint8_t *out_public_key, uint8_t *out_private_key) |
| bool | tf_ssb_db_identity_delete (tf_ssb_t *ssb, const char *user, const char *public_key) |
| bool | tf_ssb_db_identity_add (tf_ssb_t *ssb, const char *user, const char *public_key, const char *private_key) |
| bool | tf_ssb_db_identity_get_active (sqlite3 *db, const char *user, const char *package_owner, const char *package_name, char *out_identity, size_t out_identity_size) |
| void | tf_ssb_db_identity_visit (tf_ssb_t *ssb, const char *user, void(*callback)(const char *identity, void *user_data), void *user_data) |
| void | tf_ssb_db_identity_visit_all (tf_ssb_t *ssb, void(*callback)(const char *identity, void *user_data), void *user_data) |
| const char * | tf_ssb_db_get_user_for_identity (tf_ssb_t *ssb, const char *public_key) |
| bool | tf_ssb_db_identity_get_private_key (tf_ssb_t *ssb, const char *user, const char *public_key, uint8_t *out_private_key, size_t private_key_size) |
| JSValue | tf_ssb_format_message (JSContext *context, const char *previous, const char *author, int32_t sequence, double timestamp, const char *hash, const char *content, const char *signature, int flags) |
| const char ** | tf_ssb_db_following_deep_ids (tf_ssb_t *ssb, const char **ids, int count, int depth) |
| tf_ssb_following_t * | tf_ssb_db_following_deep (tf_ssb_t *ssb, const char **ids, int count, int depth, bool include_blocks) |
| const char ** | tf_ssb_db_get_all_visible_identities (tf_ssb_t *ssb, int depth) |
| tf_ssb_db_stored_connection_t * | tf_ssb_db_get_stored_connections (tf_ssb_t *ssb, int *out_count) |
| void | tf_ssb_db_forget_stored_connection (tf_ssb_t *ssb, const char *address, int port, const char *pubkey) |
| bool | tf_ssb_db_get_account_password_hash (tf_ssb_t *ssb, const char *name, char *out_password, size_t password_size) |
| bool | tf_ssb_db_set_account_password (uv_loop_t *loop, sqlite3 *db, JSContext *context, const char *name, const char *password) |
| bool | tf_ssb_db_register_account (uv_loop_t *loop, sqlite3 *db, JSContext *context, const char *name, const char *password) |
| const char * | tf_ssb_db_get_property (tf_ssb_t *ssb, const char *id, const char *key) |
| bool | tf_ssb_db_set_property (tf_ssb_t *ssb, const char *id, const char *key, const char *value) |
| bool | tf_ssb_db_remove_property (tf_ssb_t *ssb, const char *id, const char *key) |
| bool | tf_ssb_db_remove_value_from_array_property (tf_ssb_t *ssb, const char *id, const char *key, const char *value) |
| bool | tf_ssb_db_add_value_to_array_property (tf_ssb_t *ssb, const char *id, const char *key, const char *value) |
| const char * | tf_ssb_db_resolve_index (sqlite3 *db, const char *host) |
| bool | tf_ssb_db_verify (tf_ssb_t *ssb, const char *id, int32_t debug_sequence, bool fix) |
| bool | tf_ssb_db_user_has_permission (tf_ssb_t *ssb, sqlite3 *db, const char *id, const char *permission) |
| bool | tf_ssb_db_get_global_setting_bool (sqlite3 *db, const char *name, bool *out_value) |
| bool | tf_ssb_db_get_global_setting_int64 (sqlite3 *db, const char *name, int64_t *out_value) |
| bool | tf_ssb_db_get_global_setting_string (sqlite3 *db, const char *name, char *out_value, size_t size) |
| const char * | tf_ssb_db_get_global_setting_string_alloc (sqlite3 *db, const char *name) |
| bool | tf_ssb_db_set_global_setting_from_string (sqlite3 *db, const char *name, const char *value) |
| const char * | tf_ssb_db_get_profile (sqlite3 *db, const char *id) |
| const char * | tf_ssb_db_get_profile_name (sqlite3 *db, const char *id) |
| bool | tf_ssb_db_generate_invite (sqlite3 *db, const char *id, const char *host, int port, int use_count, int expires_seconds, char *out_invite, size_t size) |
| bool | tf_ssb_db_use_invite (sqlite3 *db, const char *id) |
| bool | tf_ssb_db_is_account_familiar (sqlite3 *db, const char *id, int depth) |
| int | tf_ssb_sqlite_authorizer (void *user_data, int action_code, const char *arg0, const char *arg1, const char *arg2, const char *arg3) |
| bool | tf_ssb_db_has_invite (sqlite3 *db, const char *id) |
| tf_ssb_identity_info_t * | tf_ssb_db_get_identity_info (tf_ssb_t *ssb, const char *user, const char *package_owner, const char *package_name) |
| void | tf_ssb_db_add_blob_wants (sqlite3 *db, const char *id) |
| void | tf_ssb_db_add_block (sqlite3 *db, const char *id) |
| void | tf_ssb_db_remove_block (sqlite3 *db, const char *id) |
| bool | tf_ssb_db_is_blocked (sqlite3 *db, const char *id) |
| void | tf_ssb_db_get_blocks (sqlite3 *db, void(*callback)(const char *id, double timestamp, void *user_data), void *user_data) |
| char * | tf_ssb_db_swap_with_server_identity (sqlite3 *db, const char *user, const char *user_id, const char *server_id) |
| bool | tf_ssb_db_get_app_blob_from_message (sqlite3 *db, const char *message_id, char *out_blob_id, size_t size) |
| const char * | tf_ssb_db_get_app_from_message (sqlite3 *db, const char *message_id) |
This is the main interface to SSB persistence. Everything about getting and storing messages and blobs goes through here.
| typedef struct sqlite3_stmt sqlite3_stmt |
An sqlite3 database.
| typedef void() tf_ssb_db_blob_get_callback_t(bool found, const uint8_t *data, size_t size, void *user_data) |
A function called when a blob is retrieved from the database.
| found | Whether the blob was found. |
| data | The blob data if found. |
| size | The size of the blob data if found, in bytes. |
| user_data | The user data. |
| typedef void() tf_ssb_db_blob_store_callback_t(const char *id, bool is_new, void *user_data) |
A function called when a block is stored in the database.
| id | The blob identifier. |
| is_new | True if the blob wasn't already in the database. |
| user_data | The user data. |
| typedef void() tf_ssb_db_store_message_callback_t(const char *id, bool stored, void *user_data) |
A function called when a message is stored in the database.
| id | The message identifier. |
| stored | True if the message wasn't already in the database. |
| user_data | The user data. |
| typedef struct _tf_ssb_db_stored_connection_t tf_ssb_db_stored_connection_t |
Information about a stored SHS connection.
| typedef struct _tf_ssb_following_t tf_ssb_following_t |
Information about a single followed account.
| typedef struct _tf_ssb_identity_info_t tf_ssb_identity_info_t |
Identity information
| typedef struct _tf_ssb_t tf_ssb_t |
An SSB instance.
| void tf_ssb_db_add_blob_wants | ( | sqlite3 * | db, |
| const char * | id | ||
| ) |
Add or update a blob wants cache entry.
| db | The database. |
| id | The wanted blob ID. |
| void tf_ssb_db_add_block | ( | sqlite3 * | db, |
| const char * | id | ||
| ) |
Add an instance-wide block.
| db | The database. |
| id | The account, message, or blob ID to block. |
| bool tf_ssb_db_add_value_to_array_property | ( | tf_ssb_t * | ssb, |
| const char * | id, | ||
| const char * | key, | ||
| const char * | value | ||
| ) |
Ensure a value is in an entry in the properties table that is a JSON array.
| ssb | The SSB instance. |
| id | The user. |
| key | The property key. |
| value | The value to add to the JSON array. |
| bool tf_ssb_db_blob_get | ( | tf_ssb_t * | ssb, |
| const char * | id, | ||
| uint8_t ** | out_blob, | ||
| size_t * | out_size | ||
| ) |
Retrieve a blob from the database.
| ssb | The SSB instance. | |
| id | The blob identifier. | |
| [out] | out_blob | Populated with the blob data. |
| [out] | out_size | The size of the blob data. |
| void tf_ssb_db_blob_get_async | ( | tf_ssb_t * | ssb, |
| const char * | id, | ||
| tf_ssb_db_blob_get_callback_t * | callback, | ||
| void * | user_data | ||
| ) |
Retrieve a blob from the database asynchronously.
| ssb | The SSB instance. |
| id | The blob identifier. |
| callback | Callback called with the result. |
| user_data | The user data. |
| bool tf_ssb_db_blob_get_from_db | ( | sqlite3 * | db, |
| const char * | id, | ||
| uint8_t ** | out_blob, | ||
| size_t * | out_size | ||
| ) |
Retrieve a blob from the database.
| db | The database. | |
| id | The blob identifier. | |
| [out] | out_blob | Populated with the blob data. |
| [out] | out_size | The size of the blob data. |
| bool tf_ssb_db_blob_has | ( | sqlite3 * | db, |
| const char * | id | ||
| ) |
Determine whether a blob is in the database by ID.
| db | The SQLite database instance to use. |
| id | The blob identifier. |
| bool tf_ssb_db_blob_store | ( | tf_ssb_t * | ssb, |
| const uint8_t * | blob, | ||
| size_t | size, | ||
| char * | out_id, | ||
| size_t | out_id_size, | ||
| bool * | out_new | ||
| ) |
Store a blob in the database and wait for the operation to complete.
| ssb | The SSB instance. | |
| blob | The blob data. | |
| size | The size of the blob. | |
| [out] | out_id | Populated with the blob identifier. |
| out_id_size | The size of the out_id buffer. | |
| [out] | out_new | True if the blob wasn't already in the datbase. |
| void tf_ssb_db_blob_store_async | ( | tf_ssb_t * | ssb, |
| const uint8_t * | blob, | ||
| size_t | size, | ||
| tf_ssb_db_blob_store_callback_t * | callback, | ||
| void * | user_data | ||
| ) |
Store a blob in the database asynchronously.
| ssb | The SSB instance. |
| blob | The blob data. |
| size | The size of the blob data. |
| callback | A callback to call upon completion. |
| user_data | User data for the callback. |
| bool tf_ssb_db_check | ( | sqlite3 * | db, |
| const char * | author | ||
| ) |
Sanity check the feed for the given author.
| db | The SQLite database instance to use. |
| author | The identity of the author to check. |
| tf_ssb_following_t * tf_ssb_db_following_deep | ( | tf_ssb_t * | ssb, |
| const char ** | ids, | ||
| int | count, | ||
| int | depth, | ||
| bool | include_blocks | ||
| ) |
Return information about identities visible from a set of identities given known follows and blocks.
| ssb | The SSB instance. |
| ids | An array of identities. |
| count | The number of identities. |
| depth | The following depth to use (prefer 2). |
| include_blocks | Whether to include blocked identities in results. |
| const char ** tf_ssb_db_following_deep_ids | ( | tf_ssb_t * | ssb, |
| const char ** | ids, | ||
| int | count, | ||
| int | depth | ||
| ) |
Get all the identities visible from a set of identities given known follows and blocks.
| ssb | The SSB instance. |
| ids | An array of identities. |
| count | The number of identities. |
| depth | The following depth to use (prefer 2). |
| void tf_ssb_db_forget_stored_connection | ( | tf_ssb_t * | ssb, |
| const char * | address, | ||
| int | port, | ||
| const char * | pubkey | ||
| ) |
Remove a stored connection.
| ssb | The SSB instance. |
| address | The connection address. |
| port | The connection network port number. |
| pubkey | The identity of the connection. |
| bool tf_ssb_db_generate_invite | ( | sqlite3 * | db, |
| const char * | id, | ||
| const char * | host, | ||
| int | port, | ||
| int | use_count, | ||
| int | expires_seconds, | ||
| char * | out_invite, | ||
| size_t | size | ||
| ) |
Generate an invite code and store information for it to be usable.
| db | The database. |
| id | The identity. |
| host | Hostname to which recipient should connect. |
| port | The port to which the recipient should connect. |
| use_count | Number of times the invite code is allowed to be used, or -1 for indefinitely. |
| expires_seconds | How long the invite lasts. |
| out_invite | Populated with the invite code on success. |
| size | The size of the out_invite buffer. |
| bool tf_ssb_db_get_account_password_hash | ( | tf_ssb_t * | ssb, |
| const char * | name, | ||
| char * | out_password, | ||
| size_t | password_size | ||
| ) |
Retrieve a user's hashed password from the database.
| ssb | The SSB instance. | |
| name | The username. | |
| [out] | out_password | Populated with the password. |
| password_size | The size of the out_password buffer. |
| const char ** tf_ssb_db_get_all_visible_identities | ( | tf_ssb_t * | ssb, |
| int | depth | ||
| ) |
Get all visible identities from all local accounts.
| ssb | The SSB instance. |
| depth | The following depth to consider (prefer 2). |
| bool tf_ssb_db_get_app_blob_from_message | ( | sqlite3 * | db, |
| const char * | message_id, | ||
| char * | out_blob_id, | ||
| size_t | size | ||
| ) |
Get the app blob id from a message's content.
| db | The database. |
| message_id | The message. |
| out_blob_id | Populated with the blob ID if found. |
| size | Size of the out_blob_id buffer. |
| const char * tf_ssb_db_get_app_from_message | ( | sqlite3 * | db, |
| const char * | message_id | ||
| ) |
Get the app JSON from a message's content.
| db | The database. |
| message_id | The message. |
| void tf_ssb_db_get_blocks | ( | sqlite3 * | db, |
| void(*)(const char *id, double timestamp, void *user_data) | callback, | ||
| void * | user_data | ||
| ) |
Get block list.
| db | The database. |
| callback | Called for each entry. |
| user_data | User data to be passed to the callback. |
| bool tf_ssb_db_get_global_setting_bool | ( | sqlite3 * | db, |
| const char * | name, | ||
| bool * | out_value | ||
| ) |
Get a boolean global setting value.
| db | The database. |
| name | The setting name. |
| out_value | Populated with the value. |
| bool tf_ssb_db_get_global_setting_int64 | ( | sqlite3 * | db, |
| const char * | name, | ||
| int64_t * | out_value | ||
| ) |
Get an int64_t global setting value.
| db | The database. |
| name | The setting name. |
| out_value | Populated with the value. |
| bool tf_ssb_db_get_global_setting_string | ( | sqlite3 * | db, |
| const char * | name, | ||
| char * | out_value, | ||
| size_t | size | ||
| ) |
Get a string global setting value.
| db | The database. |
| name | The setting name. |
| out_value | Populated with the value. |
| size | The size of the out_value buffer. |
| const char * tf_ssb_db_get_global_setting_string_alloc | ( | sqlite3 * | db, |
| const char * | name | ||
| ) |
Get a string global setting value.
| db | The database. |
| name | The setting name. |
| tf_ssb_identity_info_t * tf_ssb_db_get_identity_info | ( | tf_ssb_t * | ssb, |
| const char * | user, | ||
| const char * | package_owner, | ||
| const char * | package_name | ||
| ) |
Get available identities, names, and the active identity for a user.
| ssb | The SSB instance. |
| user | The user name. |
| package_owner | The owner of the package for which identity info is being fetched. |
| package_name | The name of the package for which identity info is being fetched. |
| bool tf_ssb_db_get_latest_message_by_author | ( | sqlite3 * | db, |
| sqlite3_stmt ** | in_out_statement, | ||
| const char * | author, | ||
| int32_t * | out_sequence, | ||
| char * | out_message_id, | ||
| size_t | out_message_id_size | ||
| ) |
Get information about the last message from an author.
| db | A DB reader to use. | |
| in_out_statement | If specified, will be populated with a statement that will be reused on subsequent calls and must be finalized by the caller. | |
| author | The author's identity. | |
| [out] | out_sequence | Populated with the message sequence number. |
| [out] | out_message_id | Populated with the message identifier. |
| out_message_id_size | The size of the out_message_id buffer. |
| bool tf_ssb_db_get_message_by_author_and_sequence | ( | tf_ssb_t * | ssb, |
| const char * | author, | ||
| int32_t | sequence, | ||
| char * | out_message_id, | ||
| size_t | out_message_id_size, | ||
| char * | out_previous, | ||
| 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 a message by its author and sequence number.
| ssb | The SSB instance. | |
| author | The author's identity. | |
| sequence | The message sequence number. | |
| [out] | out_message_id | Populated with the message identifier. |
| out_message_id_size | The size of the out_message_id buffer. | |
| [out] | out_previous | Populated with the previous message identifier. |
| out_previous_size | The size of the out_previous buffer. | |
| [out] | out_timestamp | Populated with the timestamp. |
| [out] | out_content | Populated with the message content. Free with tf_free(). |
| [out] | out_hash | Populated with the message hash format. |
| out_hash_size | The size of the out_hash buffer. | |
| [out] | out_signature | Populated with the message signature. |
| out_signature_size | The size of the out_signature buffer. | |
| [out] | out_flags | Populated with flags describing the format of the message. |
| const char * tf_ssb_db_get_profile | ( | sqlite3 * | db, |
| const char * | id | ||
| ) |
Get the latest profile information for the given identity.
| db | The database. |
| id | The identity. |
| const char * tf_ssb_db_get_profile_name | ( | sqlite3 * | db, |
| const char * | id | ||
| ) |
Get the latest profile name for the given identity.
| db | The database. |
| id | The identity. |
| const char * tf_ssb_db_get_property | ( | tf_ssb_t * | ssb, |
| const char * | id, | ||
| const char * | key | ||
| ) |
Get an entry from the properties table.
| ssb | The SSB instance. |
| id | The user. |
| key | The property key. |
| tf_ssb_db_stored_connection_t * tf_ssb_db_get_stored_connections | ( | tf_ssb_t * | ssb, |
| int * | out_count | ||
| ) |
Get the list of stored connections from the SSB connection tracker.
| ssb | The SSB instance. | |
| [out] | out_count | Populated with the number of returned connections. |
| const char * tf_ssb_db_get_user_for_identity | ( | tf_ssb_t * | ssb, |
| const char * | public_key | ||
| ) |
Get the user owning an identity.
| ssb | The SSB instance. |
| public_key | the identity. |
| bool tf_ssb_db_has_invite | ( | sqlite3 * | db, |
| const char * | id | ||
| ) |
Check if we have an invite for the given account.
| db | The database. |
| id | The invite public key to check. |
| bool tf_ssb_db_identity_add | ( | tf_ssb_t * | ssb, |
| const char * | user, | ||
| const char * | public_key, | ||
| const char * | private_key | ||
| ) |
Add an identity for a user to the database.
| ssb | The SSB instance. |
| user | The user's username. |
| public_key | The public key of the identity. |
| private_key | The private key of the identity. |
| bool tf_ssb_db_identity_create | ( | tf_ssb_t * | ssb, |
| const char * | user, | ||
| uint8_t * | out_public_key, | ||
| uint8_t * | out_private_key | ||
| ) |
Create a new identity for a user.
| ssb | The SSB instance. | |
| user | The user's username. | |
| [out] | out_public_key | A buffer populated with the new public key. |
| [out] | out_private_key | A buffer populated with the new private key. |
| bool tf_ssb_db_identity_delete | ( | tf_ssb_t * | ssb, |
| const char * | user, | ||
| const char * | public_key | ||
| ) |
Delete an identity for a user from the database. This is an unrecoverable operation.
| ssb | The SSB instance. |
| user | The user's username. |
| public_key | The identity to delete. |
| bool tf_ssb_db_identity_get_active | ( | sqlite3 * | db, |
| const char * | user, | ||
| const char * | package_owner, | ||
| const char * | package_name, | ||
| char * | out_identity, | ||
| size_t | out_identity_size | ||
| ) |
Get the active identity for a user for a given package.
| db | An sqlite3 database. | |
| user | The username. | |
| package_owner | The username of the package owner. | |
| package_name | The name of the package. | |
| [out] | out_identity | Populated with the identity. |
| out_identity_size | The size of the out_identity buffer. |
| int tf_ssb_db_identity_get_count_for_user | ( | tf_ssb_t * | ssb, |
| const char * | user | ||
| ) |
Get the number of SSB identities a Tilde Friends user has.
| ssb | The SSB instance. |
| user | The user's username. |
| bool tf_ssb_db_identity_get_private_key | ( | tf_ssb_t * | ssb, |
| const char * | user, | ||
| const char * | public_key, | ||
| uint8_t * | out_private_key, | ||
| size_t | private_key_size | ||
| ) |
Get the private key for an identity in the database.
| ssb | The SSB instance. | |
| user | The owning user's username. | |
| public_key | The public key of the identity. | |
| [out] | out_private_key | A buffer to receive the private key of the identity. |
| private_key_size | The size of the out_private_key buffer. |
| void tf_ssb_db_identity_visit | ( | tf_ssb_t * | ssb, |
| const char * | user, | ||
| void(*)(const char *identity, void *user_data) | callback, | ||
| void * | user_data | ||
| ) |
Call a function for each identity owned by a user.
| ssb | The SSB instance. |
| user | The user's username. |
| callback | The function to call for each identity. |
| user_data | User data to pass to the callback. |
| void tf_ssb_db_identity_visit_all | ( | tf_ssb_t * | ssb, |
| void(*)(const char *identity, void *user_data) | callback, | ||
| void * | user_data | ||
| ) |
Call a function for all identities in the database.
| ssb | The SSB instance. |
| callback | The callback to call for each identity. |
| user_data | User data to pass to the callback. |
| void tf_ssb_db_init | ( | tf_ssb_t * | ssb | ) |
Initialize the database writer for an SSB instance.
| ssb | The SSB instance. |
| void tf_ssb_db_init_reader | ( | sqlite3 * | db | ) |
Configure an opened SQLite database for reading.
| bool tf_ssb_db_is_account_familiar | ( | sqlite3 * | db, |
| const char * | id, | ||
| int | depth | ||
| ) |
Determine if an account is familiar, meaning it is local or within the given follow depth of the local accounts or we have already replicated data for it.
| db | The database. |
| id | The identity. |
| depth | The follow depth. |
| bool tf_ssb_db_is_blocked | ( | sqlite3 * | db, |
| const char * | id | ||
| ) |
Check if an ID is blocked on this instance.
| db | The database. |
| id | The account, message, or blob ID to check. |
| bool tf_ssb_db_register_account | ( | uv_loop_t * | loop, |
| sqlite3 * | db, | ||
| JSContext * | context, | ||
| const char * | name, | ||
| const char * | password | ||
| ) |
Add a user account to the database.
| loop | The event loop. |
| db | A DB writer. |
| context | A JS context. |
| name | The username to add. |
| password | The user's raw password. |
| void tf_ssb_db_remove_block | ( | sqlite3 * | db, |
| const char * | id | ||
| ) |
Remove an instance-wide block.
| db | The database. |
| id | The account, message, or blob ID to unblock. |
| bool tf_ssb_db_remove_property | ( | tf_ssb_t * | ssb, |
| const char * | id, | ||
| const char * | key | ||
| ) |
Remove an entry in the properties table.
| ssb | The SSB instance. |
| id | The user. |
| key | The property key. |
| bool tf_ssb_db_remove_value_from_array_property | ( | tf_ssb_t * | ssb, |
| const char * | id, | ||
| const char * | key, | ||
| const char * | value | ||
| ) |
Remove a value from an entry in the properties table that is a JSON array.
| ssb | The SSB instance. |
| id | The user. |
| key | The property key. |
| value | The value to remove from the JSON array. |
| const char * tf_ssb_db_resolve_index | ( | sqlite3 * | db, |
| const char * | host | ||
| ) |
Resolve a hostname to its index path by global settings.
| db | The database. |
| host | The hostname. |
| bool tf_ssb_db_set_account_password | ( | uv_loop_t * | loop, |
| sqlite3 * | db, | ||
| JSContext * | context, | ||
| const char * | name, | ||
| const char * | password | ||
| ) |
Insert or update a user's hashed password in the database.
| loop | The event loop. |
| db | A DB writer. |
| context | A JS context. |
| name | The username. |
| password | The raw password. |
| bool tf_ssb_db_set_global_setting_from_string | ( | sqlite3 * | db, |
| const char * | name, | ||
| const char * | value | ||
| ) |
Set a global setting from a string representation of its value.
| db | The database. |
| name | The setting name. |
| value | The setting value. |
| bool tf_ssb_db_set_property | ( | tf_ssb_t * | ssb, |
| const char * | id, | ||
| const char * | key, | ||
| const char * | value | ||
| ) |
Store an entry in the properties table.
| ssb | The SSB instance. |
| id | The user. |
| key | The property key. |
| value | The property value. |
| void tf_ssb_db_store_message | ( | tf_ssb_t * | ssb, |
| JSContext * | context, | ||
| const char * | id, | ||
| JSValue | val, | ||
| const char * | signature, | ||
| int | flags, | ||
| tf_ssb_db_store_message_callback_t * | callback, | ||
| void * | user_data | ||
| ) |
Store a message in the database.
| ssb | The SSB instance. |
| context | The JS context. |
| id | The message identifier. |
| val | The message object. |
| signature | The signature of the message. |
| flags | tf_ssb_message_flags_t describing the message. |
| callback | A callback to call upon completion. |
| user_data | User data for the callback. |
| char * tf_ssb_db_swap_with_server_identity | ( | sqlite3 * | db, |
| const char * | user, | ||
| const char * | user_id, | ||
| const char * | server_id | ||
| ) |
Swap a user's identity with the server identity.
| db | The database. |
| user | The user. |
| user_id | The user identity. |
| server_id | The server identity. |
| bool tf_ssb_db_use_invite | ( | sqlite3 * | db, |
| const char * | id | ||
| ) |
Consume and validate an invite.
| db | The database. |
| id | The invite public key. |
| bool tf_ssb_db_user_has_permission | ( | tf_ssb_t * | ssb, |
| sqlite3 * | db, | ||
| const char * | id, | ||
| const char * | permission | ||
| ) |
Check if a user has a specific permission.
| ssb | The SSB instance. |
| db | Optional database instance. If NULL, one will be acquired from ssb. |
| id | The user ID. |
| permission | The name of the permission. |
| bool tf_ssb_db_verify | ( | tf_ssb_t * | ssb, |
| const char * | id, | ||
| int32_t | debug_sequence, | ||
| bool | fix | ||
| ) |
Verify an author's feed.
| ssb | The SSB instance. |
| id | The author's identity. |
| debug_sequence | Message sequence number to debug if non-zero. |
| fix | Fix invalid messages when possible. |
| JSValue tf_ssb_db_visit_query | ( | tf_ssb_t * | ssb, |
| const char * | query, | ||
| const JSValue | binds, | ||
| void(*)(JSValue row, void *user_data) | callback, | ||
| void * | user_data | ||
| ) |
Call a function for each result row of an SQL query.
| ssb | The SSB instance. |
| query | The SQL query. |
| binds | An array of values to bind to SQL parameters. |
| callback | A callback to call for each result row. |
| user_data | User data to pass to the callback. |
| JSValue tf_ssb_format_message | ( | JSContext * | context, |
| const char * | previous, | ||
| const char * | author, | ||
| int32_t | sequence, | ||
| double | timestamp, | ||
| const char * | hash, | ||
| const char * | content, | ||
| const char * | signature, | ||
| int | flags | ||
| ) |
Format a message in the standard format for SSB signing.
| context | A JS context. |
| previous | The previous message identifier. |
| author | The author's public key. |
| sequence | The message sequence number. |
| timestamp | The message timestamp. |
| hash | The hash type (probably "sha256"). |
| content | The message content. |
| signature | The signature of the message. |
| flags | tf_ssb_message_flags_t describing the message. |
| int tf_ssb_sqlite_authorizer | ( | void * | user_data, |
| int | action_code, | ||
| const char * | arg0, | ||
| const char * | arg1, | ||
| const char * | arg2, | ||
| const char * | arg3 | ||
| ) |
An SQLite authorizer callback. See https://www.sqlite.org/c3ref/set_authorizer.html for use.
| user_data | User data registered with the authorizer. |
| action_code | The type of action. |
| arg0 | Depends on the action. |
| arg1 | Depends on the action. |
| arg2 | Depends on the action. |
| arg3 | Depends on the action. |