snac2

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

commit 65df883b3fe8d86720b918927568d394d6c73cef
parent 4318e8f9e77b9af1faf57ce7481eac4388d3009f
Author: default <nobody@localhost>
Date:   Tue,  8 Aug 2023 13:56:12 +0200

Fixed votersCount.

Diffstat:
Mactivitypub.c | 9+++++++--
1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/activitypub.c b/activitypub.c @@ -1257,7 +1257,6 @@ int update_question(snac *user, const char *id) xs *msg = NULL; xs *rcnt = xs_dict_new(); xs *z = xs_number_new(0); - xs *rcpts = xs_list_new(); xs *lopts = xs_list_new(); xs_list *opts; xs_list *p; @@ -1286,6 +1285,9 @@ int update_question(snac *user, const char *id) } } + xs_set s; + xs_set_init(&s); + /* iterate now the children (the votes) */ xs *chld = object_children(id); p = chld; @@ -1307,11 +1309,13 @@ int update_question(snac *user, const char *id) xs *ucnt = xs_number_new(xs_number_get(cnt) + 1); rcnt = xs_dict_set(rcnt, name, ucnt); - rcpts = xs_list_append(rcpts, atto); + xs_set_add(&s, atto); } } } + xs *rcpts = xs_set_result(&s); + /* create a new list of options with their new counts */ xs *nopts = xs_list_new(); p = lopts; @@ -1354,6 +1358,7 @@ int update_question(snac *user, const char *id) /* update the count of voters */ xs *vcnt = xs_number_new(xs_list_len(rcpts)); msg = xs_dict_set(msg, "votersCount", vcnt); + msg = xs_dict_set(msg, "cc", rcpts); /* store */ object_add_ow(id, msg);