snac2

Fork of https://codeberg.org/grunfink/snac2
git clone https://git.inz.fi/snac2
Log | Files | Refs | README | LICENSE

commit 2edce5e0ec5d098a7b879df20496cd636fa6d192
parent a45a0d68e3d8a942a2bf516d5086920dbcb3a862
Author: default <nobody@localhost>
Date:   Wed,  4 Dec 2024 21:45:49 +0100

mastoapi: show contact metrics if the user want.

Diffstat:
Mmastoapi.c | 11+++++++++++
1 file changed, 11 insertions(+), 0 deletions(-)

diff --git a/mastoapi.c b/mastoapi.c @@ -663,6 +663,17 @@ xs_dict *mastoapi_account(snac *logged, const xs_dict *actor) if (user_open(&user, prefu)) { val_links = user.links; metadata = xs_dict_get_def(user.config, "metadata", xs_stock(XSTYPE_DICT)); + + /* does this user want to publish their contact metrics? */ + if (xs_is_true(xs_dict_get(user.config, "show_contact_metrics"))) { + xs *fwing = following_list(&user); + xs *fwers = follower_list(&user); + 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); + } } }