commit fda3057

default  ·  2025-01-23 13:39:59 +0000 UTC
parent 0f0e33f
More hashtag following tweaks.
1 files changed,  +33, -0
+33, -0
 1@@ -621,6 +621,36 @@ int followed_hashtag_check(snac *user, const xs_dict *msg)
 2 }
 3 
 4 
 5+void followed_hashtag_distribute(const xs_dict *msg)
 6+/* distribute this post to all users following the included hashtags */
 7+{
 8+    const char *id = xs_dict_get(msg, "id");
 9+    const xs_list *tags_in_msg = xs_dict_get(msg, "tag");
10+
11+    if (!xs_is_string(id) || !xs_is_list(tags_in_msg) || xs_list_len(tags_in_msg) == 0)
12+        return;
13+
14+    srv_debug(1, xs_fmt("followed_hashtag_distribute check for %s", id));
15+
16+    xs *users = user_list();
17+    const char *uid;
18+
19+    xs_list_foreach(users, uid) {
20+        snac user;
21+
22+        if (user_open(&user, uid)) {
23+            if (followed_hashtag_check(&user, msg)) {
24+                timeline_add(&user, id, msg);
25+
26+                snac_log(&user, xs_fmt("followed hashtag in %s", id));
27+            }
28+
29+            user_free(&user);
30+        }
31+    }
32+}
33+
34+
35 int is_msg_for_me(snac *snac, const xs_dict *c_msg)
36 /* checks if this message is for me */
37 {
38@@ -2313,6 +2343,9 @@ int process_input_message(snac *snac, const xs_dict *msg, const xs_dict *req)
39                         /* distribute the post with the actor as 'proxy' */
40                         list_distribute(snac, actor, a_msg);
41 
42+                        /* distribute the post to users following these hashtags */
43+                        followed_hashtag_distribute(a_msg);
44+
45                         do_notify = 1;
46                     }
47                     else