diff options
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) | |||
| 663 | if (user_open(&user, prefu)) { | 663 | if (user_open(&user, prefu)) { |
| 664 | val_links = user.links; | 664 | val_links = user.links; |
| 665 | metadata = xs_dict_get_def(user.config, "metadata", xs_stock(XSTYPE_DICT)); | 665 | metadata = xs_dict_get_def(user.config, "metadata", xs_stock(XSTYPE_DICT)); |
| 666 | |||
| 667 | /* does this user want to publish their contact metrics? */ | ||
| 668 | if (xs_is_true(xs_dict_get(user.config, "show_contact_metrics"))) { | ||
| 669 | xs *fwing = following_list(&user); | ||
| 670 | xs *fwers = follower_list(&user); | ||
| 671 | xs *ni = xs_number_new(xs_list_len(fwing)); | ||
| 672 | xs *ne = xs_number_new(xs_list_len(fwers)); | ||
| 673 | |||
| 674 | acct = xs_dict_append(acct, "followers_count", ne); | ||
| 675 | acct = xs_dict_append(acct, "following_count", ni); | ||
| 676 | } | ||
| 666 | } | 677 | } |
| 667 | } | 678 | } |
| 668 | 679 | ||
| @@ -1275,6 +1286,17 @@ void credentials_get(char **body, char **ctype, int *status, snac snac) | |||
| 1275 | acct = xs_dict_append(acct, "following_count", xs_stock(0)); | 1286 | acct = xs_dict_append(acct, "following_count", xs_stock(0)); |
| 1276 | acct = xs_dict_append(acct, "statuses_count", xs_stock(0)); | 1287 | acct = xs_dict_append(acct, "statuses_count", xs_stock(0)); |
| 1277 | 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 | |||
| 1278 | *body = xs_json_dumps(acct, 4); | 1300 | *body = xs_json_dumps(acct, 4); |
| 1279 | *ctype = "application/json"; | 1301 | *ctype = "application/json"; |
| 1280 | *status = HTTP_STATUS_OK; | 1302 | *status = HTTP_STATUS_OK; |
| @@ -1349,6 +1371,9 @@ xs_list *mastoapi_timeline(snac *user, const xs_dict *args, const char *index_fn | |||
| 1349 | if (!xs_match(type, POSTLIKE_OBJECT_TYPE)) | 1371 | if (!xs_match(type, POSTLIKE_OBJECT_TYPE)) |
| 1350 | continue; | 1372 | continue; |
| 1351 | 1373 | ||
| 1374 | if (id && is_instance_blocked(id)) | ||
| 1375 | continue; | ||
| 1376 | |||
| 1352 | const char *from = NULL; | 1377 | const char *from = NULL; |
| 1353 | if (strcmp(type, "Page") == 0) | 1378 | if (strcmp(type, "Page") == 0) |
| 1354 | from = xs_dict_get(msg, "audience"); | 1379 | from = xs_dict_get(msg, "audience"); |