aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordefault <nobody@localhost>2024-12-30 10:34:53 +0100
committerdefault <nobody@localhost>2024-12-30 10:34:53 +0100
commit25e1f7f4d11ac208291e9eacf93a7dc6b883e23d (patch)
tree09d62097d9d4ba59d8346217e11943ac6692cb05
parentfafeb6c3f0aab31cececf929972ab592a33f7c3c (diff)
Started support for hashtag following.
-rw-r--r--activitypub.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/activitypub.c b/activitypub.c
index 88d8fd8..311255f 100644
--- a/activitypub.c
+++ b/activitypub.c
@@ -706,6 +706,28 @@ int is_msg_for_me(snac *snac, const xs_dict *c_msg)
}
}
+ /* is this a tag we're following? */
+ const xs_list *tags_in_msg = xs_dict_get(msg, "tag");
+ if (xs_type(tags_in_msg) == XSTYPE_LIST) {
+ const xs_list *fw_tags = xs_dict_get(snac->config, "followed_hashtags");
+ if (xs_type(fw_tags) == XSTYPE_LIST) {
+ const xs_dict *te;
+
+ /* iterate the tags in the message */
+ xs_list_foreach(tags_in_msg, te) {
+ if (xs_type(te) == XSTYPE_DICT) {
+ const char *type = xs_dict_get(te, "type");
+ const char *name = xs_dict_get(te, "name");
+
+ if (xs_type(type) == XSTYPE_STRING && xs_type(name) == XSTYPE_STRING) {
+ if (strcmp(type, "Hashtag") == 0 && xs_list_in(fw_tags, name) != -1)
+ return 7;
+ }
+ }
+ }
+ }
+ }
+
return 0;
}