summaryrefslogtreecommitdiff
path: root/data.c
diff options
context:
space:
mode:
authordefault <nobody@localhost>2023-05-31 22:06:31 +0200
committerdefault <nobody@localhost>2023-05-31 22:06:31 +0200
commit3b72b0f0ace1443f1ca6314d5fa8c0682c74bc37 (patch)
tree847828a0bdceb4f1233503ab07000dec43a6716f /data.c
parent796a111de81df9e7c8bc2e72947f27e97fa85dae (diff)
New function was_question_voted().
Diffstat (limited to 'data.c')
-rw-r--r--data.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/data.c b/data.c
index d7b0ff6..241ffbe 100644
--- a/data.c
+++ b/data.c
@@ -1935,6 +1935,30 @@ void enqueue_close_question(snac *user, const char *id, int end_secs)
}
+int was_question_voted(snac *user, const char *id)
+/* returns true if the user voted in this poll */
+{
+ xs *children = object_children(id);
+ int voted = 0;
+ xs_list *p;
+ xs_str *md5;
+
+ p = children;
+ while (xs_list_iter(&p, &md5)) {
+ xs *obj = NULL;
+
+ if (valid_status(object_get_by_md5(md5, &obj))) {
+ if (strcmp(xs_dict_get(obj, "attributedTo"), user->actor) == 0) {
+ voted = 1;
+ break;
+ }
+ }
+ }
+
+ return voted;
+}
+
+
xs_list *user_queue(snac *snac)
/* returns a list with filenames that can be dequeued */
{