From 4931c489edcea8c9c8536ca2fb8b359e0b3a15df Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Thu, 22 May 2025 10:56:30 -0400 Subject: [PATCH] ssb: Dispatch blob wants immediately when added as the result of a web request. --- apps/intro/index.html | 4 +--- apps/ssb/tf-app.js | 11 ++++------- src/httpd.js.c | 8 ++++++++ 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/apps/intro/index.html b/apps/intro/index.html index c210effd..3637e950 100644 --- a/apps/intro/index.html +++ b/apps/intro/index.html @@ -132,9 +132,7 @@ diff --git a/apps/ssb/tf-app.js b/apps/ssb/tf-app.js index 0c1e3583..4292a903 100644 --- a/apps/ssb/tf-app.js +++ b/apps/ssb/tf-app.js @@ -421,13 +421,10 @@ class TfElement extends LitElement { [JSON.stringify(Object.keys(users))] ); for (let row of info) { - users[row.author] = Object.assign( - users[row.author], - { - seq: row.max_sequence, - ts: row.max_ts, - } - ); + users[row.author] = Object.assign(users[row.author], { + seq: row.max_sequence, + ts: row.max_ts, + }); } return users; } diff --git a/src/httpd.js.c b/src/httpd.js.c index 3c347ad6..702bccbe 100644 --- a/src/httpd.js.c +++ b/src/httpd.js.c @@ -1116,6 +1116,7 @@ typedef struct _view_t void* data; size_t size; char etag[256]; + char notify_want_blob_id[k_blob_id_len]; bool not_modified; } view_t; @@ -1175,6 +1176,7 @@ static void _httpd_endpoint_view_work(tf_ssb_t* ssb, void* user_data) sqlite3* db = tf_ssb_acquire_db_writer(ssb); tf_ssb_db_add_blob_wants(db, blob_id); tf_ssb_release_db_writer(ssb, db); + snprintf(view->notify_want_blob_id, sizeof(view->notify_want_blob_id), "%s", blob_id); } } } @@ -1218,6 +1220,12 @@ static void _httpd_endpoint_view_after_work(tf_ssb_t* ssb, int status, void* use const char* k_payload = tf_http_status_text(404); tf_http_respond(view->request, 404, NULL, 0, k_payload, strlen(k_payload)); } + + if (*view->notify_want_blob_id) + { + tf_ssb_notify_blob_want_added(ssb, view->notify_want_blob_id); + } + tf_free(view->form_data); tf_http_request_unref(view->request); tf_free(view);