瀏覽代碼

In msg_note(), also add the in_reply_to author as a tag.Mention.

default 3 年之前
父節點
當前提交
9145cca97a
共有 1 個文件被更改,包括 21 次插入6 次删除
  1. 21 6
      activitypub.c

+ 21 - 6
activitypub.c

@@ -584,6 +584,9 @@ d_char *msg_note(snac *snac, char *content, char *rcpts, char *in_reply_to, char
     /* extract the tags */
     process_tags(fc2, &fc1, &tag);
 
+    if (tag == NULL)
+        tag = xs_list_new();
+
     if (in_reply_to != NULL) {
         xs *p_msg = NULL;
 
@@ -592,11 +595,26 @@ d_char *msg_note(snac *snac, char *content, char *rcpts, char *in_reply_to, char
 
         if ((p_msg = timeline_find(snac, in_reply_to)) != NULL) {
             /* add this author as recipient */
-            char *v;
+            char *a, *v;
+
+            if ((a = xs_dict_get(p_msg, "attributedTo")) && xs_list_in(to, a) == -1)
+                to = xs_list_append(to, a);
+
+            /* add this author to the tag list as a mention */
+            xs *t_href;
+            xs *t_name;
+
+            if (!xs_is_null(a) && valid_status(webfinger_request(a, &t_href, &t_name))) {
+                xs *t = xs_dict_new();
 
-            if ((v = xs_dict_get(p_msg, "attributedTo")) && xs_list_in(to, v) == -1)
-                to = xs_list_append(to, v);
+                t = xs_dict_append(t, "type", "Mention");
+                t = xs_dict_append(t, "href", t_href);
+                t = xs_dict_append(t, "name", t_name);
 
+                tag = xs_list_append(tag, t);
+            }
+
+            /* get the context, if there is one */
             if ((v = xs_dict_get(p_msg, "context")))
                 ctxt = xs_dup(v);
 
@@ -635,9 +653,6 @@ d_char *msg_note(snac *snac, char *content, char *rcpts, char *in_reply_to, char
         }
     }
 
-    if (tag == NULL)
-        tag = xs_list_new();
-
     if (ctxt == NULL)
         ctxt = xs_fmt("%s#ctxt", id);