diff options
| author | default <nobody@localhost> | 2024-12-04 21:58:19 +0100 |
|---|---|---|
| committer | default <nobody@localhost> | 2024-12-04 21:58:19 +0100 |
| commit | e6d8cc26eaef1482b66acaf5f934536dde709109 (patch) | |
| tree | 88a14a19fe27e020601848532241289670dffe51 /mastoapi.c | |
| parent | 2edce5e0ec5d098a7b879df20496cd636fa6d192 (diff) | |
mastoapi: also fill metrics from credentials_get().
Diffstat (limited to 'mastoapi.c')
| -rw-r--r-- | mastoapi.c | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -1286,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; |