ssb: Expose last successful connection time for stored connections.
Some checks failed
Build Tilde Friends / Build-All (push) Has been cancelled
Some checks failed
Build Tilde Friends / Build-All (push) Has been cancelled
This commit is contained in:
parent
ab9f57f044
commit
aa7a32395e
@ -1,5 +1,5 @@
|
||||
{
|
||||
"type": "tildefriends-app",
|
||||
"emoji": "🦀",
|
||||
"previous": "&XXMkhzapfVH8TnYyi4A+lCq2orE57Z5kStC4AbfX04Q=.sha256"
|
||||
"previous": "&JVIVaxuqwtqP70qgese6cIMI0gtN4BdJetFLSq8TJzY=.sha256"
|
||||
}
|
||||
|
@ -308,6 +308,12 @@ class TfTabConnectionsElement extends LitElement {
|
||||
<div class="w3-bar-item">
|
||||
<tf-user id=${x.pubkey} .users=${self.users}></tf-user>
|
||||
<div><small>${x.address}:${x.port}</small></div>
|
||||
<div>
|
||||
<small
|
||||
>Last connection:
|
||||
${new Date(x.last_success * 1000)}</small
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
${this.render_message(x)}
|
||||
|
@ -1888,13 +1888,15 @@ tf_ssb_db_stored_connection_t* tf_ssb_db_get_stored_connections(tf_ssb_t* ssb, i
|
||||
int count = 0;
|
||||
|
||||
sqlite3_stmt* statement;
|
||||
if (sqlite3_prepare_v2(db, "SELECT host, port, key FROM connections ORDER BY host, port, key", -1, &statement, NULL) == SQLITE_OK)
|
||||
if (sqlite3_prepare_v2(db, "SELECT host, port, key, last_attempt, last_success FROM connections ORDER BY host, port, key", -1, &statement, NULL) == SQLITE_OK)
|
||||
{
|
||||
while (sqlite3_step(statement) == SQLITE_ROW)
|
||||
{
|
||||
result = tf_resize_vec(result, sizeof(tf_ssb_db_stored_connection_t) * (count + 1));
|
||||
result[count] = (tf_ssb_db_stored_connection_t) {
|
||||
.port = sqlite3_column_int(statement, 1),
|
||||
.last_attempt = sqlite3_column_int64(statement, 3),
|
||||
.last_success = sqlite3_column_int64(statement, 4),
|
||||
};
|
||||
snprintf(result[count].address, sizeof(result[count].address), "%s", (const char*)sqlite3_column_text(statement, 0));
|
||||
snprintf(result[count].pubkey, sizeof(result[count].pubkey), "%s", (const char*)sqlite3_column_text(statement, 2));
|
||||
|
@ -340,6 +340,10 @@ typedef struct _tf_ssb_db_stored_connection_t
|
||||
int port;
|
||||
/** The identity. */
|
||||
char pubkey[k_id_base64_len];
|
||||
/** Time of last attempted connection. */
|
||||
int64_t last_attempt;
|
||||
/** Time of last successful connection. */
|
||||
int64_t last_success;
|
||||
} tf_ssb_db_stored_connection_t;
|
||||
|
||||
/**
|
||||
|
@ -988,6 +988,8 @@ static void _tf_ssb_stored_connections_after_work(tf_ssb_t* ssb, int status, voi
|
||||
JS_SetPropertyStr(context, connection, "address", JS_NewString(context, work->connections[i].address));
|
||||
JS_SetPropertyStr(context, connection, "port", JS_NewInt32(context, work->connections[i].port));
|
||||
JS_SetPropertyStr(context, connection, "pubkey", JS_NewString(context, work->connections[i].pubkey));
|
||||
JS_SetPropertyStr(context, connection, "last_attempt", JS_NewInt64(context, work->connections[i].last_attempt));
|
||||
JS_SetPropertyStr(context, connection, "last_success", JS_NewInt64(context, work->connections[i].last_success));
|
||||
JS_SetPropertyUint32(context, result, i, connection);
|
||||
}
|
||||
tf_free(work->connections);
|
||||
|
Loading…
x
Reference in New Issue
Block a user