diff options
| author | shtrophic <christoph@liebender.dev> | 2024-12-05 17:16:57 +0100 |
|---|---|---|
| committer | shtrophic <christoph@liebender.dev> | 2024-12-05 17:16:57 +0100 |
| commit | 7e743e8918e0a4d058217ec33ab745b1f1a97335 (patch) | |
| tree | 9aaed93dff31ccfbc63b4302dd8531a47c11f9bf /mastoapi.c | |
| parent | cbd89bdf16674b577cee7d7533ea69014cb307e7 (diff) | |
| parent | 221eeabf0c00f076ee8ae670811aabbc5b11a826 (diff) | |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'mastoapi.c')
| -rw-r--r-- | mastoapi.c | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -663,6 +663,17 @@ xs_dict *mastoapi_account(snac *logged, const xs_dict *actor) if (user_open(&user, prefu)) { val_links = user.links; metadata = xs_dict_get_def(user.config, "metadata", xs_stock(XSTYPE_DICT)); + + /* does this user want to publish their contact metrics? */ + if (xs_is_true(xs_dict_get(user.config, "show_contact_metrics"))) { + xs *fwing = following_list(&user); + xs *fwers = follower_list(&user); + xs *ni = xs_number_new(xs_list_len(fwing)); + xs *ne = xs_number_new(xs_list_len(fwers)); + + acct = xs_dict_append(acct, "followers_count", ne); + acct = xs_dict_append(acct, "following_count", ni); + } } } @@ -1275,6 +1286,17 @@ void credentials_get(char **body, char **ctype, int *status, snac snac) acct = xs_dict_append(acct, "following_count", xs_stock(0)); acct = xs_dict_append(acct, "statuses_count", xs_stock(0)); + /* does this user want to publish their contact metrics? */ + if (xs_is_true(xs_dict_get(snac.config, "show_contact_metrics"))) { + xs *fwing = following_list(&snac); + xs *fwers = follower_list(&snac); + xs *ni = xs_number_new(xs_list_len(fwing)); + xs *ne = xs_number_new(xs_list_len(fwers)); + + acct = xs_dict_append(acct, "followers_count", ne); + acct = xs_dict_append(acct, "following_count", ni); + } + *body = xs_json_dumps(acct, 4); *ctype = "application/json"; *status = HTTP_STATUS_OK; @@ -1349,6 +1371,9 @@ xs_list *mastoapi_timeline(snac *user, const xs_dict *args, const char *index_fn if (!xs_match(type, POSTLIKE_OBJECT_TYPE)) continue; + if (id && is_instance_blocked(id)) + continue; + const char *from = NULL; if (strcmp(type, "Page") == 0) from = xs_dict_get(msg, "audience"); |