commit a51c996

default  ·  2025-01-22 09:38:01 +0000 UTC
parent ac663a6
More tweaks to hashtag following code.
1 files changed,  +17, -4
+17, -4
 1@@ -636,19 +636,32 @@ int is_msg_for_me(snac *snac, const xs_dict *c_msg)
 2     if (xs_match(type, "Like|Announce|EmojiReact")) {
 3         const char *object = xs_dict_get(c_msg, "object");
 4 
 5-        if (xs_type(object) == XSTYPE_DICT)
 6+        if (xs_is_dict(object))
 7             object = xs_dict_get(object, "id");
 8 
 9         /* bad object id? reject */
10-        if (xs_type(object) != XSTYPE_STRING)
11+        if (!xs_is_string(object))
12             return 0;
13 
14         /* if it's about one of our posts, accept it */
15         if (xs_startswith(object, snac->actor))
16             return 2;
17 
18-        /* if it's by someone we don't follow, reject */
19-        return following_check(snac, actor);
20+        /* if it's by someone we follow, accept it */
21+        if (following_check(snac, actor))
22+            return 1;
23+
24+        /* do we follow any hashtag? */
25+        if (xs_is_list(xs_dict_get(snac->config, "followed_hashtags"))) {
26+            xs *obj = NULL;
27+
28+            /* if the admired object contains any followed hashtag, accept it */
29+            if (valid_status(object_get(object, &obj)) &&
30+                followed_hashtag_check(snac, obj))
31+                return 7;
32+        }
33+
34+        return 0;
35     }
36 
37     /* if it's an Undo, it must be from someone related to us */