Forráskód Böngészése

As they look ugly in some platforms, links are no longer shown as attachments.

grunfink 1 éve
szülő
commit
c166e05f7d
2 módosított fájl, 7 hozzáadás és 29 törlés
  1. 7 5
      activitypub.c
  2. 0 24
      format.c

+ 7 - 5
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));

+ 0 - 24
format.c

@@ -160,18 +160,6 @@ static xs_str *format_line(const char *line, xs_list **attach)
                     xs *link = xs_fmt("<a href=\"%s\">%s</a>", url, name);
 
                     s = xs_str_cat(s, link);
-
-                    if (attach) {
-                        /* also add the link as an attachment */
-                        xs *d = xs_dict_new();
-
-                        d = xs_dict_append(d, "mediaType", "text/html");
-                        d = xs_dict_append(d, "url",       url);
-                        d = xs_dict_append(d, "name",      name);
-                        d = xs_dict_append(d, "type",      "Link");
-
-                        *attach = xs_list_append(*attach, d);
-                    }
                 }
                 else
                     s = xs_str_cat(s, v);
@@ -255,18 +243,6 @@ static xs_str *format_line(const char *line, xs_list **attach)
                 else {
                     xs *s1 = xs_fmt("<a href=\"%s\" target=\"_blank\">%s</a>", v2, u);
                     s = xs_str_cat(s, s1);
-
-                    if (attach) {
-                        /* also add the link as an attachment */
-                        xs *d = xs_dict_new();
-
-                        d = xs_dict_append(d, "mediaType", "text/html");
-                        d = xs_dict_append(d, "url",       v2);
-                        d = xs_dict_append(d, "name",      "");
-                        d = xs_dict_append(d, "type",      "Link");
-
-                        *attach = xs_list_append(*attach, d);
-                    }
                 }
             }
             else