summaryrefslogtreecommitdiff
path: root/html.c
diff options
context:
space:
mode:
authorGravatar default2022-09-30 05:36:46 +0200
committerGravatar default2022-09-30 05:36:46 +0200
commit118ebac622b387973d60075f3a22d92ef3d8dd46 (patch)
tree5f166447e7b79c4f0e930d10faa1b5302b21a5d7 /html.c
parentFixed check_signature(). (diff)
downloadsnac2-118ebac622b387973d60075f3a22d92ef3d8dd46.tar.gz
snac2-118ebac622b387973d60075f3a22d92ef3d8dd46.tar.xz
snac2-118ebac622b387973d60075f3a22d92ef3d8dd46.zip
Posts can be done from the web interface.
Diffstat (limited to 'html.c')
-rw-r--r--html.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/html.c b/html.c
index fca05d2..66c35f1 100644
--- a/html.c
+++ b/html.c
@@ -760,6 +760,66 @@ int html_post_handler(d_char *req, char *q_path, d_char *payload, int p_size,
760 char **body, int *b_size, char **ctype) 760 char **body, int *b_size, char **ctype)
761{ 761{
762 int status = 0; 762 int status = 0;
763 snac snac;
764 char *uid, *p_path;
765 char *p_vars;
766
767 xs *l = xs_split_n(q_path, "/", 2);
768
769 uid = xs_list_get(l, 1);
770 if (!uid || !user_open(&snac, uid)) {
771 /* invalid user */
772 srv_log(xs_fmt("html_get_handler bad user %s", uid));
773 return 404;
774 }
775
776 p_path = xs_list_get(l, 2);
777
778 /* all posts must be authenticated */
779 if (!login(&snac, req))
780 return 401;
781
782 p_vars = xs_dict_get(req, "p_vars");
783
784 {
785 xs *j1 = xs_json_dumps_pp(req, 4);
786 printf("%s\n", j1);
787 printf("[%s]\n", p_path);
788 }
789
790 if (p_path && strcmp(p_path, "admin/note") == 0) {
791 /* post note */
792 char *content = xs_dict_get(p_vars, "content");
793 char *in_reply_to = xs_dict_get(p_vars, "in_reply_to");
794
795 if (content != NULL) {
796 xs *msg = NULL;
797 xs *c_msg = NULL;
798
799 msg = msg_note(&snac, content, NULL, in_reply_to);
800
801 c_msg = msg_create(&snac, msg);
802
803 post(&snac, c_msg);
804
805 timeline_add(&snac, xs_dict_get(msg, "id"), msg, in_reply_to, NULL);
806 }
807
808 status = 303;
809 }
810 else
811 if (p_path && strcmp(p_path, "admin/action") == 0) {
812 /* action on an entry */
813 }
814 else
815 if (p_path && strcmp(p_path, "admin/user-setup") == 0) {
816 /* change of user data */
817 }
818
819 if (status == 303) {
820 *body = xs_fmt("%s/admin", snac.actor);
821 *b_size = strlen(*body);
822 }
763 823
764 return status; 824 return status;
765} 825}