From 24105f6e9759b74c04522de1de12ddb77cfba568 Mon Sep 17 00:00:00 2001 From: postscriptum Date: Thu, 22 May 2025 03:34:48 +0300 Subject: use utf-8 lowercase function for tags #396 --- data.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'data.c') diff --git a/data.c b/data.c index e3fa52d..d5dc171 100644 --- a/data.c +++ b/data.c @@ -2200,7 +2200,7 @@ void tag_index(const char *id, const xs_dict *obj) if (*name == '\0') continue; - name = xs_tolower_i((xs_str *)name); + name = xs_utf8_to_lower((xs_str *)name); xs *md5_tag = xs_md5_hex(name, strlen(name)); xs *tag_dir = xs_fmt("%s/%c%c", g_tag_dir, md5_tag[0], md5_tag[1]); @@ -2230,7 +2230,7 @@ xs_str *tag_fn(const char *tag) if (*tag == '#') tag++; - xs *lw_tag = xs_tolower_i(xs_dup(tag)); + xs *lw_tag = xs_utf8_to_lower(xs_dup(tag)); xs *md5 = xs_md5_hex(lw_tag, strlen(lw_tag)); return xs_fmt("%s/tag/%c%c/%s.idx", srv_basedir, md5[0], md5[1], md5); -- cgit From e567736640da21d37848567cd164cb84bbdab507 Mon Sep 17 00:00:00 2001 From: postscriptum Date: Thu, 22 May 2025 04:16:28 +0300 Subject: add missed replacement to the `content_match` function --- data.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'data.c') diff --git a/data.c b/data.c index d5dc171..8ca271d 100644 --- a/data.c +++ b/data.c @@ -2817,7 +2817,7 @@ int content_match(const char *file, const xs_dict *msg) /* massage content (strip HTML tags, etc.) */ xs *c = xs_regex_replace(v, "<[^>]+>", " "); c = xs_regex_replace_i(c, " {2,}", " "); - c = xs_tolower_i(c); + c = xs_utf8_to_lower(c); while (!r && !feof(f)) { xs *rx = xs_strip_i(xs_readline(f)); -- cgit From 56816b305155fee2154c7991ba9be8c0e7671307 Mon Sep 17 00:00:00 2001 From: grunfink Date: Thu, 22 May 2025 11:18:48 +0200 Subject: Minor memory leak fixes. --- activitypub.c | 2 +- data.c | 8 ++++---- format.c | 2 +- mastoapi.c | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) (limited to 'data.c') diff --git a/activitypub.c b/activitypub.c index c06d8df..0cc7bcb 100644 --- a/activitypub.c +++ b/activitypub.c @@ -903,7 +903,7 @@ xs_str *process_tags(snac *snac, const char *content, xs_list **tag) if (*v == '#') { /* hashtag */ xs *d = xs_dict_new(); - xs *n = xs_utf8_to_lower(xs_dup(v)); + xs *n = xs_utf8_to_lower(v); xs *h = xs_fmt("%s?t=%s", srv_baseurl, n + 1); xs *l = xs_fmt("%s", h, v); diff --git a/data.c b/data.c index 631a68b..5f890d3 100644 --- a/data.c +++ b/data.c @@ -2247,7 +2247,7 @@ xs_str *tag_fn(const char *tag) if (*tag == '#') tag++; - xs *lw_tag = xs_utf8_to_lower(xs_dup(tag)); + xs *lw_tag = xs_utf8_to_lower(tag); xs *md5 = xs_md5_hex(lw_tag, strlen(lw_tag)); return xs_fmt("%s/tag/%c%c/%s.idx", srv_basedir, md5[0], md5[1], md5); @@ -2832,9 +2832,9 @@ int content_match(const char *file, const xs_dict *msg) srv_debug(1, xs_fmt("content_match: loading regexes from %s", fn)); /* massage content (strip HTML tags, etc.) */ - xs *c = xs_regex_replace(v, "<[^>]+>", " "); - c = xs_regex_replace_i(c, " {2,}", " "); - c = xs_utf8_to_lower(c); + xs *c1 = xs_regex_replace(v, "<[^>]+>", " "); + c1 = xs_regex_replace_i(c1, " {2,}", " "); + xs *c = xs_utf8_to_lower(c1); while (!r && !feof(f)) { xs *rx = xs_strip_i(xs_readline(f)); diff --git a/format.c b/format.c index 0f844cd..9bad391 100644 --- a/format.c +++ b/format.c @@ -444,7 +444,7 @@ xs_str *sanitize(const char *content) if (n & 0x1) { xs *s1 = xs_strip_i(xs_crop_i(xs_dup(v), v[1] == '/' ? 2 : 1, -1)); xs *l1 = xs_split_n(s1, " ", 1); - xs *tag = xs_utf8_to_lower(xs_dup(xs_list_get(l1, 0))); + xs *tag = xs_utf8_to_lower(xs_list_get(l1, 0)); xs *s2 = NULL; int i; diff --git a/mastoapi.c b/mastoapi.c index c46a971..9875b12 100644 --- a/mastoapi.c +++ b/mastoapi.c @@ -1638,7 +1638,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, const char *aq = xs_dict_get(args, "q"); if (!xs_is_null(aq)) { - xs *q = xs_utf8_to_lower(xs_dup(aq)); + xs *q = xs_utf8_to_lower(aq); out = xs_list_new(); xs *wing = following_list(&snac1); xs *wers = follower_list(&snac1); -- cgit From 11b4a46d54ce55545a8ac4958e5ff292c072d1d3 Mon Sep 17 00:00:00 2001 From: shtrophic Date: Sun, 25 May 2025 11:38:15 +0200 Subject: Increase verbosity for srv_debug() in tag_index() --- data.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'data.c') diff --git a/data.c b/data.c index 5f890d3..f45e346 100644 --- a/data.c +++ b/data.c @@ -2235,7 +2235,7 @@ void tag_index(const char *id, const xs_dict *obj) fclose(f); } - srv_debug(0, xs_fmt("tagged %s #%s (#%s)", id, name, md5_tag)); + srv_debug(1, xs_fmt("tagged %s #%s (#%s)", id, name, md5_tag)); } } } -- cgit From 631e44a64a20741b5e4716bf75caf7fa743fef82 Mon Sep 17 00:00:00 2001 From: grunfink Date: Tue, 27 May 2025 21:08:57 +0200 Subject: Renamed timeline_here() to timeline_here_by_md5(), as it always should have been. --- data.c | 4 ++-- html.c | 6 +++--- main.c | 2 +- mastoapi.c | 2 +- snac.h | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) (limited to 'data.c') diff --git a/data.c b/data.c index f45e346..9eada38 100644 --- a/data.c +++ b/data.c @@ -1391,7 +1391,7 @@ xs_str *timeline_fn_by_md5(snac *snac, const char *md5) } -int timeline_here(snac *snac, const char *md5) +int timeline_here_by_md5(snac *snac, const char *md5) /* checks if an object is in the user cache */ { xs *fn = timeline_fn_by_md5(snac, md5); @@ -1515,7 +1515,7 @@ xs_list *timeline_top_level(snac *snac, const xs_list *list) break; /* well, there is a parent... but is it here? */ - if (!timeline_here(snac, line2)) + if (!timeline_here_by_md5(snac, line2)) break; /* it's here! try again with its own parent */ diff --git a/html.c b/html.c index 83dac0a..4aa0fa4 100644 --- a/html.c +++ b/html.c @@ -2117,7 +2117,7 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, if (!xs_is_null(parent) && *parent) { xs *md5 = xs_md5_hex(parent, strlen(parent)); - if (!timeline_here(user, md5)) { + if (!timeline_here_by_md5(user, md5)) { xs_html_add(post_header, xs_html_tag("div", xs_html_attr("class", "snac-origin"), @@ -3775,7 +3775,7 @@ int html_get_handler(const xs_dict *req, const char *q_path, /* add the post to the timeline */ xs *md5 = xs_md5_hex(q, strlen(q)); - if (!timeline_here(&snac, md5)) + if (!timeline_here_by_md5(&snac, md5)) timeline_add(&snac, q, object); } } @@ -3917,7 +3917,7 @@ int html_get_handler(const xs_dict *req, const char *q_path, xs *l = xs_split(p_path, "/"); const char *md5 = xs_list_get(l, -1); - if (md5 && *md5 && timeline_here(&snac, md5)) { + if (md5 && *md5 && timeline_here_by_md5(&snac, md5)) { xs *list0 = xs_list_append(xs_list_new(), md5); xs *list = timeline_top_level(&snac, list0); diff --git a/main.c b/main.c index 80df2d0..9cfbb0d 100644 --- a/main.c +++ b/main.c @@ -695,7 +695,7 @@ int main(int argc, char *argv[]) xs_json_dump(data, 4, stdout); enqueue_actor_refresh(&snac, xs_dict_get(data, "attributedTo"), 0); - if (!timeline_here(&snac, url)) + if (!timeline_here_by_md5(&snac, url)) timeline_add(&snac, url, data); else printf("Post %s already here\n", url); diff --git a/mastoapi.c b/mastoapi.c index 9875b12..c88fd1b 100644 --- a/mastoapi.c +++ b/mastoapi.c @@ -2510,7 +2510,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, if (xs_startswith(q, "https://")) { xs *md5 = xs_md5_hex(q, strlen(q)); - if (!timeline_here(&snac1, md5)) { + if (!timeline_here_by_md5(&snac1, md5)) { xs *object = NULL; int status; diff --git a/snac.h b/snac.h index 841c41e..621ab8a 100644 --- a/snac.h +++ b/snac.h @@ -164,7 +164,7 @@ int pending_count(snac *user); double timeline_mtime(snac *snac); int timeline_touch(snac *snac); -int timeline_here(snac *snac, const char *md5); +int timeline_here_by_md5(snac *snac, const char *md5); int timeline_get_by_md5(snac *snac, const char *md5, xs_dict **msg); int timeline_del(snac *snac, const char *id); xs_str *user_index_fn(snac *user, const char *idx_name); -- cgit From 5bc451159420d5d51a507fda82a623069cfae92b Mon Sep 17 00:00:00 2001 From: grunfink Date: Tue, 27 May 2025 21:14:23 +0200 Subject: New function timeline_here(). --- data.c | 8 ++++++++ html.c | 8 ++------ main.c | 2 +- mastoapi.c | 4 +--- snac.h | 1 + 5 files changed, 13 insertions(+), 10 deletions(-) (limited to 'data.c') diff --git a/data.c b/data.c index 9eada38..224976b 100644 --- a/data.c +++ b/data.c @@ -1400,6 +1400,14 @@ int timeline_here_by_md5(snac *snac, const char *md5) } +int timeline_here(snac *user, const char *id) +{ + xs *md5 = xs_md5_hex(id, strlen(id)); + + return timeline_here_by_md5(user, md5); +} + + int timeline_get_by_md5(snac *snac, const char *md5, xs_dict **msg) /* gets a message from the timeline */ { diff --git a/html.c b/html.c index 4aa0fa4..4c30355 100644 --- a/html.c +++ b/html.c @@ -2115,9 +2115,7 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, const char *parent = get_in_reply_to(msg); if (!xs_is_null(parent) && *parent) { - xs *md5 = xs_md5_hex(parent, strlen(parent)); - - if (!timeline_here_by_md5(user, md5)) { + if (!timeline_here(user, parent)) { xs_html_add(post_header, xs_html_tag("div", xs_html_attr("class", "snac-origin"), @@ -3773,9 +3771,7 @@ int html_get_handler(const xs_dict *req, const char *q_path, q = url_acct; /* add the post to the timeline */ - xs *md5 = xs_md5_hex(q, strlen(q)); - - if (!timeline_here_by_md5(&snac, md5)) + if (!timeline_here(&snac, q)) timeline_add(&snac, q, object); } } diff --git a/main.c b/main.c index 9cfbb0d..80df2d0 100644 --- a/main.c +++ b/main.c @@ -695,7 +695,7 @@ int main(int argc, char *argv[]) xs_json_dump(data, 4, stdout); enqueue_actor_refresh(&snac, xs_dict_get(data, "attributedTo"), 0); - if (!timeline_here_by_md5(&snac, url)) + if (!timeline_here(&snac, url)) timeline_add(&snac, url, data); else printf("Post %s already here\n", url); diff --git a/mastoapi.c b/mastoapi.c index c88fd1b..df713a8 100644 --- a/mastoapi.c +++ b/mastoapi.c @@ -2508,9 +2508,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, /* reply something only for offset 0; otherwise, apps like Tusky keep asking again and again */ if (xs_startswith(q, "https://")) { - xs *md5 = xs_md5_hex(q, strlen(q)); - - if (!timeline_here_by_md5(&snac1, md5)) { + if (!timeline_here(&snac1, q)) { xs *object = NULL; int status; diff --git a/snac.h b/snac.h index 621ab8a..f32a90d 100644 --- a/snac.h +++ b/snac.h @@ -165,6 +165,7 @@ int pending_count(snac *user); double timeline_mtime(snac *snac); int timeline_touch(snac *snac); int timeline_here_by_md5(snac *snac, const char *md5); +int timeline_here(snac *snac, const char *id); int timeline_get_by_md5(snac *snac, const char *md5, xs_dict **msg); int timeline_del(snac *snac, const char *id); xs_str *user_index_fn(snac *user, const char *idx_name); -- cgit From c8f6e1865dca9477d0cdfb95168bdca4a62852c3 Mon Sep 17 00:00:00 2001 From: grunfink Date: Fri, 30 May 2025 11:30:37 +0200 Subject: New function enqueue_notify_webhook(). --- data.c | 19 +++++++++++++++++++ snac.h | 2 ++ 2 files changed, 21 insertions(+) (limited to 'data.c') diff --git a/data.c b/data.c index 224976b..ddfb443 100644 --- a/data.c +++ b/data.c @@ -3166,6 +3166,8 @@ void notify_add(snac *snac, const char *type, const char *utype, pthread_mutex_unlock(&data_mutex); } + + enqueue_notify_webhook(snac, noti, 0); } @@ -3521,6 +3523,23 @@ void enqueue_webmention(const xs_dict *msg) } +void enqueue_notify_webhook(snac *user, const xs_dict *noti, int retries) +/* enqueues a notification webhook */ +{ + const char *webhook = xs_dict_get(user->config, "notify_webhook"); + + if (xs_is_string(webhook)) { + xs *qmsg = _new_qmsg("notify_webhook", noti, retries); + const char *ntid = xs_dict_get(qmsg, "ntid"); + xs *fn = xs_fmt("%s/queue/%s.json", user->basedir, ntid); + + qmsg = _enqueue_put(fn, qmsg); + + snac_debug(user, 1, xs_fmt("notify_webhook")); + } +} + + int was_question_voted(snac *user, const char *id) /* returns true if the user voted in this poll */ { diff --git a/snac.h b/snac.h index 06a36f1..b13a44a 100644 --- a/snac.h +++ b/snac.h @@ -294,6 +294,8 @@ void enqueue_object_request(snac *user, const char *id, int forward_secs); void enqueue_verify_links(snac *user); void enqueue_actor_refresh(snac *user, const char *actor, int forward_secs); void enqueue_webmention(const xs_dict *msg); +void enqueue_notify_webhook(snac *user, const xs_dict *noti, int retries); + int was_question_voted(snac *user, const char *id); xs_list *user_queue(snac *snac); -- cgit From 5a2aef8666a82a30dff329992bd41baa53d4e123 Mon Sep 17 00:00:00 2001 From: grunfink Date: Fri, 30 May 2025 12:12:19 +0200 Subject: More notify_webhook work. --- activitypub.c | 33 +++++++++++++++++++++++++++++++++ data.c | 11 ++++++++++- 2 files changed, 43 insertions(+), 1 deletion(-) (limited to 'data.c') diff --git a/activitypub.c b/activitypub.c index 8877a27..fb0c42c 100644 --- a/activitypub.c +++ b/activitypub.c @@ -2765,6 +2765,39 @@ void process_user_queue_item(snac *user, xs_dict *q_item) snac_log(user, xs_fmt("actor_refresh %s %d", actor, status)); } } + else + if (strcmp(type, "notify_webhook") == 0) { + const char *webhook = xs_dict_get(user->config, "notify_webhook"); + + if (xs_is_string(webhook)) { + const xs_dict *msg = xs_dict_get(q_item, "message"); + int retries = xs_number_get(xs_dict_get(q_item, "retries")); + + xs *hdrs = xs_dict_new(); + + hdrs = xs_dict_set(hdrs, "content-type", "application/json"); + hdrs = xs_dict_set(hdrs, "user-agent", USER_AGENT); + + xs *body = xs_json_dumps(msg, 4); + + int status; + xs *rsp = xs_http_request("POST", webhook, hdrs, body, strlen(body), &status, NULL, NULL, 0); + + snac_debug(user, 0, xs_fmt("webhook post %s %d", webhook, status)); + + if (!valid_status(status)) { + retries++; + + if (retries > queue_retry_max) + snac_debug(user, 0, xs_fmt("webhook post giving up %s", webhook)); + else { + snac_debug(user, 0, xs_fmt("webhook post requeue %s %d", webhook, retries)); + + enqueue_notify_webhook(user, msg, retries); + } + } + } + } else snac_log(user, xs_fmt("unexpected user q_item type '%s'", type)); } diff --git a/data.c b/data.c index ddfb443..10084f9 100644 --- a/data.c +++ b/data.c @@ -3529,7 +3529,16 @@ void enqueue_notify_webhook(snac *user, const xs_dict *noti, int retries) const char *webhook = xs_dict_get(user->config, "notify_webhook"); if (xs_is_string(webhook)) { - xs *qmsg = _new_qmsg("notify_webhook", noti, retries); + xs *msg = xs_dup(noti); + + /* add more data */ + msg = xs_dict_set(msg, "target", user->actor); + xs *actor_obj = NULL; + + if (valid_status(object_get(xs_dict_get(noti, "actor"), &actor_obj)) && actor_obj) + msg = xs_dict_set(msg, "account", actor_obj); + + xs *qmsg = _new_qmsg("notify_webhook", msg, retries); const char *ntid = xs_dict_get(qmsg, "ntid"); xs *fn = xs_fmt("%s/queue/%s.json", user->basedir, ntid); -- cgit From f055c8b694a398868d14fd70df61d02429846dae Mon Sep 17 00:00:00 2001 From: grunfink Date: Fri, 30 May 2025 19:34:11 +0200 Subject: Added a new server knob disable_notify_webhook. --- activitypub.c | 2 +- data.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'data.c') diff --git a/activitypub.c b/activitypub.c index fb0c42c..ab63abe 100644 --- a/activitypub.c +++ b/activitypub.c @@ -2769,7 +2769,7 @@ void process_user_queue_item(snac *user, xs_dict *q_item) if (strcmp(type, "notify_webhook") == 0) { const char *webhook = xs_dict_get(user->config, "notify_webhook"); - if (xs_is_string(webhook)) { + if (xs_is_string(webhook) && *webhook) { const xs_dict *msg = xs_dict_get(q_item, "message"); int retries = xs_number_get(xs_dict_get(q_item, "retries")); diff --git a/data.c b/data.c index 10084f9..74bc112 100644 --- a/data.c +++ b/data.c @@ -3167,7 +3167,8 @@ void notify_add(snac *snac, const char *type, const char *utype, pthread_mutex_unlock(&data_mutex); } - enqueue_notify_webhook(snac, noti, 0); + if (!xs_is_true(xs_dict_get(srv_config, "disable_notify_webhook"))) + enqueue_notify_webhook(snac, noti, 0); } @@ -3528,7 +3529,7 @@ void enqueue_notify_webhook(snac *user, const xs_dict *noti, int retries) { const char *webhook = xs_dict_get(user->config, "notify_webhook"); - if (xs_is_string(webhook)) { + if (xs_is_string(webhook) && *webhook) { xs *msg = xs_dup(noti); /* add more data */ -- cgit From 706816b4321337d56ff3121186567363b882d01d Mon Sep 17 00:00:00 2001 From: grunfink Date: Fri, 30 May 2025 19:43:55 +0200 Subject: Added uid, basedir and baseurl to the notify webhook message. --- data.c | 4 ++++ examples/auto_follower_webhook.py | 10 +++++----- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'data.c') diff --git a/data.c b/data.c index 74bc112..28f7cd9 100644 --- a/data.c +++ b/data.c @@ -3534,6 +3534,10 @@ void enqueue_notify_webhook(snac *user, const xs_dict *noti, int retries) /* add more data */ msg = xs_dict_set(msg, "target", user->actor); + msg = xs_dict_set(msg, "uid", user->uid); + msg = xs_dict_set(msg, "basedir", srv_basedir); + msg = xs_dict_set(msg, "baseurl", srv_baseurl); + xs *actor_obj = NULL; if (valid_status(object_get(xs_dict_get(noti, "actor"), &actor_obj)) && actor_obj) diff --git a/examples/auto_follower_webhook.py b/examples/auto_follower_webhook.py index e1192c1..eb632a3 100755 --- a/examples/auto_follower_webhook.py +++ b/examples/auto_follower_webhook.py @@ -2,8 +2,7 @@ # This is an example of a snac webhook that automatically follows all new followers. -# To use it, set the variables snac_basedir and snac_user to something reasonable, -# configure the user webhook to be http://localhost:12345, and run this program. +# To use it, configure the user webhook to be http://localhost:12345, and run this program. # copyright (C) 2025 grunfink et al. / MIT license @@ -14,8 +13,6 @@ import os host_name = "localhost" server_port = 12345 -snac_basedir = "/var/snac/example_instance" -snac_user = "example_user" class SnacAutoResponderServer(BaseHTTPRequestHandler): @@ -35,7 +32,10 @@ class SnacAutoResponderServer(BaseHTTPRequestHandler): if type == "Follow": actor = noti["actor"] - cmd = "snac follow %s %s %s" % (snac_basedir, snac_user, actor) + uid = noti["uid"] + basedir = noti["basedir"] + + cmd = "snac follow %s %s %s" % (basedir, uid, actor) os.system(cmd) -- cgit From c8848f6e9f8e9fd9d17290b1ef301d3bf7beccb4 Mon Sep 17 00:00:00 2001 From: grunfink Date: Fri, 30 May 2025 19:59:40 +0200 Subject: More webhook checks. --- activitypub.c | 2 +- data.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'data.c') diff --git a/activitypub.c b/activitypub.c index ab63abe..100db67 100644 --- a/activitypub.c +++ b/activitypub.c @@ -2769,7 +2769,7 @@ void process_user_queue_item(snac *user, xs_dict *q_item) if (strcmp(type, "notify_webhook") == 0) { const char *webhook = xs_dict_get(user->config, "notify_webhook"); - if (xs_is_string(webhook) && *webhook) { + if (xs_is_string(webhook) && xs_match(webhook, "https://*|http://*")) { /** **/ const xs_dict *msg = xs_dict_get(q_item, "message"); int retries = xs_number_get(xs_dict_get(q_item, "retries")); diff --git a/data.c b/data.c index 28f7cd9..6c38631 100644 --- a/data.c +++ b/data.c @@ -3529,7 +3529,7 @@ void enqueue_notify_webhook(snac *user, const xs_dict *noti, int retries) { const char *webhook = xs_dict_get(user->config, "notify_webhook"); - if (xs_is_string(webhook) && *webhook) { + if (xs_is_string(webhook) && xs_match(webhook, "https://*|http://*")) { /** **/ xs *msg = xs_dup(noti); /* add more data */ -- cgit From d87d294b7ddd93b16d0c89c324612aef5c6d648e Mon Sep 17 00:00:00 2001 From: grunfink Date: Mon, 16 Jun 2025 18:16:45 +0200 Subject: In enqueue_notify_webhook(), also add the inReplyTo object if there is one. --- data.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'data.c') diff --git a/data.c b/data.c index 6c38631..32b47d8 100644 --- a/data.c +++ b/data.c @@ -3543,6 +3543,16 @@ void enqueue_notify_webhook(snac *user, const xs_dict *noti, int retries) if (valid_status(object_get(xs_dict_get(noti, "actor"), &actor_obj)) && actor_obj) msg = xs_dict_set(msg, "account", actor_obj); + /* if this post is a reply, also add the inReplyTo object */ + const char *in_reply_to = xs_dict_get_path(msg, "msg.object.inReplyTo"); + + if (xs_is_string(in_reply_to)) { + xs *irt_obj = NULL; + + if (valid_status(object_get(in_reply_to, &irt_obj))) + msg = xs_dict_set(msg, "inReplyTo", irt_obj); + } + xs *qmsg = _new_qmsg("notify_webhook", msg, retries); const char *ntid = xs_dict_get(qmsg, "ntid"); xs *fn = xs_fmt("%s/queue/%s.json", user->basedir, ntid); -- cgit From f580014c5031f78489257cbf152d38098a6f38ff Mon Sep 17 00:00:00 2001 From: grunfink Date: Mon, 16 Jun 2025 18:24:47 +0200 Subject: Renamed webhook 'inReplyTo' to 'reply'. --- data.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'data.c') diff --git a/data.c b/data.c index 32b47d8..e1cab52 100644 --- a/data.c +++ b/data.c @@ -3550,7 +3550,7 @@ void enqueue_notify_webhook(snac *user, const xs_dict *noti, int retries) xs *irt_obj = NULL; if (valid_status(object_get(in_reply_to, &irt_obj))) - msg = xs_dict_set(msg, "inReplyTo", irt_obj); + msg = xs_dict_set(msg, "reply", irt_obj); } xs *qmsg = _new_qmsg("notify_webhook", msg, retries); -- cgit From 9b134e9076569b31eb5ec77ebda60eb9001485a8 Mon Sep 17 00:00:00 2001 From: grunfink Date: Wed, 18 Jun 2025 09:00:09 +0200 Subject: Added 'alias' and 'alias_raw' as forced update in user_persist(). --- data.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'data.c') diff --git a/data.c b/data.c index e1cab52..f26da49 100644 --- a/data.c +++ b/data.c @@ -333,6 +333,7 @@ int user_open_by_md5(snac *snac, const char *md5) return 0; } + int user_persist(snac *snac, int publish) /* store user */ { @@ -348,7 +349,7 @@ int user_persist(snac *snac, int publish) if (old != NULL) { int nw = 0; - const char *fields[] = { "header", "avatar", "name", "bio", + const char *fields[] = { "header", "avatar", "name", "bio", "alias", "alias_raw", "metadata", "latitude", "longitude", NULL }; for (int n = 0; fields[n]; n++) { -- cgit