Browse Source

New function hashtag_in_msg().

default 1 month ago
parent
commit
771e987958
1 changed files with 11 additions and 6 deletions
  1. 11 6
      activitypub.c

+ 11 - 6
activitypub.c

@@ -587,12 +587,10 @@ int is_msg_from_private_user(const xs_dict *msg)
 }
 
 
-int followed_hashtag_check(snac *user, const xs_dict *msg)
-/* returns true if this message contains a hashtag followed by me */
+int hashtag_in_msg(const xs_list *hashtags, const xs_dict *msg)
+/* returns 1 if the message contains any of the list of hashtags */
 {
-    const xs_list *fw_tags = xs_dict_get(user->config, "followed_hashtags");
-
-    if (xs_is_list(fw_tags)) {
+    if (xs_is_list(hashtags)) {
         const xs_list *tags_in_msg = xs_dict_get(msg, "tag");
 
         if (xs_is_list(tags_in_msg)) {
@@ -608,7 +606,7 @@ int followed_hashtag_check(snac *user, const xs_dict *msg)
                         if (strcmp(type, "Hashtag") == 0) {
                             xs *lc_name = xs_utf8_to_lower(name);
 
-                            if (xs_list_in(fw_tags, lc_name) != -1)
+                            if (xs_list_in(hashtags, lc_name) != -1)
                                 return 1;
                         }
                     }
@@ -621,6 +619,13 @@ int followed_hashtag_check(snac *user, const xs_dict *msg)
 }
 
 
+int followed_hashtag_check(snac *user, const xs_dict *msg)
+/* returns true if this message contains a hashtag followed by me */
+{
+    return hashtag_in_msg(xs_dict_get(user->config, "followed_hashtags"), msg);
+}
+
+
 void followed_hashtag_distribute(const xs_dict *msg)
 /* distribute this post to all users following the included hashtags */
 {