diff options
| author | 2025-02-27 14:43:29 +0100 | |
|---|---|---|
| committer | 2025-02-27 14:43:29 +0100 | |
| commit | 771e987958fca3ad8cf310771256596dc38f4904 (patch) | |
| tree | 0acff4c664b852cb419cc4f4359943ea2520c7cd /activitypub.c | |
| parent | Merge pull request 'Fix memory leak in multipart parsing' (#307) from inz/sna... (diff) | |
| download | snac2-771e987958fca3ad8cf310771256596dc38f4904.tar.gz snac2-771e987958fca3ad8cf310771256596dc38f4904.tar.xz snac2-771e987958fca3ad8cf310771256596dc38f4904.zip | |
New function hashtag_in_msg().
Diffstat (limited to 'activitypub.c')
| -rw-r--r-- | activitypub.c | 17 |
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) | |||
| 587 | } | 587 | } |
| 588 | 588 | ||
| 589 | 589 | ||
| 590 | int followed_hashtag_check(snac *user, const xs_dict *msg) | 590 | int hashtag_in_msg(const xs_list *hashtags, const xs_dict *msg) |
| 591 | /* returns true if this message contains a hashtag followed by me */ | 591 | /* returns 1 if the message contains any of the list of hashtags */ |
| 592 | { | 592 | { |
| 593 | const xs_list *fw_tags = xs_dict_get(user->config, "followed_hashtags"); | 593 | if (xs_is_list(hashtags)) { |
| 594 | |||
| 595 | if (xs_is_list(fw_tags)) { | ||
| 596 | const xs_list *tags_in_msg = xs_dict_get(msg, "tag"); | 594 | const xs_list *tags_in_msg = xs_dict_get(msg, "tag"); |
| 597 | 595 | ||
| 598 | if (xs_is_list(tags_in_msg)) { | 596 | if (xs_is_list(tags_in_msg)) { |
| @@ -608,7 +606,7 @@ int followed_hashtag_check(snac *user, const xs_dict *msg) | |||
| 608 | if (strcmp(type, "Hashtag") == 0) { | 606 | if (strcmp(type, "Hashtag") == 0) { |
| 609 | xs *lc_name = xs_utf8_to_lower(name); | 607 | xs *lc_name = xs_utf8_to_lower(name); |
| 610 | 608 | ||
| 611 | if (xs_list_in(fw_tags, lc_name) != -1) | 609 | if (xs_list_in(hashtags, lc_name) != -1) |
| 612 | return 1; | 610 | return 1; |
| 613 | } | 611 | } |
| 614 | } | 612 | } |
| @@ -621,6 +619,13 @@ int followed_hashtag_check(snac *user, const xs_dict *msg) | |||
| 621 | } | 619 | } |
| 622 | 620 | ||
| 623 | 621 | ||
| 622 | int followed_hashtag_check(snac *user, const xs_dict *msg) | ||
| 623 | /* returns true if this message contains a hashtag followed by me */ | ||
| 624 | { | ||
| 625 | return hashtag_in_msg(xs_dict_get(user->config, "followed_hashtags"), msg); | ||
| 626 | } | ||
| 627 | |||
| 628 | |||
| 624 | void followed_hashtag_distribute(const xs_dict *msg) | 629 | void followed_hashtag_distribute(const xs_dict *msg) |
| 625 | /* distribute this post to all users following the included hashtags */ | 630 | /* distribute this post to all users following the included hashtags */ |
| 626 | { | 631 | { |