commit e8b00b3
default
·
2025-03-31 18:23:24 +0000 UTC
parent 918cd65
Added some code for the future.
1 files changed,
+49,
-6
M
html.c
M
html.c
+49,
-6
1@@ -559,6 +559,30 @@ xs_html *html_note(snac *user, const char *summary,
2 xs_html_text(L("End in 1 day"))))));
3 }
4
5+#if 0
6+ /* scheduled post data */
7+ xs *sched_date = xs_dup("");
8+ xs *sched_time = xs_dup("");
9+
10+ xs_html_add(form,
11+ xs_html_tag("p", NULL),
12+ xs_html_tag("details",
13+ xs_html_tag("summary",
14+ xs_html_text(L("Scheduled post..."))),
15+ xs_html_tag("p",
16+ xs_html_text(L("Post date: ")),
17+ xs_html_sctag("input",
18+ xs_html_attr("type", "date"),
19+ xs_html_attr("value", sched_date),
20+ xs_html_attr("name", "post_date")),
21+ xs_html_text(" "),
22+ xs_html_text(L("Post time: ")),
23+ xs_html_sctag("input",
24+ xs_html_attr("type", "time"),
25+ xs_html_attr("value", sched_time),
26+ xs_html_attr("name", "post_time")))));
27+#endif
28+
29 xs_html_add(form,
30 xs_html_tag("p", NULL),
31 xs_html_sctag("input",
32@@ -4186,12 +4210,14 @@ int html_post_handler(const xs_dict *req, const char *q_path,
33 snac_debug(&snac, 1, xs_fmt("web action '%s' received", p_path));
34
35 /* post note */
36- const xs_str *content = xs_dict_get(p_vars, "content");
37- const xs_str *in_reply_to = xs_dict_get(p_vars, "in_reply_to");
38- const xs_str *to = xs_dict_get(p_vars, "to");
39- const xs_str *sensitive = xs_dict_get(p_vars, "sensitive");
40- const xs_str *summary = xs_dict_get(p_vars, "summary");
41- const xs_str *edit_id = xs_dict_get(p_vars, "edit_id");
42+ const char *content = xs_dict_get(p_vars, "content");
43+ const char *in_reply_to = xs_dict_get(p_vars, "in_reply_to");
44+ const char *to = xs_dict_get(p_vars, "to");
45+ const char *sensitive = xs_dict_get(p_vars, "sensitive");
46+ const char *summary = xs_dict_get(p_vars, "summary");
47+ const char *edit_id = xs_dict_get(p_vars, "edit_id");
48+ const char *post_date = xs_dict_get_def(p_vars, "post_date", "");
49+ const char *post_time = xs_dict_get_def(p_vars, "post_time", "");
50 int priv = !xs_is_null(xs_dict_get(p_vars, "mentioned_only"));
51 int store_as_draft = !xs_is_null(xs_dict_get(p_vars, "is_draft"));
52 xs *attach_list = xs_list_new();
53@@ -4279,6 +4305,23 @@ int html_post_handler(const xs_dict *req, const char *q_path,
54 msg = xs_dict_set(msg, "summary", xs_is_null(summary) ? "..." : summary);
55 }
56
57+ if (*post_date) {
58+ /* scheduled post */
59+ xs *sched_date = xs_fmt("%sT%s:00", post_date, *post_time ? post_time : "12:00");
60+ time_t t = xs_parse_localtime(sched_date, "%Y-%m-%dT%H:%M:%S");
61+
62+ if (t != 0) {
63+ xs *iso_date = xs_str_iso_date(t);
64+ msg = xs_dict_set(msg, "published", iso_date);
65+
66+ snac_debug(&snac, 1, xs_fmt("Scheduled date: [%s]", iso_date));
67+ }
68+ else {
69+ snac_log(&snac, xs_fmt("Invalid scheduled date: [%s]", sched_date));
70+ post_date = "";
71+ }
72+ }
73+
74 if (xs_is_null(edit_id)) {
75 /* new message */
76 const char *id = xs_dict_get(msg, "id");