summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordefault <nobody@localhost>2023-08-08 13:56:12 +0200
committerdefault <nobody@localhost>2023-08-08 13:56:12 +0200
commit65df883b3fe8d86720b918927568d394d6c73cef (patch)
tree3f432eb14a323bd0e3bb9193d9cc3d234535b77c
parent4318e8f9e77b9af1faf57ce7481eac4388d3009f (diff)
Fixed votersCount.
-rw-r--r--activitypub.c9
1 files 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);