From 3b72b0f0ace1443f1ca6314d5fa8c0682c74bc37 Mon Sep 17 00:00:00 2001 From: default Date: Wed, 31 May 2023 22:06:31 +0200 Subject: New function was_question_voted(). --- data.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'data.c') 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 */ { -- cgit v1.2.3