diff options
| author | 2025-04-01 06:14:46 +0200 | |
|---|---|---|
| committer | 2025-04-01 06:14:46 +0200 | |
| commit | 5090e4e77489d7e4e2d358c417c83be8f76307cb (patch) | |
| tree | 99ac992b7388e4562e44661e4d9f8cc2e84e1613 /html.c | |
| parent | Some more work for future posts. (diff) | |
| download | snac2-5090e4e77489d7e4e2d358c417c83be8f76307cb.tar.gz snac2-5090e4e77489d7e4e2d358c417c83be8f76307cb.tar.xz snac2-5090e4e77489d7e4e2d358c417c83be8f76307cb.zip | |
Added more scheduling code.
Diffstat (limited to 'html.c')
| -rw-r--r-- | html.c | 44 |
1 files changed, 42 insertions, 2 deletions
| @@ -2870,6 +2870,18 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only, | |||
| 2870 | xs_html_text(L("drafts"))))); | 2870 | xs_html_text(L("drafts"))))); |
| 2871 | } | 2871 | } |
| 2872 | 2872 | ||
| 2873 | { | ||
| 2874 | /* show the list of scheduled posts */ | ||
| 2875 | xs *url = xs_fmt("%s/sched", user->actor); | ||
| 2876 | xs_html_add(lol, | ||
| 2877 | xs_html_tag("li", | ||
| 2878 | xs_html_tag("a", | ||
| 2879 | xs_html_attr("href", url), | ||
| 2880 | xs_html_attr("class", "snac-list-link"), | ||
| 2881 | xs_html_attr("title", L("Scheduled posts")), | ||
| 2882 | xs_html_text(L("scheduled posts"))))); | ||
| 2883 | } | ||
| 2884 | |||
| 2873 | /* the list of followed hashtags */ | 2885 | /* the list of followed hashtags */ |
| 2874 | const char *followed_hashtags = xs_dict_get(user->config, "followed_hashtags"); | 2886 | const char *followed_hashtags = xs_dict_get(user->config, "followed_hashtags"); |
| 2875 | 2887 | ||
| @@ -3919,6 +3931,21 @@ int html_get_handler(const xs_dict *req, const char *q_path, | |||
| 3919 | } | 3931 | } |
| 3920 | } | 3932 | } |
| 3921 | else | 3933 | else |
| 3934 | if (strcmp(p_path, "sched") == 0) { /** list of scheduled posts **/ | ||
| 3935 | if (!login(&snac, req)) { | ||
| 3936 | *body = xs_dup(uid); | ||
| 3937 | status = HTTP_STATUS_UNAUTHORIZED; | ||
| 3938 | } | ||
| 3939 | else { | ||
| 3940 | xs *list = scheduled_list(&snac); | ||
| 3941 | |||
| 3942 | *body = html_timeline(&snac, list, 0, skip, show, | ||
| 3943 | 0, L("Scheduled posts"), "", 0, error); | ||
| 3944 | *b_size = strlen(*body); | ||
| 3945 | status = HTTP_STATUS_OK; | ||
| 3946 | } | ||
| 3947 | } | ||
| 3948 | else | ||
| 3922 | if (xs_startswith(p_path, "list/")) { /** list timelines **/ | 3949 | if (xs_startswith(p_path, "list/")) { /** list timelines **/ |
| 3923 | if (!login(&snac, req)) { | 3950 | if (!login(&snac, req)) { |
| 3924 | *body = xs_dup(uid); | 3951 | *body = xs_dup(uid); |
| @@ -4342,7 +4369,7 @@ int html_post_handler(const xs_dict *req, const char *q_path, | |||
| 4342 | } | 4369 | } |
| 4343 | else | 4370 | else |
| 4344 | if (future_post) { | 4371 | if (future_post) { |
| 4345 | snac_log(&snac, xs_fmt("DUMMY scheduled post 1 %s", id)); | 4372 | schedule_add(&snac, id, msg); |
| 4346 | } | 4373 | } |
| 4347 | else { | 4374 | else { |
| 4348 | c_msg = msg_create(&snac, msg); | 4375 | c_msg = msg_create(&snac, msg); |
| @@ -4381,7 +4408,7 @@ int html_post_handler(const xs_dict *req, const char *q_path, | |||
| 4381 | object_add_ow(edit_id, msg); | 4408 | object_add_ow(edit_id, msg); |
| 4382 | 4409 | ||
| 4383 | if (future_post) { | 4410 | if (future_post) { |
| 4384 | snac_log(&snac, xs_fmt("DUMMY scheduled post 2 %s", edit_id)); | 4411 | schedule_add(&snac, edit_id, msg); |
| 4385 | } | 4412 | } |
| 4386 | else { | 4413 | else { |
| 4387 | c_msg = msg_create(&snac, msg); | 4414 | c_msg = msg_create(&snac, msg); |
| @@ -4390,7 +4417,15 @@ int html_post_handler(const xs_dict *req, const char *q_path, | |||
| 4390 | 4417 | ||
| 4391 | draft_del(&snac, edit_id); | 4418 | draft_del(&snac, edit_id); |
| 4392 | } | 4419 | } |
| 4420 | else | ||
| 4421 | if (is_scheduled(&snac, edit_id)) { | ||
| 4422 | /* editing an scheduled post; just update it */ | ||
| 4423 | schedule_add(&snac, edit_id, msg); | ||
| 4424 | } | ||
| 4393 | else { | 4425 | else { |
| 4426 | /* ignore the (possibly changed) published date */ | ||
| 4427 | msg = xs_dict_set(msg, "published", xs_dict_get(p_msg, "published")); | ||
| 4428 | |||
| 4394 | /* set the updated field */ | 4429 | /* set the updated field */ |
| 4395 | xs *updated = xs_str_utctime(0, ISO_DATE_SPEC); | 4430 | xs *updated = xs_str_utctime(0, ISO_DATE_SPEC); |
| 4396 | msg = xs_dict_set(msg, "updated", updated); | 4431 | msg = xs_dict_set(msg, "updated", updated); |
| @@ -4475,6 +4510,9 @@ int html_post_handler(const xs_dict *req, const char *q_path, | |||
| 4475 | if (is_draft(&snac, id)) | 4510 | if (is_draft(&snac, id)) |
| 4476 | draft_del(&snac, id); | 4511 | draft_del(&snac, id); |
| 4477 | else | 4512 | else |
| 4513 | if (is_scheduled(&snac, id)) | ||
| 4514 | schedule_del(&snac, id); | ||
| 4515 | else | ||
| 4478 | hide(&snac, id); | 4516 | hide(&snac, id); |
| 4479 | } | 4517 | } |
| 4480 | else | 4518 | else |
| @@ -4570,6 +4608,8 @@ int html_post_handler(const xs_dict *req, const char *q_path, | |||
| 4570 | 4608 | ||
| 4571 | draft_del(&snac, id); | 4609 | draft_del(&snac, id); |
| 4572 | 4610 | ||
| 4611 | schedule_del(&snac, id); | ||
| 4612 | |||
| 4573 | snac_log(&snac, xs_fmt("deleted entry %s", id)); | 4613 | snac_log(&snac, xs_fmt("deleted entry %s", id)); |
| 4574 | } | 4614 | } |
| 4575 | } | 4615 | } |