commit 771e987

default  ·  2025-02-27 13:43:29 +0000 UTC
parent 07b343d
New function hashtag_in_msg().
1 files changed,  +11, -6
+11, -6
 1@@ -587,12 +587,10 @@ int is_msg_from_private_user(const xs_dict *msg)
 2 }
 3 
 4 
 5-int followed_hashtag_check(snac *user, const xs_dict *msg)
 6-/* returns true if this message contains a hashtag followed by me */
 7+int hashtag_in_msg(const xs_list *hashtags, const xs_dict *msg)
 8+/* returns 1 if the message contains any of the list of hashtags */
 9 {
10-    const xs_list *fw_tags = xs_dict_get(user->config, "followed_hashtags");
11-
12-    if (xs_is_list(fw_tags)) {
13+    if (xs_is_list(hashtags)) {
14         const xs_list *tags_in_msg = xs_dict_get(msg, "tag");
15 
16         if (xs_is_list(tags_in_msg)) {
17@@ -608,7 +606,7 @@ int followed_hashtag_check(snac *user, const xs_dict *msg)
18                         if (strcmp(type, "Hashtag") == 0) {
19                             xs *lc_name = xs_utf8_to_lower(name);
20 
21-                            if (xs_list_in(fw_tags, lc_name) != -1)
22+                            if (xs_list_in(hashtags, lc_name) != -1)
23                                 return 1;
24                         }
25                     }
26@@ -621,6 +619,13 @@ int followed_hashtag_check(snac *user, const xs_dict *msg)
27 }
28 
29 
30+int followed_hashtag_check(snac *user, const xs_dict *msg)
31+/* returns true if this message contains a hashtag followed by me */
32+{
33+    return hashtag_in_msg(xs_dict_get(user->config, "followed_hashtags"), msg);
34+}
35+
36+
37 void followed_hashtag_distribute(const xs_dict *msg)
38 /* distribute this post to all users following the included hashtags */
39 {