commit 25e1f7f
default
·
2024-12-30 09:34:53 +0000 UTC
parent fafeb6c
Started support for hashtag following.
1 files changed,
+22,
-0
+22,
-0
1@@ -706,6 +706,28 @@ int is_msg_for_me(snac *snac, const xs_dict *c_msg)
2 }
3 }
4
5+ /* is this a tag we're following? */
6+ const xs_list *tags_in_msg = xs_dict_get(msg, "tag");
7+ if (xs_type(tags_in_msg) == XSTYPE_LIST) {
8+ const xs_list *fw_tags = xs_dict_get(snac->config, "followed_hashtags");
9+ if (xs_type(fw_tags) == XSTYPE_LIST) {
10+ const xs_dict *te;
11+
12+ /* iterate the tags in the message */
13+ xs_list_foreach(tags_in_msg, te) {
14+ if (xs_type(te) == XSTYPE_DICT) {
15+ const char *type = xs_dict_get(te, "type");
16+ const char *name = xs_dict_get(te, "name");
17+
18+ if (xs_type(type) == XSTYPE_STRING && xs_type(name) == XSTYPE_STRING) {
19+ if (strcmp(type, "Hashtag") == 0 && xs_list_in(fw_tags, name) != -1)
20+ return 7;
21+ }
22+ }
23+ }
24+ }
25+ }
26+
27 return 0;
28 }
29