Browse Source

Also add announces to lists.

default 11 months ago
parent
commit
6a77c634ad
3 changed files with 13 additions and 7 deletions
  1. 3 0
      activitypub.c
  2. 9 6
      data.c
  3. 1 1
      snac.h

+ 3 - 0
activitypub.c

@@ -2099,6 +2099,9 @@ int process_input_message(snac *snac, xs_dict *msg, xs_dict *req)
                             snac_log(snac, xs_fmt("repeated 'Announce' from %s to %s",
                                 actor, object));
 
+                        /* distribute the post with the actor as 'proxy' */
+                        list_distribute(snac, actor, a_msg);
+
                         do_notify = 1;
                     }
                     else

+ 9 - 6
data.c

@@ -1165,7 +1165,7 @@ int timeline_add(snac *snac, const char *id, const xs_dict *o_msg)
 
     tag_index(id, o_msg);
 
-    list_distribute(snac, o_msg);
+    list_distribute(snac, NULL, o_msg);
 
     snac_debug(snac, 1, xs_fmt("timeline_add %s", id));
 
@@ -1881,14 +1881,17 @@ xs_val *list_content(snac *user, const char *list, const char *actor_md5, int op
 }
 
 
-void list_distribute(snac *user, const xs_dict *post)
+void list_distribute(snac *user, const char *who, const xs_dict *post)
 /* distributes the post to all appropriate lists */
 {
-    char *atto = get_atto(post);
-    char *id   = xs_dict_get(post, "id");
+    char *id = xs_dict_get(post, "id");
 
-    if (xs_type(atto) == XSTYPE_STRING && xs_type(id) == XSTYPE_STRING) {
-        xs *a_md5 = xs_md5_hex(atto, strlen(atto));
+    /* if who is not set, use the attributedTo in the message */
+    if (xs_is_null(who))
+        who = get_atto(post);
+
+    if (xs_type(who) == XSTYPE_STRING && xs_type(id) == XSTYPE_STRING) {
+        xs *a_md5 = xs_md5_hex(who, strlen(who));
         xs *i_md5 = xs_md5_hex(id, strlen(id));
         xs *spec  = xs_fmt("%s/list/" "*.lst", user->basedir);
         xs *ls    = xs_glob(spec, 0, 0);

+ 1 - 1
snac.h

@@ -176,7 +176,7 @@ xs_list *tag_search(char *tag, int skip, int show);
 
 xs_val *list_maint(snac *user, const char *list, int op);
 xs_val *list_content(snac *user, const char *list_id, const char *actor_md5, int op);
-void list_distribute(snac *user, const xs_dict *post);
+void list_distribute(snac *user, const char *who, const xs_dict *post);
 
 int actor_add(const char *actor, xs_dict *msg);
 int actor_get(const char *actor, xs_dict **data);