diff options
| author | 2025-05-09 15:31:58 +0200 | |
|---|---|---|
| committer | 2025-05-09 15:31:58 +0200 | |
| commit | c166e05f7d3ba1efe9b16290bf3da2b06fdae8ea (patch) | |
| tree | aba94462b73a15e41d7a7f651f41e379f194e1a7 | |
| parent | Version 2.76 RELEASED. (diff) | |
| download | snac2-c166e05f7d3ba1efe9b16290bf3da2b06fdae8ea.tar.gz snac2-c166e05f7d3ba1efe9b16290bf3da2b06fdae8ea.tar.xz snac2-c166e05f7d3ba1efe9b16290bf3da2b06fdae8ea.zip | |
As they look ugly in some platforms, links are no longer shown as attachments.
| -rw-r--r-- | activitypub.c | 12 | ||||
| -rw-r--r-- | format.c | 24 |
2 files changed, 7 insertions, 29 deletions
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) | |||
| 3034 | if (strcmp(type, "webmention") == 0) { | 3034 | if (strcmp(type, "webmention") == 0) { |
| 3035 | const xs_dict *msg = xs_dict_get(q_item, "message"); | 3035 | const xs_dict *msg = xs_dict_get(q_item, "message"); |
| 3036 | const char *source = xs_dict_get(msg, "id"); | 3036 | const char *source = xs_dict_get(msg, "id"); |
| 3037 | const xs_list *atts = xs_dict_get(msg, "attachment"); | 3037 | const char *content = xs_dict_get(msg, "content"); |
| 3038 | const xs_dict *att; | ||
| 3039 | 3038 | ||
| 3040 | xs_list_foreach(atts, att) { | 3039 | if (xs_is_string(source) && xs_is_string(content)) { |
| 3041 | const char *target = xs_dict_get(att, "url"); | 3040 | xs *links = xs_regex_select(content, "\"https?[^\"]+"); |
| 3041 | const char *link; | ||
| 3042 | |||
| 3043 | xs_list_foreach(links, link) { | ||
| 3044 | xs *target = xs_strip_chars_i(xs_dup(link), "\""); | ||
| 3042 | 3045 | ||
| 3043 | if (xs_is_string(source) && xs_is_string(target)) { | ||
| 3044 | int r = xs_webmention_send(source, target, USER_AGENT); | 3046 | int r = xs_webmention_send(source, target, USER_AGENT); |
| 3045 | 3047 | ||
| 3046 | srv_debug(1, xs_fmt("webmention source=%s target=%s %d", source, target, r)); | 3048 | srv_debug(1, xs_fmt("webmention source=%s target=%s %d", source, target, r)); |
| @@ -160,18 +160,6 @@ static xs_str *format_line(const char *line, xs_list **attach) | |||
| 160 | xs *link = xs_fmt("<a href=\"%s\">%s</a>", url, name); | 160 | xs *link = xs_fmt("<a href=\"%s\">%s</a>", url, name); |
| 161 | 161 | ||
| 162 | s = xs_str_cat(s, link); | 162 | s = xs_str_cat(s, link); |
| 163 | |||
| 164 | if (attach) { | ||
| 165 | /* also add the link as an attachment */ | ||
| 166 | xs *d = xs_dict_new(); | ||
| 167 | |||
| 168 | d = xs_dict_append(d, "mediaType", "text/html"); | ||
| 169 | d = xs_dict_append(d, "url", url); | ||
| 170 | d = xs_dict_append(d, "name", name); | ||
| 171 | d = xs_dict_append(d, "type", "Link"); | ||
| 172 | |||
| 173 | *attach = xs_list_append(*attach, d); | ||
| 174 | } | ||
| 175 | } | 163 | } |
| 176 | else | 164 | else |
| 177 | s = xs_str_cat(s, v); | 165 | s = xs_str_cat(s, v); |
| @@ -255,18 +243,6 @@ static xs_str *format_line(const char *line, xs_list **attach) | |||
| 255 | else { | 243 | else { |
| 256 | xs *s1 = xs_fmt("<a href=\"%s\" target=\"_blank\">%s</a>", v2, u); | 244 | xs *s1 = xs_fmt("<a href=\"%s\" target=\"_blank\">%s</a>", v2, u); |
| 257 | s = xs_str_cat(s, s1); | 245 | s = xs_str_cat(s, s1); |
| 258 | |||
| 259 | if (attach) { | ||
| 260 | /* also add the link as an attachment */ | ||
| 261 | xs *d = xs_dict_new(); | ||
| 262 | |||
| 263 | d = xs_dict_append(d, "mediaType", "text/html"); | ||
| 264 | d = xs_dict_append(d, "url", v2); | ||
| 265 | d = xs_dict_append(d, "name", ""); | ||
| 266 | d = xs_dict_append(d, "type", "Link"); | ||
| 267 | |||
| 268 | *attach = xs_list_append(*attach, d); | ||
| 269 | } | ||
| 270 | } | 246 | } |
| 271 | } | 247 | } |
| 272 | else | 248 | else |