In update_question(), send the updated question to all voters.

This commit is contained in:
default 2023-05-29 09:37:54 +02:00
parent 60ea9b3a09
commit aea0ea4416

View file

@ -974,6 +974,7 @@ int update_question(snac *user, const char *id)
xs *rcnt = xs_dict_new();
xs *z = xs_number_new(0);
xs *chld = NULL;
xs *rcpts = xs_list_new();
xs_list *opts;
xs_val *p;
xs_str *k;
@ -1010,7 +1011,9 @@ int update_question(snac *user, const char *id)
continue;
const char *name = xs_dict_get(obj, "name");
if (name) {
const char *atto = xs_dict_get(obj, "attributedTo");
if (name && atto) {
/* get the current count */
const xs_number *cnt = xs_dict_get(rcnt, name);
@ -1018,6 +1021,8 @@ int update_question(snac *user, const char *id)
/* if it exists, increment */
xs *ucnt = xs_number_new(xs_number_get(cnt) + 1);
rcnt = xs_dict_set(rcnt, name, ucnt);
rcpts = xs_list_append(rcpts, atto);
}
}
}
@ -1058,6 +1063,12 @@ int update_question(snac *user, const char *id)
snac_debug(user, 1, xs_fmt("recounted poll %s", id));
timeline_touch(user);
/* send an update message to all voters */
xs *u_msg = msg_update(user, msg);
u_msg = xs_dict_set(u_msg, "cc", rcpts);
enqueue_message(user, u_msg);
return 0;
}