commit e6d8cc2

default  ·  2024-12-04 20:58:19 +0000 UTC
parent 2edce5e
mastoapi: also fill metrics from credentials_get().
1 files changed,  +11, -0
+11, -0
 1@@ -1286,6 +1286,17 @@ void credentials_get(char **body, char **ctype, int *status, snac snac)
 2     acct = xs_dict_append(acct, "following_count", xs_stock(0));
 3     acct = xs_dict_append(acct, "statuses_count", xs_stock(0));
 4 
 5+    /* does this user want to publish their contact metrics? */
 6+    if (xs_is_true(xs_dict_get(snac.config, "show_contact_metrics"))) {
 7+        xs *fwing = following_list(&snac);
 8+        xs *fwers = follower_list(&snac);
 9+        xs *ni = xs_number_new(xs_list_len(fwing));
10+        xs *ne = xs_number_new(xs_list_len(fwers));
11+
12+        acct = xs_dict_append(acct, "followers_count", ne);
13+        acct = xs_dict_append(acct, "following_count", ni);
14+    }
15+
16     *body = xs_json_dumps(acct, 4);
17     *ctype = "application/json";
18     *status = HTTP_STATUS_OK;