diff options
| -rw-r--r-- | activitypub.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/activitypub.c b/activitypub.c index 86599ee..cade0d9 100644 --- a/activitypub.c +++ b/activitypub.c | |||
| @@ -621,6 +621,36 @@ int followed_hashtag_check(snac *user, const xs_dict *msg) | |||
| 621 | } | 621 | } |
| 622 | 622 | ||
| 623 | 623 | ||
| 624 | void followed_hashtag_distribute(const xs_dict *msg) | ||
| 625 | /* distribute this post to all users following the included hashtags */ | ||
| 626 | { | ||
| 627 | const char *id = xs_dict_get(msg, "id"); | ||
| 628 | const xs_list *tags_in_msg = xs_dict_get(msg, "tag"); | ||
| 629 | |||
| 630 | if (!xs_is_string(id) || !xs_is_list(tags_in_msg) || xs_list_len(tags_in_msg) == 0) | ||
| 631 | return; | ||
| 632 | |||
| 633 | srv_debug(1, xs_fmt("followed_hashtag_distribute check for %s", id)); | ||
| 634 | |||
| 635 | xs *users = user_list(); | ||
| 636 | const char *uid; | ||
| 637 | |||
| 638 | xs_list_foreach(users, uid) { | ||
| 639 | snac user; | ||
| 640 | |||
| 641 | if (user_open(&user, uid)) { | ||
| 642 | if (followed_hashtag_check(&user, msg)) { | ||
| 643 | timeline_add(&user, id, msg); | ||
| 644 | |||
| 645 | snac_log(&user, xs_fmt("followed hashtag in %s", id)); | ||
| 646 | } | ||
| 647 | |||
| 648 | user_free(&user); | ||
| 649 | } | ||
| 650 | } | ||
| 651 | } | ||
| 652 | |||
| 653 | |||
| 624 | int is_msg_for_me(snac *snac, const xs_dict *c_msg) | 654 | int is_msg_for_me(snac *snac, const xs_dict *c_msg) |
| 625 | /* checks if this message is for me */ | 655 | /* checks if this message is for me */ |
| 626 | { | 656 | { |
| @@ -2313,6 +2343,9 @@ int process_input_message(snac *snac, const xs_dict *msg, const xs_dict *req) | |||
| 2313 | /* distribute the post with the actor as 'proxy' */ | 2343 | /* distribute the post with the actor as 'proxy' */ |
| 2314 | list_distribute(snac, actor, a_msg); | 2344 | list_distribute(snac, actor, a_msg); |
| 2315 | 2345 | ||
| 2346 | /* distribute the post to users following these hashtags */ | ||
| 2347 | followed_hashtag_distribute(a_msg); | ||
| 2348 | |||
| 2316 | do_notify = 1; | 2349 | do_notify = 1; |
| 2317 | } | 2350 | } |
| 2318 | else | 2351 | else |