diff options
| author | grunfink <grunfink@comam.es> | 2025-06-26 10:39:47 +0200 |
|---|---|---|
| committer | grunfink <grunfink@comam.es> | 2025-06-26 10:39:47 +0200 |
| commit | c976b9a334872e14aadc1f454680599468652231 (patch) | |
| tree | 357dc81cd871a94e861c3cef199ce30d1a66b079 | |
| parent | 5d680a5ba227c5275624fbeefe0cce05cfb60ee6 (diff) | |
Sending notes from the cmdline allows setting an inReplyTo field.
| -rw-r--r-- | Makefile | 6 | ||||
| -rw-r--r-- | Makefile.NetBSD | 6 | ||||
| -rw-r--r-- | main.c | 23 |
3 files changed, 25 insertions, 10 deletions
@@ -60,10 +60,10 @@ html.o: html.c xs.h xs_io.h xs_json.h xs_regex.h xs_set.h xs_openssl.h \ http.o: http.c xs.h xs_io.h xs_openssl.h xs_curl.h xs_time.h xs_json.h \ snac.h http_codes.h httpd.o: httpd.c xs.h xs_io.h xs_json.h xs_socket.h xs_unix_socket.h \ - xs_httpd.h xs_mime.h xs_time.h xs_openssl.h xs_fcgi.h xs_html.h snac.h \ - http_codes.h + xs_httpd.h xs_mime.h xs_time.h xs_openssl.h xs_fcgi.h xs_html.h \ + xs_webmention.h snac.h http_codes.h main.o: main.c xs.h xs_io.h xs_json.h xs_time.h xs_openssl.h xs_match.h \ - snac.h http_codes.h + xs_random.h snac.h http_codes.h mastoapi.o: mastoapi.c xs.h xs_hex.h xs_openssl.h xs_json.h xs_io.h \ xs_time.h xs_glob.h xs_set.h xs_random.h xs_url.h xs_mime.h xs_match.h \ xs_unicode.h snac.h http_codes.h diff --git a/Makefile.NetBSD b/Makefile.NetBSD index d19ab2d..ac5b052 100644 --- a/Makefile.NetBSD +++ b/Makefile.NetBSD @@ -49,10 +49,10 @@ html.o: html.c xs.h xs_io.h xs_json.h xs_regex.h xs_set.h xs_openssl.h \ http.o: http.c xs.h xs_io.h xs_openssl.h xs_curl.h xs_time.h xs_json.h \ snac.h http_codes.h httpd.o: httpd.c xs.h xs_io.h xs_json.h xs_socket.h xs_unix_socket.h \ - xs_httpd.h xs_mime.h xs_time.h xs_openssl.h xs_fcgi.h xs_html.h snac.h \ - http_codes.h + xs_httpd.h xs_mime.h xs_time.h xs_openssl.h xs_fcgi.h xs_html.h \ + xs_webmention.h snac.h http_codes.h main.o: main.c xs.h xs_io.h xs_json.h xs_time.h xs_openssl.h xs_match.h \ - snac.h http_codes.h + xs_random.h snac.h http_codes.h mastoapi.o: mastoapi.c xs.h xs_hex.h xs_openssl.h xs_json.h xs_io.h \ xs_time.h xs_glob.h xs_set.h xs_random.h xs_url.h xs_mime.h xs_match.h \ xs_unicode.h snac.h http_codes.h @@ -7,6 +7,7 @@ #include "xs_time.h" #include "xs_openssl.h" #include "xs_match.h" +#include "xs_random.h" #include "snac.h" @@ -779,12 +780,24 @@ int main(int argc, char *argv[]) xs *msg = NULL; xs *c_msg = NULL; xs *attl = xs_list_new(); - char *fn = NULL; + const char *fn = NULL; + const char *in_reply_to = NULL; + const char **next = NULL; /* iterate possible attachments */ while ((fn = GET_ARGV())) { FILE *f; + if (next) { + *next = fn; + next = NULL; + } + else + if (strcmp(fn, "-r") == 0) { + /* next argument is an inReplyTo */ + next = &in_reply_to; + } + else if ((f = fopen(fn, "rb")) != NULL) { /* get the file size and content */ fseek(f, 0, SEEK_END); @@ -794,8 +807,10 @@ int main(int argc, char *argv[]) fclose(f); char *ext = strrchr(fn, '.'); - xs *hash = xs_md5_hex(fn, strlen(fn)); - xs *id = xs_fmt("%s%s", hash, ext); + char rnd[32]; + xs_rnd_buf(rnd, sizeof(rnd)); + xs *hash = xs_md5_hex(rnd, sizeof(rnd)); + xs *id = xs_fmt("post-%s%s", hash, ext ? ext : ""); xs *url = xs_fmt("%s/s/%s", snac.actor, id); /* store */ @@ -856,7 +871,7 @@ int main(int argc, char *argv[]) if (strcmp(cmd, "note_unlisted") == 0) scope = 2; - msg = msg_note(&snac, content, NULL, NULL, attl, scope, getenv("LANG"), NULL); + msg = msg_note(&snac, content, NULL, in_reply_to, attl, scope, getenv("LANG"), NULL); c_msg = msg_create(&snac, msg); |