diff options
author | default <nobody@localhost> | 2022-09-30 05:36:46 +0200 |
---|---|---|
committer | default <nobody@localhost> | 2022-09-30 05:36:46 +0200 |
commit | 118ebac622b387973d60075f3a22d92ef3d8dd46 (patch) | |
tree | 5f166447e7b79c4f0e930d10faa1b5302b21a5d7 /html.c | |
parent | 2688230a190cc5a98bfb5e95b3a41864854b3151 (diff) |
Posts can be done from the web interface.
Diffstat (limited to 'html.c')
-rw-r--r-- | html.c | 60 |
1 files changed, 60 insertions, 0 deletions
@@ -760,6 +760,66 @@ int html_post_handler(d_char *req, char *q_path, d_char *payload, int p_size, char **body, int *b_size, char **ctype) { int status = 0; + snac snac; + char *uid, *p_path; + char *p_vars; + + xs *l = xs_split_n(q_path, "/", 2); + + uid = xs_list_get(l, 1); + if (!uid || !user_open(&snac, uid)) { + /* invalid user */ + srv_log(xs_fmt("html_get_handler bad user %s", uid)); + return 404; + } + + p_path = xs_list_get(l, 2); + + /* all posts must be authenticated */ + if (!login(&snac, req)) + return 401; + + p_vars = xs_dict_get(req, "p_vars"); + + { + xs *j1 = xs_json_dumps_pp(req, 4); + printf("%s\n", j1); + printf("[%s]\n", p_path); + } + + if (p_path && strcmp(p_path, "admin/note") == 0) { + /* post note */ + char *content = xs_dict_get(p_vars, "content"); + char *in_reply_to = xs_dict_get(p_vars, "in_reply_to"); + + if (content != NULL) { + xs *msg = NULL; + xs *c_msg = NULL; + + msg = msg_note(&snac, content, NULL, in_reply_to); + + c_msg = msg_create(&snac, msg); + + post(&snac, c_msg); + + timeline_add(&snac, xs_dict_get(msg, "id"), msg, in_reply_to, NULL); + } + + status = 303; + } + else + if (p_path && strcmp(p_path, "admin/action") == 0) { + /* action on an entry */ + } + else + if (p_path && strcmp(p_path, "admin/user-setup") == 0) { + /* change of user data */ + } + + if (status == 303) { + *body = xs_fmt("%s/admin", snac.actor); + *b_size = strlen(*body); + } return status; } |