commit 6eb0aa1

default  ·  2023-05-24 11:19:40 +0000 UTC
parent 5d8e370
Show the poll as closed if we already voted for it.
1 files changed,  +21, -1
M html.c
M html.c
+21, -1
 1@@ -896,10 +896,30 @@ xs_str *html_entry(snac *snac, xs_str *os, const xs_dict *msg, int local,
 2             xs_list *ao = xs_dict_get(msg, "anyOf");
 3             xs_list *p;
 4             xs_dict *v;
 5+            int closed = 0;
 6 
 7+            if (xs_dict_get(msg, "closed"))
 8+                closed = 1;
 9+            else {
10+                /* not yet closed? check if we already voted for this */
11+                xs *children = object_children(id);
12+                p = children;
13+                while (!closed && xs_list_iter(&p, &v)) {
14+                    xs *msg = NULL;
15+
16+                    if (valid_status(object_get_by_md5(v, &msg))) {
17+                        const char *atto = xs_dict_get(msg, "attributedTo");
18+
19+                        if (atto && strcmp(atto, snac->actor) == 0)
20+                            closed = 1; /* closed for us */
21+                    }
22+                }
23+            }
24+
25+            /* get the appropriate list of options */
26             p = oo != NULL ? oo : ao;
27 
28-            if (!xs_is_null(xs_dict_get(msg, "closed"))) {
29+            if (closed) {
30                 /* closed poll */
31                 c = xs_str_cat(c, "<table>\n");
32