diff options
| author | 2024-12-30 10:34:53 +0100 | |
|---|---|---|
| committer | 2024-12-30 10:34:53 +0100 | |
| commit | 25e1f7f4d11ac208291e9eacf93a7dc6b883e23d (patch) | |
| tree | 09d62097d9d4ba59d8346217e11943ac6692cb05 /activitypub.c | |
| parent | Merge pull request 'mastoapi: implement timeline min_id' (#254) from nowster/... (diff) | |
| download | penes-snac2-25e1f7f4d11ac208291e9eacf93a7dc6b883e23d.tar.gz penes-snac2-25e1f7f4d11ac208291e9eacf93a7dc6b883e23d.tar.xz penes-snac2-25e1f7f4d11ac208291e9eacf93a7dc6b883e23d.zip | |
Started support for hashtag following.
Diffstat (limited to 'activitypub.c')
| -rw-r--r-- | activitypub.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/activitypub.c b/activitypub.c index 88d8fd8..311255f 100644 --- a/activitypub.c +++ b/activitypub.c | |||
| @@ -706,6 +706,28 @@ int is_msg_for_me(snac *snac, const xs_dict *c_msg) | |||
| 706 | } | 706 | } |
| 707 | } | 707 | } |
| 708 | 708 | ||
| 709 | /* is this a tag we're following? */ | ||
| 710 | const xs_list *tags_in_msg = xs_dict_get(msg, "tag"); | ||
| 711 | if (xs_type(tags_in_msg) == XSTYPE_LIST) { | ||
| 712 | const xs_list *fw_tags = xs_dict_get(snac->config, "followed_hashtags"); | ||
| 713 | if (xs_type(fw_tags) == XSTYPE_LIST) { | ||
| 714 | const xs_dict *te; | ||
| 715 | |||
| 716 | /* iterate the tags in the message */ | ||
| 717 | xs_list_foreach(tags_in_msg, te) { | ||
| 718 | if (xs_type(te) == XSTYPE_DICT) { | ||
| 719 | const char *type = xs_dict_get(te, "type"); | ||
| 720 | const char *name = xs_dict_get(te, "name"); | ||
| 721 | |||
| 722 | if (xs_type(type) == XSTYPE_STRING && xs_type(name) == XSTYPE_STRING) { | ||
| 723 | if (strcmp(type, "Hashtag") == 0 && xs_list_in(fw_tags, name) != -1) | ||
| 724 | return 7; | ||
| 725 | } | ||
| 726 | } | ||
| 727 | } | ||
| 728 | } | ||
| 729 | } | ||
| 730 | |||
| 709 | return 0; | 731 | return 0; |
| 710 | } | 732 | } |
| 711 | 733 | ||