From 4e3d596bee1cee2c4146265eb6ac827f09820c53 Mon Sep 17 00:00:00 2001 From: shtrophic Date: Mon, 20 Jan 2025 19:43:42 +0100 Subject: add xs_smtp_request --- activitypub.c | 48 +++++++++++++++++++----------------------------- 1 file changed, 19 insertions(+), 29 deletions(-) (limited to 'activitypub.c') diff --git a/activitypub.c b/activitypub.c index 8b44dc8..ca5cc3e 100644 --- a/activitypub.c +++ b/activitypub.c @@ -962,17 +962,20 @@ void notify(snac *snac, const char *type, const char *utype, const char *actor, xs *subject = xs_fmt("snac notify for @%s@%s", xs_dict_get(snac->config, "uid"), xs_dict_get(srv_config, "host")); - xs *from = xs_fmt("snac-daemon ", xs_dict_get(srv_config, "host")); + xs *from = xs_fmt("", xs_dict_get(srv_config, "host")); xs *header = xs_fmt( - "From: %s\n" + "From: snac-daemon %s\n" "To: %s\n" "Subject: %s\n" "\n", from, email, subject); - xs *email_body = xs_fmt("%s%s", header, body); + xs_dict *mailinfo = xs_dict_new(); + xs_dict_append(mailinfo, "from", from); + xs_dict_append(mailinfo, "to", email); + xs_dict_append(mailinfo, "body", xs_fmt("%s%s", header, body)); - enqueue_email(email_body, 0); + enqueue_email(mailinfo, 0); } /* telegram */ @@ -2461,32 +2464,19 @@ int process_input_message(snac *snac, const xs_dict *msg, const xs_dict *req) } -int send_email(const char *msg) +int send_email(const xs_dict *mailinfo) /* invoke sendmail with email headers and body in msg */ { - FILE *f; - int status; - int fds[2]; - pid_t pid; - if (pipe(fds) == -1) return -1; - pid = vfork(); - if (pid == -1) return -1; - else if (pid == 0) { - dup2(fds[0], 0); - close(fds[0]); - close(fds[1]); - execl("/usr/sbin/sendmail", "sendmail", "-t", (char *) NULL); - _exit(1); - } - close(fds[0]); - if ((f = fdopen(fds[1], "w")) == NULL) { - close(fds[1]); - return -1; - } - fprintf(f, "%s\n", msg); - fclose(f); - if (waitpid(pid, &status, 0) == -1) return -1; - return status; + const xs_dict *smtp_cfg = xs_dict_get(srv_config, "smtp"); + const char + *url = xs_dict_get(smtp_cfg, "url"), + *user = xs_dict_get(smtp_cfg, "username"), + *pass = xs_dict_get(smtp_cfg, "password"), + *from = xs_dict_get(mailinfo, "from"), + *to = xs_dict_get(mailinfo, "to"), + *body = xs_dict_get(mailinfo, "body"); + + return xs_smtp_request(url, user, pass, from, to, body); } @@ -2749,7 +2739,7 @@ void process_queue_item(xs_dict *q_item) else if (strcmp(type, "email") == 0) { /* send this email */ - const xs_str *msg = xs_dict_get(q_item, "message"); + const xs_dict *msg = xs_dict_get(q_item, "message"); int retries = xs_number_get(xs_dict_get(q_item, "retries")); if (!send_email(msg)) -- cgit v1.2.3 From 4c1a2d24d374d00c656c4489db7d28f80d64f9dc Mon Sep 17 00:00:00 2001 From: shtrophic Date: Mon, 20 Jan 2025 22:59:30 +0100 Subject: add port parsing for sandboxing --- activitypub.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'activitypub.c') diff --git a/activitypub.c b/activitypub.c index ca5cc3e..e5fc715 100644 --- a/activitypub.c +++ b/activitypub.c @@ -2465,9 +2465,9 @@ int process_input_message(snac *snac, const xs_dict *msg, const xs_dict *req) int send_email(const xs_dict *mailinfo) -/* invoke sendmail with email headers and body in msg */ +/* invoke curl */ { - const xs_dict *smtp_cfg = xs_dict_get(srv_config, "smtp"); + const xs_dict *smtp_cfg = xs_dict_get(srv_config, "email_notifications"); const char *url = xs_dict_get(smtp_cfg, "url"), *user = xs_dict_get(smtp_cfg, "username"), -- cgit v1.2.3 From 13e4a7cda59db29063efc5dad0823fe99ec7b764 Mon Sep 17 00:00:00 2001 From: shtrophic Date: Mon, 20 Jan 2025 23:03:27 +0100 Subject: fix memory leak --- activitypub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activitypub.c') diff --git a/activitypub.c b/activitypub.c index e5fc715..2b10435 100644 --- a/activitypub.c +++ b/activitypub.c @@ -970,7 +970,7 @@ void notify(snac *snac, const char *type, const char *utype, const char *actor, "\n", from, email, subject); - xs_dict *mailinfo = xs_dict_new(); + xs *mailinfo = xs_dict_new(); xs_dict_append(mailinfo, "from", from); xs_dict_append(mailinfo, "to", email); xs_dict_append(mailinfo, "body", xs_fmt("%s%s", header, body)); -- cgit v1.2.3 From 3d96c576287736ebdf87e4a7b956842a6c6e055f Mon Sep 17 00:00:00 2001 From: shtrophic Date: Fri, 24 Jan 2025 22:24:05 +0100 Subject: enforce tls when supported && add tests --- activitypub.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'activitypub.c') diff --git a/activitypub.c b/activitypub.c index 4cb779a..f3b2bae 100644 --- a/activitypub.c +++ b/activitypub.c @@ -2538,8 +2538,9 @@ int send_email(const xs_dict *mailinfo) *from = xs_dict_get(mailinfo, "from"), *to = xs_dict_get(mailinfo, "to"), *body = xs_dict_get(mailinfo, "body"); + int smtp_port = parse_port(url, NULL); - return xs_smtp_request(url, user, pass, from, to, body); + return xs_smtp_request(url, user, pass, from, to, body, smtp_port == 465 || smtp_port == 587); } -- cgit v1.2.3 From 2ca7735779e79dbe6fe62f0111a12c145f428d8f Mon Sep 17 00:00:00 2001 From: shtrophic Date: Wed, 19 Feb 2025 08:56:14 +0100 Subject: fix ownership-problem of mailinfo --- activitypub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activitypub.c') diff --git a/activitypub.c b/activitypub.c index e2519e6..a91821d 100644 --- a/activitypub.c +++ b/activitypub.c @@ -1025,7 +1025,7 @@ void notify(snac *snac, const char *type, const char *utype, const char *actor, "\n", from, email, subject); - xs *mailinfo = xs_dict_new(); + xs_dict *mailinfo = xs_dict_new(); xs_dict_append(mailinfo, "from", from); xs_dict_append(mailinfo, "to", email); xs_dict_append(mailinfo, "body", xs_fmt("%s%s", header, body)); -- cgit v1.2.3 From 59a34a9646e28cc9a63194ff55547de0005d0110 Mon Sep 17 00:00:00 2001 From: shtrophic Date: Thu, 20 Feb 2025 17:13:12 +0100 Subject: Revert "fix ownership-problem of mailinfo" This reverts commit 2ca7735779e79dbe6fe62f0111a12c145f428d8f. --- activitypub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activitypub.c') diff --git a/activitypub.c b/activitypub.c index a91821d..e2519e6 100644 --- a/activitypub.c +++ b/activitypub.c @@ -1025,7 +1025,7 @@ void notify(snac *snac, const char *type, const char *utype, const char *actor, "\n", from, email, subject); - xs_dict *mailinfo = xs_dict_new(); + xs *mailinfo = xs_dict_new(); xs_dict_append(mailinfo, "from", from); xs_dict_append(mailinfo, "to", email); xs_dict_append(mailinfo, "body", xs_fmt("%s%s", header, body)); -- cgit v1.2.3 From d19fe4157ced8789e43b7c061b11fcc7baf91c78 Mon Sep 17 00:00:00 2001 From: shtrophic Date: Thu, 20 Feb 2025 18:15:48 +0100 Subject: use xs_dict_append correctly --- activitypub.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'activitypub.c') diff --git a/activitypub.c b/activitypub.c index e2519e6..a209abd 100644 --- a/activitypub.c +++ b/activitypub.c @@ -1026,9 +1026,9 @@ void notify(snac *snac, const char *type, const char *utype, const char *actor, from, email, subject); xs *mailinfo = xs_dict_new(); - xs_dict_append(mailinfo, "from", from); - xs_dict_append(mailinfo, "to", email); - xs_dict_append(mailinfo, "body", xs_fmt("%s%s", header, body)); + mailinfo = xs_dict_append(mailinfo, "from", from); + mailinfo = xs_dict_append(mailinfo, "to", email); + mailinfo = xs_dict_append(mailinfo, "body", xs_fmt("%s%s", header, body)); enqueue_email(mailinfo, 0); } -- cgit v1.2.3 From 9b2d0381ba734102c20d2111f0a2b64a3c438ef7 Mon Sep 17 00:00:00 2001 From: default Date: Tue, 1 Apr 2025 06:32:53 +0200 Subject: More scheduled post code. --- activitypub.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'activitypub.c') diff --git a/activitypub.c b/activitypub.c index c00c371..4c22c25 100644 --- a/activitypub.c +++ b/activitypub.c @@ -2759,6 +2759,8 @@ int process_user_queue(snac *snac) cnt++; } + scheduled_process(snac); + return cnt; } -- cgit v1.2.3 From d19806a72db3585048c57f8940a74ec04f16e125 Mon Sep 17 00:00:00 2001 From: green Date: Mon, 24 Mar 2025 02:27:10 +0100 Subject: maybe a fix for username emojis --- activitypub.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'activitypub.c') diff --git a/activitypub.c b/activitypub.c index 4c22c25..ee7c9b1 100644 --- a/activitypub.c +++ b/activitypub.c @@ -1327,6 +1327,11 @@ xs_dict *msg_actor(snac *snac) msg = xs_dict_set(msg, "preferredUsername", snac->uid); msg = xs_dict_set(msg, "published", xs_dict_get(snac->config, "published")); + // this exists so we get the emoji tags from our name too. + // and then we just throw away the result, because it's kinda useless to have markdown in the dysplay name. + // right now, only emojies in bio actually work for local users + xs *name_dummy = not_really_markdown(xs_dict_get(snac->config, "name"), NULL, &tags); + xs *f_bio_2 = not_really_markdown(xs_dict_get(snac->config, "bio"), NULL, &tags); f_bio = process_tags(snac, f_bio_2, &tags); msg = xs_dict_set(msg, "summary", f_bio); -- cgit v1.2.3 From 0c03e6c9d9a6b65fede94cc9eab34a05746f8d5e Mon Sep 17 00:00:00 2001 From: green Date: Sun, 13 Apr 2025 15:44:24 +0200 Subject: cleaned up old changes and outdated comments --- activitypub.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'activitypub.c') diff --git a/activitypub.c b/activitypub.c index ee7c9b1..2403a62 100644 --- a/activitypub.c +++ b/activitypub.c @@ -34,7 +34,7 @@ const char *susie_cool = "+ZcgN7wF7ZVihXkfSlWIVzIA6dbQzaygllpNuTX" "ZmmFNlvxADX1+o0cUPMbAAAAAElFTkSuQmCC"; -const char *susie_muertos = +const char *susie_muertos = "iVBORw0KGgoAAAANSUhEUgAAAEAAAABAAQAAAAC" "CEkxzAAAAV0lEQVQoz4XQsQ0AMQxCUW/A/lv+DT" "ic6zGRolekIMyMELNp8PiCEw6Q4w4NoAt53IH5m" @@ -1328,8 +1328,7 @@ xs_dict *msg_actor(snac *snac) msg = xs_dict_set(msg, "published", xs_dict_get(snac->config, "published")); // this exists so we get the emoji tags from our name too. - // and then we just throw away the result, because it's kinda useless to have markdown in the dysplay name. - // right now, only emojies in bio actually work for local users + // and then we just throw away the result, because it's kinda useless to have markdown in the display name. xs *name_dummy = not_really_markdown(xs_dict_get(snac->config, "name"), NULL, &tags); xs *f_bio_2 = not_really_markdown(xs_dict_get(snac->config, "bio"), NULL, &tags); -- cgit v1.2.3 From 7f936d2d1a88840209895c6091801e8c4cfdaaa1 Mon Sep 17 00:00:00 2001 From: shtrophic Date: Thu, 24 Apr 2025 12:18:23 +0200 Subject: default to `smtp://localhost` --- activitypub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activitypub.c') diff --git a/activitypub.c b/activitypub.c index 061d1f8..df68151 100644 --- a/activitypub.c +++ b/activitypub.c @@ -2571,7 +2571,7 @@ int send_email(const xs_dict *mailinfo) { const xs_dict *smtp_cfg = xs_dict_get(srv_config, "email_notifications"); const char - *url = xs_dict_get(smtp_cfg, "url"), + *url = xs_dict_get_def(smtp_cfg, "url", "smtp://localhost"), *user = xs_dict_get(smtp_cfg, "username"), *pass = xs_dict_get(smtp_cfg, "password"), *from = xs_dict_get(mailinfo, "from"), -- cgit v1.2.3 From 3dec7404bf59397452f3cc32fdf33b379f2546fc Mon Sep 17 00:00:00 2001 From: grunfink Date: Sun, 27 Apr 2025 05:15:32 +0200 Subject: Fixed memory leak. --- activitypub.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'activitypub.c') diff --git a/activitypub.c b/activitypub.c index df68151..10e5776 100644 --- a/activitypub.c +++ b/activitypub.c @@ -1053,9 +1053,10 @@ void notify(snac *snac, const char *type, const char *utype, const char *actor, from, email, subject); xs *mailinfo = xs_dict_new(); + xs *body = xs_fmt("%s%s", header, body); mailinfo = xs_dict_append(mailinfo, "from", from); mailinfo = xs_dict_append(mailinfo, "to", email); - mailinfo = xs_dict_append(mailinfo, "body", xs_fmt("%s%s", header, body)); + mailinfo = xs_dict_append(mailinfo, "body", body); enqueue_email(mailinfo, 0); } -- cgit v1.2.3 From aa15f84b34e51ae8121a8174ea68f105d295699c Mon Sep 17 00:00:00 2001 From: grunfink Date: Sun, 27 Apr 2025 05:23:39 +0200 Subject: Changed server SMTP settings. --- activitypub.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'activitypub.c') diff --git a/activitypub.c b/activitypub.c index 10e5776..fd2d81a 100644 --- a/activitypub.c +++ b/activitypub.c @@ -34,7 +34,7 @@ const char *susie_cool = "+ZcgN7wF7ZVihXkfSlWIVzIA6dbQzaygllpNuTX" "ZmmFNlvxADX1+o0cUPMbAAAAAElFTkSuQmCC"; -const char *susie_muertos = +const char *susie_muertos = "iVBORw0KGgoAAAANSUhEUgAAAEAAAABAAQAAAAC" "CEkxzAAAAV0lEQVQoz4XQsQ0AMQxCUW/A/lv+DT" "ic6zGRolekIMyMELNp8PiCEw6Q4w4NoAt53IH5m" @@ -2570,14 +2570,17 @@ int process_input_message(snac *snac, const xs_dict *msg, const xs_dict *req) int send_email(const xs_dict *mailinfo) /* invoke curl */ { - const xs_dict *smtp_cfg = xs_dict_get(srv_config, "email_notifications"); - const char - *url = xs_dict_get_def(smtp_cfg, "url", "smtp://localhost"), - *user = xs_dict_get(smtp_cfg, "username"), - *pass = xs_dict_get(smtp_cfg, "password"), + const char + *url = xs_dict_get(srv_config, "smtp_url"), + *user = xs_dict_get(srv_config, "smtp_username"), + *pass = xs_dict_get(srv_config, "smtp_password"), *from = xs_dict_get(mailinfo, "from"), *to = xs_dict_get(mailinfo, "to"), *body = xs_dict_get(mailinfo, "body"); + + if (url == NULL || *url == '\0') + url = "smtp://localhost"; + int smtp_port = parse_port(url, NULL); return xs_smtp_request(url, user, pass, from, to, body, smtp_port == 465 || smtp_port == 587); -- cgit v1.2.3 From c27e1aa5a126d6676232e7e3cb7cff95a3661b35 Mon Sep 17 00:00:00 2001 From: grunfink Date: Sun, 27 Apr 2025 05:26:42 +0200 Subject: Fixed typo. --- activitypub.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'activitypub.c') diff --git a/activitypub.c b/activitypub.c index fd2d81a..fbf7a1f 100644 --- a/activitypub.c +++ b/activitypub.c @@ -1053,10 +1053,10 @@ void notify(snac *snac, const char *type, const char *utype, const char *actor, from, email, subject); xs *mailinfo = xs_dict_new(); - xs *body = xs_fmt("%s%s", header, body); + xs *bd = xs_fmt("%s%s", header, body); mailinfo = xs_dict_append(mailinfo, "from", from); mailinfo = xs_dict_append(mailinfo, "to", email); - mailinfo = xs_dict_append(mailinfo, "body", body); + mailinfo = xs_dict_append(mailinfo, "body", bd); enqueue_email(mailinfo, 0); } -- cgit v1.2.3 From da0ce17f15e3bb0d3b9eb1442f036d8f549ceee8 Mon Sep 17 00:00:00 2001 From: grunfink Date: Mon, 28 Apr 2025 05:15:31 +0200 Subject: Email notifications are sent the old way if 'spawn_sendmail' is set to true. --- activitypub.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'activitypub.c') diff --git a/activitypub.c b/activitypub.c index fbf7a1f..92e408b 100644 --- a/activitypub.c +++ b/activitypub.c @@ -2570,6 +2570,34 @@ int process_input_message(snac *snac, const xs_dict *msg, const xs_dict *req) int send_email(const xs_dict *mailinfo) /* invoke curl */ { + if (xs_is_true(xs_dict_get(srv_config, "spawn_sendmail"))) { + const char *msg = xs_dict_get(mailinfo, "body"); + FILE *f; + int status; + int fds[2]; + pid_t pid; + + if (pipe(fds) == -1) return -1; + pid = vfork(); + if (pid == -1) return -1; + else if (pid == 0) { + dup2(fds[0], 0); + close(fds[0]); + close(fds[1]); + execl("/usr/sbin/sendmail", "sendmail", "-t", (char *) NULL); + _exit(1); + } + close(fds[0]); + if ((f = fdopen(fds[1], "w")) == NULL) { + close(fds[1]); + return -1; + } + fprintf(f, "%s\n", msg); + fclose(f); + if (waitpid(pid, &status, 0) == -1) return -1; + return status; + } + const char *url = xs_dict_get(srv_config, "smtp_url"), *user = xs_dict_get(srv_config, "smtp_username"), -- cgit v1.2.3 From 8e467684c2d6960d64af9ea3de74ddb30d82302f Mon Sep 17 00:00:00 2001 From: grunfink Date: Mon, 28 Apr 2025 06:12:29 +0200 Subject: Changed email notifications: use SMTP only if configured. --- activitypub.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'activitypub.c') diff --git a/activitypub.c b/activitypub.c index 92e408b..98ed6da 100644 --- a/activitypub.c +++ b/activitypub.c @@ -2570,7 +2570,10 @@ int process_input_message(snac *snac, const xs_dict *msg, const xs_dict *req) int send_email(const xs_dict *mailinfo) /* invoke curl */ { - if (xs_is_true(xs_dict_get(srv_config, "spawn_sendmail"))) { + const char *url = xs_dict_get(srv_config, "smtp_url"); + + if (!xs_is_string(url) || *url == '\0') { + /* revert back to old sendmail pipe behaviour */ const char *msg = xs_dict_get(mailinfo, "body"); FILE *f; int status; @@ -2599,7 +2602,6 @@ int send_email(const xs_dict *mailinfo) } const char - *url = xs_dict_get(srv_config, "smtp_url"), *user = xs_dict_get(srv_config, "smtp_username"), *pass = xs_dict_get(srv_config, "smtp_password"), *from = xs_dict_get(mailinfo, "from"), -- cgit v1.2.3 From bca51ef5ba10fc38d804d5d83f26575e02190663 Mon Sep 17 00:00:00 2001 From: grunfink Date: Sat, 3 May 2025 19:39:04 +0200 Subject: Preprocess the webmention q_item. Nothing is really done yet. --- activitypub.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'activitypub.c') diff --git a/activitypub.c b/activitypub.c index 98ed6da..5ba1f25 100644 --- a/activitypub.c +++ b/activitypub.c @@ -3025,6 +3025,19 @@ void process_queue_item(xs_dict *q_item) } } } + else + if (strcmp(type, "webmention") == 0) { + const xs_dict *msg = xs_dict_get(q_item, "message"); + const char *source = xs_dict_get(msg, "id"); + const xs_list *atts = xs_dict_get(msg, "attachment"); + const xs_dict *att; + + xs_list_foreach(atts, att) { + const char *target = xs_dict_get(att, "url"); + + srv_debug(1, xs_fmt("webmention source=%s target=%s", source, target)); + } + } else srv_log(xs_fmt("unexpected q_item type '%s'", type)); } -- cgit v1.2.3 From 7d1b257e4616ff750638b387ae60a128ff0ed43f Mon Sep 17 00:00:00 2001 From: grunfink Date: Sun, 4 May 2025 11:09:07 +0200 Subject: Webmentions are now sent. --- activitypub.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'activitypub.c') diff --git a/activitypub.c b/activitypub.c index 5ba1f25..53a1e74 100644 --- a/activitypub.c +++ b/activitypub.c @@ -11,6 +11,7 @@ #include "xs_set.h" #include "xs_match.h" #include "xs_unicode.h" +#include "xs_webmention.h" #include "snac.h" @@ -3035,7 +3036,11 @@ void process_queue_item(xs_dict *q_item) xs_list_foreach(atts, att) { const char *target = xs_dict_get(att, "url"); - srv_debug(1, xs_fmt("webmention source=%s target=%s", source, target)); + if (xs_is_string(source) && xs_is_string(target)) { + int r = xs_webmention_send(source, target, USER_AGENT); + + srv_debug(1, xs_fmt("webmention source=%s target=%s %d", source, target, r)); + } } } else -- cgit v1.2.3 From c166e05f7d3ba1efe9b16290bf3da2b06fdae8ea Mon Sep 17 00:00:00 2001 From: grunfink Date: Fri, 9 May 2025 15:31:58 +0200 Subject: As they look ugly in some platforms, links are no longer shown as attachments. --- activitypub.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'activitypub.c') diff --git a/activitypub.c b/activitypub.c index dcbb79f..48a999a 100644 --- a/activitypub.c +++ b/activitypub.c @@ -3034,13 +3034,15 @@ void process_queue_item(xs_dict *q_item) if (strcmp(type, "webmention") == 0) { const xs_dict *msg = xs_dict_get(q_item, "message"); const char *source = xs_dict_get(msg, "id"); - const xs_list *atts = xs_dict_get(msg, "attachment"); - const xs_dict *att; + const char *content = xs_dict_get(msg, "content"); - xs_list_foreach(atts, att) { - const char *target = xs_dict_get(att, "url"); + if (xs_is_string(source) && xs_is_string(content)) { + xs *links = xs_regex_select(content, "\"https?[^\"]+"); + const char *link; + + xs_list_foreach(links, link) { + xs *target = xs_strip_chars_i(xs_dup(link), "\""); - if (xs_is_string(source) && xs_is_string(target)) { int r = xs_webmention_send(source, target, USER_AGENT); srv_debug(1, xs_fmt("webmention source=%s target=%s %d", source, target, r)); -- cgit v1.2.3 From 418581a71dc1a540a4a18b439aa215b143706c80 Mon Sep 17 00:00:00 2001 From: grunfink Date: Sun, 11 May 2025 18:59:28 +0200 Subject: Minor tweak to link extraction regex. --- activitypub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activitypub.c') diff --git a/activitypub.c b/activitypub.c index 48a999a..a7e133a 100644 --- a/activitypub.c +++ b/activitypub.c @@ -3037,7 +3037,7 @@ void process_queue_item(xs_dict *q_item) const char *content = xs_dict_get(msg, "content"); if (xs_is_string(source) && xs_is_string(content)) { - xs *links = xs_regex_select(content, "\"https?[^\"]+"); + xs *links = xs_regex_select(content, "\"https?:/" "/[^\"]+"); const char *link; xs_list_foreach(links, link) { -- cgit v1.2.3 From 321f64ed70d039dea510c8a7d7aee7dc9577737a Mon Sep 17 00:00:00 2001 From: green Date: Mon, 19 May 2025 15:25:11 +0200 Subject: performance: use following_list_len in more places --- activitypub.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'activitypub.c') diff --git a/activitypub.c b/activitypub.c index a7e133a..120b4a1 100644 --- a/activitypub.c +++ b/activitypub.c @@ -3204,8 +3204,7 @@ int activitypub_get_handler(const xs_dict *req, const char *q_path, int total = 0; if (show_contact_metrics) { - xs *l = follower_list(&snac); - total = xs_list_len(l); + total = follower_list_len(&snac); } xs *id = xs_fmt("%s/%s", snac.actor, p_path); @@ -3216,8 +3215,7 @@ int activitypub_get_handler(const xs_dict *req, const char *q_path, int total = 0; if (show_contact_metrics) { - xs *l = following_list(&snac); - total = xs_list_len(l); + total = following_list_len(&snac); } xs *id = xs_fmt("%s/%s", snac.actor, p_path); -- cgit v1.2.3