diff options
| author | 2025-09-09 08:33:30 +0200 | |
|---|---|---|
| committer | 2025-09-09 08:33:30 +0200 | |
| commit | 4b5e945d957aaf6aa96cb11715384d161f245ea1 (patch) | |
| tree | 40474c817aad2c2af488263532f40af078a65958 /main.c | |
| parent | Got rid of the 'fsck' command, as it's done on startup. (diff) | |
| download | snac2-4b5e945d957aaf6aa96cb11715384d161f245ea1.tar.gz snac2-4b5e945d957aaf6aa96cb11715384d161f245ea1.tar.xz snac2-4b5e945d957aaf6aa96cb11715384d161f245ea1.zip | |
Added support for scheduled posts from the cmdline.
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 38 |
1 files changed, 29 insertions, 9 deletions
| @@ -808,6 +808,20 @@ int main(int argc, char *argv[]) | |||
| 808 | const char *fn = NULL; | 808 | const char *fn = NULL; |
| 809 | const char *in_reply_to = NULL; | 809 | const char *in_reply_to = NULL; |
| 810 | const char **next = NULL; | 810 | const char **next = NULL; |
| 811 | xs *post_date = NULL; | ||
| 812 | |||
| 813 | const char *env_date = getenv("SNAC_POST_DATE"); | ||
| 814 | if (env_date) { | ||
| 815 | /* convert to ISO */ | ||
| 816 | time_t t = xs_parse_localtime(env_date, "%Y%m%d%H%M%S"); | ||
| 817 | |||
| 818 | if (t == 0) { | ||
| 819 | fprintf(stderr, "Invalid $SNAC_POST_DATE format (must be YYYYmmddHHMMSS)\n"); | ||
| 820 | return 1; | ||
| 821 | } | ||
| 822 | |||
| 823 | post_date = xs_str_iso_date(t); | ||
| 824 | } | ||
| 811 | 825 | ||
| 812 | /* iterate possible attachments */ | 826 | /* iterate possible attachments */ |
| 813 | while ((fn = GET_ARGV())) { | 827 | while ((fn = GET_ARGV())) { |
| @@ -885,7 +899,7 @@ int main(int argc, char *argv[]) | |||
| 885 | content = xs_dup(url); | 899 | content = xs_dup(url); |
| 886 | 900 | ||
| 887 | if (!content || !*content) { | 901 | if (!content || !*content) { |
| 888 | printf("Nothing to send\n"); | 902 | fprintf(stderr, "Nothing to send\n"); |
| 889 | return 1; | 903 | return 1; |
| 890 | } | 904 | } |
| 891 | 905 | ||
| @@ -896,18 +910,24 @@ int main(int argc, char *argv[]) | |||
| 896 | if (strcmp(cmd, "note_unlisted") == 0) | 910 | if (strcmp(cmd, "note_unlisted") == 0) |
| 897 | scope = 2; | 911 | scope = 2; |
| 898 | 912 | ||
| 899 | msg = msg_note(&snac, content, NULL, in_reply_to, attl, scope, getenv("LANG"), NULL); | 913 | msg = msg_note(&snac, content, NULL, in_reply_to, attl, scope, getenv("LANG"), post_date); |
| 900 | 914 | ||
| 901 | c_msg = msg_create(&snac, msg); | 915 | const char *id = xs_dict_get(msg, "id"); |
| 902 | 916 | ||
| 903 | if (dbglevel) { | 917 | if (post_date) |
| 904 | xs_json_dump(c_msg, 4, stdout); | 918 | schedule_add(&snac, id, msg); |
| 905 | } | 919 | else { |
| 920 | c_msg = msg_create(&snac, msg); | ||
| 906 | 921 | ||
| 907 | enqueue_message(&snac, c_msg); | 922 | if (dbglevel) { |
| 908 | enqueue_webmention(msg); | 923 | xs_json_dump(c_msg, 4, stdout); |
| 924 | } | ||
| 909 | 925 | ||
| 910 | timeline_add(&snac, xs_dict_get(msg, "id"), msg); | 926 | enqueue_message(&snac, c_msg); |
| 927 | enqueue_webmention(msg); | ||
| 928 | |||
| 929 | timeline_add(&snac, id, msg); | ||
| 930 | } | ||
| 911 | 931 | ||
| 912 | return 0; | 932 | return 0; |
| 913 | } | 933 | } |