diff options
| author | 2023-05-31 22:06:31 +0200 | |
|---|---|---|
| committer | 2023-05-31 22:06:31 +0200 | |
| commit | 3b72b0f0ace1443f1ca6314d5fa8c0682c74bc37 (patch) | |
| tree | 847828a0bdceb4f1233503ab07000dec43a6716f /data.c | |
| parent | New function mastoapi_poll(). (diff) | |
| download | snac2-3b72b0f0ace1443f1ca6314d5fa8c0682c74bc37.tar.gz snac2-3b72b0f0ace1443f1ca6314d5fa8c0682c74bc37.tar.xz snac2-3b72b0f0ace1443f1ca6314d5fa8c0682c74bc37.zip | |
New function was_question_voted().
Diffstat (limited to 'data.c')
| -rw-r--r-- | data.c | 24 |
1 files changed, 24 insertions, 0 deletions
| @@ -1935,6 +1935,30 @@ void enqueue_close_question(snac *user, const char *id, int end_secs) | |||
| 1935 | } | 1935 | } |
| 1936 | 1936 | ||
| 1937 | 1937 | ||
| 1938 | int was_question_voted(snac *user, const char *id) | ||
| 1939 | /* returns true if the user voted in this poll */ | ||
| 1940 | { | ||
| 1941 | xs *children = object_children(id); | ||
| 1942 | int voted = 0; | ||
| 1943 | xs_list *p; | ||
| 1944 | xs_str *md5; | ||
| 1945 | |||
| 1946 | p = children; | ||
| 1947 | while (xs_list_iter(&p, &md5)) { | ||
| 1948 | xs *obj = NULL; | ||
| 1949 | |||
| 1950 | if (valid_status(object_get_by_md5(md5, &obj))) { | ||
| 1951 | if (strcmp(xs_dict_get(obj, "attributedTo"), user->actor) == 0) { | ||
| 1952 | voted = 1; | ||
| 1953 | break; | ||
| 1954 | } | ||
| 1955 | } | ||
| 1956 | } | ||
| 1957 | |||
| 1958 | return voted; | ||
| 1959 | } | ||
| 1960 | |||
| 1961 | |||
| 1938 | xs_list *user_queue(snac *snac) | 1962 | xs_list *user_queue(snac *snac) |
| 1939 | /* returns a list with filenames that can be dequeued */ | 1963 | /* returns a list with filenames that can be dequeued */ |
| 1940 | { | 1964 | { |