summaryrefslogtreecommitdiff
path: root/html.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-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,
877 char *content = xs_dict_get(p_vars, "content"); 877 char *content = xs_dict_get(p_vars, "content");
878 char *in_reply_to = xs_dict_get(p_vars, "in_reply_to"); 878 char *in_reply_to = xs_dict_get(p_vars, "in_reply_to");
879 char *attach_url = xs_dict_get(p_vars, "attach_url"); 879 char *attach_url = xs_dict_get(p_vars, "attach_url");
880 char *attach_file = xs_dict_get(p_vars, "attach");
881 xs *attach_list = xs_list_new();
882
883 /* is attach_url set? */
884 if (!xs_is_null(attach_url) && *attach_url != '\0')
885 attach_list = xs_list_append(attach_list, attach_url);
886
887 /* is attach_file set? */
888 if (!xs_is_null(attach_file) && xs_type(attach_file) == XSTYPE_LIST) {
889 char *fn = xs_list_get(attach_file, 0);
890
891 if (*fn != '\0') {
892 char *ext = strrchr(fn, '.');
893 xs *ntid = tid(0);
894 xs *id = xs_fmt("%s%s", ntid, ext);
895 xs *url = xs_fmt("%s/s/%s", snac.actor, id);
896 int fo = xs_number_get(xs_list_get(attach_file, 1));
897 int fs = xs_number_get(xs_list_get(attach_file, 2));
898
899 /* store */
900 static_put(&snac, id, payload + fo, fs);
901
902 attach_list = xs_list_append(attach_list, url);
903 }
904 }
880 905
881 if (content != NULL) { 906 if (content != NULL) {
882 xs *msg = NULL; 907 xs *msg = NULL;
883 xs *c_msg = NULL; 908 xs *c_msg = NULL;
884 909
885 msg = msg_note(&snac, content, NULL, in_reply_to, attach_url); 910 msg = msg_note(&snac, content, NULL, in_reply_to, attach_list);
886 911
887 c_msg = msg_create(&snac, msg); 912 c_msg = msg_create(&snac, msg);
888 913