commit 93bc87e

default  ·  2024-12-04 06:06:50 +0000 UTC
parent a6e13e4
New user variable show_contact_metrics.
1 files changed,  +18, -2
+18, -2
 1@@ -2836,6 +2836,8 @@ int activitypub_get_handler(const xs_dict *req, const char *q_path,
 2 
 3     *ctype  = "application/activity+json";
 4 
 5+    int show_contact_metrics = xs_is_true(xs_dict_get(snac.config, "show_contact_metrics"));
 6+
 7     if (p_path == NULL) {
 8         /* if there was no component after the user, it's an actor request */
 9         msg = msg_actor(&snac);
10@@ -2875,13 +2877,27 @@ int activitypub_get_handler(const xs_dict *req, const char *q_path,
11     }
12     else
13     if (strcmp(p_path, "followers") == 0) {
14+        int total = 0;
15+
16+        if (show_contact_metrics) {
17+            xs *l = follower_list(&snac);
18+            total = xs_list_len(l);
19+        }
20+
21         xs *id = xs_fmt("%s/%s", snac.actor, p_path);
22-        msg = msg_collection(&snac, id, 0);
23+        msg = msg_collection(&snac, id, total);
24     }
25     else
26     if (strcmp(p_path, "following") == 0) {
27+        int total = 0;
28+
29+        if (show_contact_metrics) {
30+            xs *l = following_list(&snac);
31+            total = xs_list_len(l);
32+        }
33+
34         xs *id = xs_fmt("%s/%s", snac.actor, p_path);
35-        msg = msg_collection(&snac, id, 0);
36+        msg = msg_collection(&snac, id, total);
37     }
38     else
39     if (xs_startswith(p_path, "p/")) {