From 65df883b3fe8d86720b918927568d394d6c73cef Mon Sep 17 00:00:00 2001 From: default Date: Tue, 8 Aug 2023 13:56:12 +0200 Subject: [PATCH] Fixed votersCount. --- activitypub.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/activitypub.c b/activitypub.c index 24cf49d..1fb09c6 100644 --- 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);