aboutsummaryrefslogtreecommitdiff
path: root/activitypub.c
diff options
context:
space:
mode:
authordefault <nobody@localhost>2025-02-27 14:43:29 +0100
committerdefault <nobody@localhost>2025-02-27 14:43:29 +0100
commit771e987958fca3ad8cf310771256596dc38f4904 (patch)
tree0acff4c664b852cb419cc4f4359943ea2520c7cd /activitypub.c
parent07b343de70939327afefd2060a341a6ee555973b (diff)
New function hashtag_in_msg().
Diffstat (limited to 'activitypub.c')
-rw-r--r--activitypub.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/activitypub.c b/activitypub.c
index 104110d..2813beb 100644
--- a/activitypub.c
+++ b/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 */
{