commit c166e05
grunfink
·
2025-05-09 13:31:58 +0000 UTC
parent 33647d2
As they look ugly in some platforms, links are no longer shown as attachments.
2 files changed,
+7,
-29
+7,
-5
1@@ -3034,13 +3034,15 @@ void process_queue_item(xs_dict *q_item)
2 if (strcmp(type, "webmention") == 0) {
3 const xs_dict *msg = xs_dict_get(q_item, "message");
4 const char *source = xs_dict_get(msg, "id");
5- const xs_list *atts = xs_dict_get(msg, "attachment");
6- const xs_dict *att;
7+ const char *content = xs_dict_get(msg, "content");
8
9- xs_list_foreach(atts, att) {
10- const char *target = xs_dict_get(att, "url");
11+ if (xs_is_string(source) && xs_is_string(content)) {
12+ xs *links = xs_regex_select(content, "\"https?[^\"]+");
13+ const char *link;
14+
15+ xs_list_foreach(links, link) {
16+ xs *target = xs_strip_chars_i(xs_dup(link), "\"");
17
18- if (xs_is_string(source) && xs_is_string(target)) {
19 int r = xs_webmention_send(source, target, USER_AGENT);
20
21 srv_debug(1, xs_fmt("webmention source=%s target=%s %d", source, target, r));
M
format.c
+0,
-24
1@@ -160,18 +160,6 @@ static xs_str *format_line(const char *line, xs_list **attach)
2 xs *link = xs_fmt("<a href=\"%s\">%s</a>", url, name);
3
4 s = xs_str_cat(s, link);
5-
6- if (attach) {
7- /* also add the link as an attachment */
8- xs *d = xs_dict_new();
9-
10- d = xs_dict_append(d, "mediaType", "text/html");
11- d = xs_dict_append(d, "url", url);
12- d = xs_dict_append(d, "name", name);
13- d = xs_dict_append(d, "type", "Link");
14-
15- *attach = xs_list_append(*attach, d);
16- }
17 }
18 else
19 s = xs_str_cat(s, v);
20@@ -255,18 +243,6 @@ static xs_str *format_line(const char *line, xs_list **attach)
21 else {
22 xs *s1 = xs_fmt("<a href=\"%s\" target=\"_blank\">%s</a>", v2, u);
23 s = xs_str_cat(s, s1);
24-
25- if (attach) {
26- /* also add the link as an attachment */
27- xs *d = xs_dict_new();
28-
29- d = xs_dict_append(d, "mediaType", "text/html");
30- d = xs_dict_append(d, "url", v2);
31- d = xs_dict_append(d, "name", "");
32- d = xs_dict_append(d, "type", "Link");
33-
34- *attach = xs_list_append(*attach, d);
35- }
36 }
37 }
38 else