diff options
| author | 2024-12-04 21:58:19 +0100 | |
|---|---|---|
| committer | 2024-12-04 21:58:19 +0100 | |
| commit | e6d8cc26eaef1482b66acaf5f934536dde709109 (patch) | |
| tree | 88a14a19fe27e020601848532241289670dffe51 | |
| parent | mastoapi: show contact metrics if the user want. (diff) | |
| download | penes-snac2-e6d8cc26eaef1482b66acaf5f934536dde709109.tar.gz penes-snac2-e6d8cc26eaef1482b66acaf5f934536dde709109.tar.xz penes-snac2-e6d8cc26eaef1482b66acaf5f934536dde709109.zip | |
mastoapi: also fill metrics from credentials_get().
| -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) | |||
| 1286 | acct = xs_dict_append(acct, "following_count", xs_stock(0)); | 1286 | acct = xs_dict_append(acct, "following_count", xs_stock(0)); |
| 1287 | acct = xs_dict_append(acct, "statuses_count", xs_stock(0)); | 1287 | acct = xs_dict_append(acct, "statuses_count", xs_stock(0)); |
| 1288 | 1288 | ||
| 1289 | /* does this user want to publish their contact metrics? */ | ||
| 1290 | if (xs_is_true(xs_dict_get(snac.config, "show_contact_metrics"))) { | ||
| 1291 | xs *fwing = following_list(&snac); | ||
| 1292 | xs *fwers = follower_list(&snac); | ||
| 1293 | xs *ni = xs_number_new(xs_list_len(fwing)); | ||
| 1294 | xs *ne = xs_number_new(xs_list_len(fwers)); | ||
| 1295 | |||
| 1296 | acct = xs_dict_append(acct, "followers_count", ne); | ||
| 1297 | acct = xs_dict_append(acct, "following_count", ni); | ||
| 1298 | } | ||
| 1299 | |||
| 1289 | *body = xs_json_dumps(acct, 4); | 1300 | *body = xs_json_dumps(acct, 4); |
| 1290 | *ctype = "application/json"; | 1301 | *ctype = "application/json"; |
| 1291 | *status = HTTP_STATUS_OK; | 1302 | *status = HTTP_STATUS_OK; |