snac2

Fork of https://codeberg.org/grunfink/snac2
git clone https://git.inz.fi/snac2
Log | Files | Refs | README | LICENSE

commit a51c996efe0e41334523602271740b6e6b2501c0
parent ac663a6b4dd5eee1fb3c676524b8e141eb2529ed
Author: default <nobody@localhost>
Date:   Wed, 22 Jan 2025 10:38:01 +0100

More tweaks to hashtag following code.

Diffstat:
Mactivitypub.c | 21+++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/activitypub.c b/activitypub.c @@ -636,19 +636,32 @@ int is_msg_for_me(snac *snac, const xs_dict *c_msg) if (xs_match(type, "Like|Announce|EmojiReact")) { const char *object = xs_dict_get(c_msg, "object"); - if (xs_type(object) == XSTYPE_DICT) + if (xs_is_dict(object)) object = xs_dict_get(object, "id"); /* bad object id? reject */ - if (xs_type(object) != XSTYPE_STRING) + if (!xs_is_string(object)) return 0; /* if it's about one of our posts, accept it */ if (xs_startswith(object, snac->actor)) return 2; - /* if it's by someone we don't follow, reject */ - return following_check(snac, actor); + /* if it's by someone we follow, accept it */ + if (following_check(snac, actor)) + return 1; + + /* do we follow any hashtag? */ + if (xs_is_list(xs_dict_get(snac->config, "followed_hashtags"))) { + xs *obj = NULL; + + /* if the admired object contains any followed hashtag, accept it */ + if (valid_status(object_get(object, &obj)) && + followed_hashtag_check(snac, obj)) + return 7; + } + + return 0; } /* if it's an Undo, it must be from someone related to us */