commit 2f499e9

default  ·  2024-05-04 23:06:34 +0000 UTC
parent 20bc826
Fixed Pleroma polls.
1 files changed,  +16, -3
M html.c
M html.c
+16, -3
 1@@ -1653,20 +1653,27 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only,
 2         xs_list *p;
 3         xs_dict *v;
 4         int closed = 0;
 5+        char *f_closed = NULL;
 6 
 7         xs_html *poll = xs_html_tag("div", NULL);
 8 
 9         if (read_only)
10             closed = 1; /* non-identified page; show as closed */
11         else
12-        if (xs_dict_get(msg, "closed"))
13-            closed = 2;
14-        else
15         if (user && xs_startswith(id, user->actor))
16             closed = 1; /* we questioned; closed for us */
17         else
18         if (user && was_question_voted(user, id))
19             closed = 1; /* we already voted; closed for us */
20+        else
21+        if ((f_closed = xs_dict_get(msg, "closed")) != NULL) {
22+            /* it has a closed date... but is it in the past? */
23+            time_t t0 = time(NULL);
24+            time_t t1 = xs_parse_iso_date(f_closed, 0);
25+
26+            if (t1 < t0)
27+                closed = 2;
28+        }
29 
30         /* get the appropriate list of options */
31         p = oo != NULL ? oo : ao;
32@@ -1756,6 +1763,12 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only,
33         else {
34             /* show when the poll closes */
35             char *end_time = xs_dict_get(msg, "endTime");
36+
37+            /* Pleroma does not have an endTime field;
38+               it has a closed time in the future */
39+            if (xs_is_null(end_time))
40+                end_time = xs_dict_get(msg, "closed");
41+
42             if (!xs_is_null(end_time)) {
43                 time_t t0 = time(NULL);
44                 time_t t1 = xs_parse_iso_date(end_time, 0);