aboutsummaryrefslogtreecommitdiff
path: root/mastoapi.c
diff options
context:
space:
mode:
authordefault <nobody@localhost>2025-04-02 09:01:31 +0200
committerdefault <nobody@localhost>2025-04-02 09:01:31 +0200
commit877434218ffca350eb918fd47dfe81f29f2605ae (patch)
tree696fb8648da6b579317086f4ffb49fe74d1fa92b /mastoapi.c
parent1962c628dfc2fa72470d39c8e1f3c975ca58faaf (diff)
mastoapi: added support for scheduled posts.
Diffstat (limited to 'mastoapi.c')
-rw-r--r--mastoapi.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/mastoapi.c b/mastoapi.c
index 7b1e0ad..d93afc5 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -2726,14 +2726,24 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path,
msg = xs_dict_set(msg, "summary", summary);
}
- /* store */
- timeline_add(&snac, xs_dict_get(msg, "id"), msg);
+ /* scheduled? */
+ const char *scheduled_at = xs_dict_get(args, "scheduled_at");
- /* 'Create' message */
- xs *c_msg = msg_create(&snac, msg);
- enqueue_message(&snac, c_msg);
+ if (xs_is_string(scheduled_at) && *scheduled_at) {
+ msg = xs_dict_set(msg, "published", scheduled_at);
- timeline_touch(&snac);
+ schedule_add(&snac, xs_dict_get(msg, "id"), msg);
+ }
+ else {
+ /* store */
+ timeline_add(&snac, xs_dict_get(msg, "id"), msg);
+
+ /* 'Create' message */
+ xs *c_msg = msg_create(&snac, msg);
+ enqueue_message(&snac, c_msg);
+
+ timeline_touch(&snac);
+ }
/* convert to a mastodon status as a response code */
xs *st = mastoapi_status(&snac, msg);