mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-10 03:50:38 +03:00
In update_question(), send the updated question to all voters.
This commit is contained in:
parent
60ea9b3a09
commit
aea0ea4416
@ -974,6 +974,7 @@ int update_question(snac *user, const char *id)
|
|||||||
xs *rcnt = xs_dict_new();
|
xs *rcnt = xs_dict_new();
|
||||||
xs *z = xs_number_new(0);
|
xs *z = xs_number_new(0);
|
||||||
xs *chld = NULL;
|
xs *chld = NULL;
|
||||||
|
xs *rcpts = xs_list_new();
|
||||||
xs_list *opts;
|
xs_list *opts;
|
||||||
xs_val *p;
|
xs_val *p;
|
||||||
xs_str *k;
|
xs_str *k;
|
||||||
@ -1010,7 +1011,9 @@ int update_question(snac *user, const char *id)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
const char *name = xs_dict_get(obj, "name");
|
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 */
|
/* get the current count */
|
||||||
const xs_number *cnt = xs_dict_get(rcnt, name);
|
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 */
|
/* if it exists, increment */
|
||||||
xs *ucnt = xs_number_new(xs_number_get(cnt) + 1);
|
xs *ucnt = xs_number_new(xs_number_get(cnt) + 1);
|
||||||
rcnt = xs_dict_set(rcnt, name, ucnt);
|
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));
|
snac_debug(user, 1, xs_fmt("recounted poll %s", id));
|
||||||
timeline_touch(user);
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user