summaryrefslogtreecommitdiff
path: root/html.c
diff options
context:
space:
mode:
authordefault <nobody@localhost>2022-10-16 18:03:28 +0200
committerdefault <nobody@localhost>2022-10-16 18:03:28 +0200
commitd9a15b8af7da2bc27d4d55ee745242f5b4e39071 (patch)
treef890fe2b2f0a327f08da31404fd267c675fac690 /html.c
parent0d79e465e6f01e51c5ddf26b40096e608b506d9b (diff)
Attachments are now starting to get real.
Diffstat (limited to 'html.c')
-rw-r--r--html.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/html.c b/html.c
index f4ecb8a..5e4f60c 100644
--- a/html.c
+++ b/html.c
@@ -877,12 +877,37 @@ int html_post_handler(d_char *req, char *q_path, d_char *payload, int p_size,
char *content = xs_dict_get(p_vars, "content");
char *in_reply_to = xs_dict_get(p_vars, "in_reply_to");
char *attach_url = xs_dict_get(p_vars, "attach_url");
+ char *attach_file = xs_dict_get(p_vars, "attach");
+ xs *attach_list = xs_list_new();
+
+ /* is attach_url set? */
+ if (!xs_is_null(attach_url) && *attach_url != '\0')
+ attach_list = xs_list_append(attach_list, attach_url);
+
+ /* is attach_file set? */
+ if (!xs_is_null(attach_file) && xs_type(attach_file) == XSTYPE_LIST) {
+ char *fn = xs_list_get(attach_file, 0);
+
+ if (*fn != '\0') {
+ char *ext = strrchr(fn, '.');
+ xs *ntid = tid(0);
+ xs *id = xs_fmt("%s%s", ntid, ext);
+ xs *url = xs_fmt("%s/s/%s", snac.actor, id);
+ int fo = xs_number_get(xs_list_get(attach_file, 1));
+ int fs = xs_number_get(xs_list_get(attach_file, 2));
+
+ /* store */
+ static_put(&snac, id, payload + fo, fs);
+
+ attach_list = xs_list_append(attach_list, url);
+ }
+ }
if (content != NULL) {
xs *msg = NULL;
xs *c_msg = NULL;
- msg = msg_note(&snac, content, NULL, in_reply_to, attach_url);
+ msg = msg_note(&snac, content, NULL, in_reply_to, attach_list);
c_msg = msg_create(&snac, msg);