commit 8774342

default  ·  2025-04-02 07:01:31 +0000 UTC
parent 1962c62
mastoapi: added support for scheduled posts.
1 files changed,  +16, -6
+16, -6
 1@@ -2726,14 +2726,24 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path,
 2                 msg = xs_dict_set(msg, "summary",   summary);
 3             }
 4 
 5-            /* store */
 6-            timeline_add(&snac, xs_dict_get(msg, "id"), msg);
 7+            /* scheduled? */
 8+            const char *scheduled_at = xs_dict_get(args, "scheduled_at");
 9 
10-            /* 'Create' message */
11-            xs *c_msg = msg_create(&snac, msg);
12-            enqueue_message(&snac, c_msg);
13+            if (xs_is_string(scheduled_at) && *scheduled_at) {
14+                msg = xs_dict_set(msg, "published", scheduled_at);
15 
16-            timeline_touch(&snac);
17+                schedule_add(&snac, xs_dict_get(msg, "id"), msg);
18+            }
19+            else {
20+                /* store */
21+                timeline_add(&snac, xs_dict_get(msg, "id"), msg);
22+
23+                /* 'Create' message */
24+                xs *c_msg = msg_create(&snac, msg);
25+                enqueue_message(&snac, c_msg);
26+
27+                timeline_touch(&snac);
28+            }
29 
30             /* convert to a mastodon status as a response code */
31             xs *st = mastoapi_status(&snac, msg);