From c4f05a8d084dbee4a2dd526e5febe39964e90428 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Fri, 10 Dec 2021 21:11:13 -0500 Subject: [PATCH] How about that ... we're now correctly handling the reply-references and carrying over the subject, and Wes is on the way here with a burger for me. --- webcit-ng/http.c | 18 ++++++++++++++++++ webcit-ng/messages.c | 8 +++++++- webcit-ng/static/js/view_forum.js | 16 +++++++++++++--- webcit-ng/webcit.h | 1 + 4 files changed, 39 insertions(+), 4 deletions(-) diff --git a/webcit-ng/http.c b/webcit-ng/http.c index 29a1fba6d..8daa52afa 100644 --- a/webcit-ng/http.c +++ b/webcit-ng/http.c @@ -173,6 +173,7 @@ void perform_one_http_transaction(struct client_handle *ch) { kv.key = strdup(tok); kv.val = strdup(eq); array_append(h.request_parms, &kv); + syslog(LOG_DEBUG, "\033[1m\033[33m| %s = %s\033[0m", kv.key, kv.val); } } } @@ -302,3 +303,20 @@ char *header_val(struct http_transaction *h, char *requested_header) { } return (NULL); } + + +// Utility function to fetch a specific URL parameter from a completely read-in request. +// Returns the value of the requested parameter, or NULL if the specified parameter was not sent. +// The caller does NOT own the memory of the returned pointer, but can count on the pointer +// to still be valid through the end of the transaction. +char *get_url_param(struct http_transaction *h, char *requested_param) { + struct keyval *kv; + int i; + for (i=0; irequest_parms); ++i) { + kv = array_get_element_at(h->request_parms, i); + if (!strcasecmp(kv->key, requested_param)) { + return (kv->val); + } + } + return (NULL); +} diff --git a/webcit-ng/messages.c b/webcit-ng/messages.c index 5ecfc165f..841271796 100644 --- a/webcit-ng/messages.c +++ b/webcit-ng/messages.c @@ -146,7 +146,13 @@ void dav_put_message(struct http_transaction *h, struct ctdlsession *c, char *eu return; } - ctdl_printf(c, "ENT0 1|||4|||1|"); // This protocol syntax will give us metadata back after upload + char *wefw = get_url_param(h, "wefw"); // references + if (!wefw) wefw = ""; + char *subj = get_url_param(h, "subj"); // subject + if (!subj) subj = ""; + + // Mode 4 will give us metadata back after upload + ctdl_printf(c, "ENT0 1|||4|%s||1|||||%s|", subj, wefw); ctdl_readline(c, buf, sizeof buf); if (buf[0] != '8') { h->response_code = 502; diff --git a/webcit-ng/static/js/view_forum.js b/webcit-ng/static/js/view_forum.js index d073b99ee..79d0cbb11 100644 --- a/webcit-ng/static/js/view_forum.js +++ b/webcit-ng/static/js/view_forum.js @@ -258,13 +258,18 @@ function open_reply_box(prefix, msgnum, is_quoted, references, msgid) { + ""; // end buttons on right side if (msg.subj) { replybox += - "
" + "FIXME subject" + ""; + "
" + "FIXME subject" + ""; + } + else { // hidden filed for empty subject + replybox += ""; } replybox += "
" // end header + + + "" // hidden field for references + + compose_references(references,msgid) + "" // begin body + "
" - + "refs: " + compose_references(references,msgid) + "
" + "\n" // empty initial content + "
" // end body @@ -338,8 +343,13 @@ function forum_cancel_post(div_name) { function forum_save_message(div_name, reply_to_msgnum) { document.body.style.cursor = "wait"; + wefw = (document.getElementById("ctdl-replyreferences").innerHTML).replaceAll("|","!"); // references (if present) + subj = document.getElementById("ctdl-subject").innerHTML; // subject (if present) - url = "/ctdl/r/" + escapeHTMLURI(current_room) + "/dummy_name_for_new_message"; + url = "/ctdl/r/" + escapeHTMLURI(current_room) + + "/dummy_name_for_new_message" + + "?wefw=" + wefw + + "&subj=" + subj boundary = randomString(20); body_text = "--" + boundary + "\r\n" diff --git a/webcit-ng/webcit.h b/webcit-ng/webcit.h index 06269da81..c3e326dfb 100644 --- a/webcit-ng/webcit.h +++ b/webcit-ng/webcit.h @@ -137,6 +137,7 @@ void ctdl_u(struct http_transaction *, struct ctdlsession *); struct ctdlsession *connect_to_citadel(struct http_transaction *); void disconnect_from_citadel(struct ctdlsession *); char *header_val(struct http_transaction *h, char *requested_header); +char *get_url_param(struct http_transaction *h, char *requested_param); int unescape_input(char *); void http_redirect(struct http_transaction *h, char *to_where); char *http_datestring(time_t xtime); -- 2.30.2