commit be9cf2f

default  ·  2024-05-04 23:58:27 +0000 UTC
parent fc76ae4
Enqueue an object request for closed polls.

It seems that Pleroma does not send poll updates on close (or never).
2 files changed,  +20, -1
M data.c
M html.c
M data.c
+1, -1
1@@ -2662,7 +2662,7 @@ void enqueue_object_request(snac *user, const char *id, int forward_secs)
2 
3     qmsg = _enqueue_put(fn, qmsg);
4 
5-    snac_debug(user, 0, xs_fmt("enqueue_object_request %s", id));
6+    snac_debug(user, 0, xs_fmt("enqueue_object_request %s %d", id, forward_secs));
7 }
8 
9 
M html.c
+19, -0
 1@@ -3300,6 +3300,25 @@ int html_post_handler(const xs_dict *req, const char *q_path,
 2             timeline_add(&snac, xs_dict_get(msg, "id"), msg);
 3         }
 4 
 5+        {
 6+            /* get the poll object */
 7+            xs *poll = NULL;
 8+
 9+            if (valid_status(object_get(irt, &poll))) {
10+                char *date = xs_dict_get(poll, "endTime");
11+                if (xs_is_null(date))
12+                    date = xs_dict_get(poll, "closed");
13+
14+                if (!xs_is_null(date)) {
15+                    time_t t = xs_parse_iso_date(date, 0) - time(NULL);
16+
17+                    /* request the poll when it's closed;
18+                       Pleroma does not send and update when the poll closes */
19+                    enqueue_object_request(&snac, irt, t + 2);
20+                }
21+            }
22+        }
23+
24         status = 303;
25     }
26