commit 6a77c63

default  ·  2024-04-30 17:41:08 +0000 UTC
parent 4e23570
Also add announces to lists.
3 files changed,  +13, -7
M data.c
M snac.h
+3, -0
 1@@ -2099,6 +2099,9 @@ int process_input_message(snac *snac, xs_dict *msg, xs_dict *req)
 2                             snac_log(snac, xs_fmt("repeated 'Announce' from %s to %s",
 3                                 actor, object));
 4 
 5+                        /* distribute the post with the actor as 'proxy' */
 6+                        list_distribute(snac, actor, a_msg);
 7+
 8                         do_notify = 1;
 9                     }
10                     else
M data.c
+9, -6
 1@@ -1165,7 +1165,7 @@ int timeline_add(snac *snac, const char *id, const xs_dict *o_msg)
 2 
 3     tag_index(id, o_msg);
 4 
 5-    list_distribute(snac, o_msg);
 6+    list_distribute(snac, NULL, o_msg);
 7 
 8     snac_debug(snac, 1, xs_fmt("timeline_add %s", id));
 9 
10@@ -1881,14 +1881,17 @@ xs_val *list_content(snac *user, const char *list, const char *actor_md5, int op
11 }
12 
13 
14-void list_distribute(snac *user, const xs_dict *post)
15+void list_distribute(snac *user, const char *who, const xs_dict *post)
16 /* distributes the post to all appropriate lists */
17 {
18-    char *atto = get_atto(post);
19-    char *id   = xs_dict_get(post, "id");
20+    char *id = xs_dict_get(post, "id");
21 
22-    if (xs_type(atto) == XSTYPE_STRING && xs_type(id) == XSTYPE_STRING) {
23-        xs *a_md5 = xs_md5_hex(atto, strlen(atto));
24+    /* if who is not set, use the attributedTo in the message */
25+    if (xs_is_null(who))
26+        who = get_atto(post);
27+
28+    if (xs_type(who) == XSTYPE_STRING && xs_type(id) == XSTYPE_STRING) {
29+        xs *a_md5 = xs_md5_hex(who, strlen(who));
30         xs *i_md5 = xs_md5_hex(id, strlen(id));
31         xs *spec  = xs_fmt("%s/list/" "*.lst", user->basedir);
32         xs *ls    = xs_glob(spec, 0, 0);
M snac.h
+1, -1
1@@ -176,7 +176,7 @@ xs_list *tag_search(char *tag, int skip, int show);
2 
3 xs_val *list_maint(snac *user, const char *list, int op);
4 xs_val *list_content(snac *user, const char *list_id, const char *actor_md5, int op);
5-void list_distribute(snac *user, const xs_dict *post);
6+void list_distribute(snac *user, const char *who, const xs_dict *post);
7 
8 int actor_add(const char *actor, xs_dict *msg);
9 int actor_get(const char *actor, xs_dict **data);