From 6eb210875770e7463daa7eddb9bf0fc3ecccec37 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Fri, 10 Dec 2021 18:15:43 -0500 Subject: [PATCH] Begin gathering references and message IDs for replies --- webcit-ng/forum_view.c | 6 +++++ webcit-ng/messages.c | 8 ++++--- webcit-ng/static/js/view_forum.js | 40 ++++++++++++++++++++++++------- 3 files changed, 43 insertions(+), 11 deletions(-) diff --git a/webcit-ng/forum_view.c b/webcit-ng/forum_view.c index 97f8a1b28..f3a9b5853 100644 --- a/webcit-ng/forum_view.c +++ b/webcit-ng/forum_view.c @@ -82,6 +82,12 @@ void json_render_one_message(struct http_transaction *h, struct ctdlsession *c, else if (!strncasecmp(buf, "subj=", 5)) { JsonObjectAppend(j, NewJsonPlainString(HKEY("subj"), &buf[5], -1)); } + else if (!strncasecmp(buf, "msgn=", 5)) { + JsonObjectAppend(j, NewJsonPlainString(HKEY("msgn"), &buf[5], -1)); + } + else if (!strncasecmp(buf, "wefw=", 5)) { + JsonObjectAppend(j, NewJsonPlainString(HKEY("wefw"), &buf[5], -1)); + } } if (message_originated_locally) { diff --git a/webcit-ng/messages.c b/webcit-ng/messages.c index ed88c9970..5ecfc165f 100644 --- a/webcit-ng/messages.c +++ b/webcit-ng/messages.c @@ -157,13 +157,15 @@ void dav_put_message(struct http_transaction *h, struct ctdlsession *c, char *eu return; } - // Remember, ctdl_printf() appends \n on its own, so we only need \r here. + // Remember, ctdl_printf() appends \n on its own, so when adding a CRLF newline, only use \r + // Or for a blank line, use ctdl_write() with \r\n + content_type = header_val(h, "Content-type"); ctdl_printf(c, "Content-type: %s\r", (content_type ? content_type : "application/octet-stream")); - ctdl_printf(c, "\r"); + ctdl_write(c, HKEY("\r\n")); ctdl_write(c, h->request_body, h->request_body_length); if (h->request_body[h->request_body_length] != '\n') { - ctdl_printf(c, "\r"); + ctdl_write(c, HKEY("\r\n")); } ctdl_printf(c, "000"); diff --git a/webcit-ng/static/js/view_forum.js b/webcit-ng/static/js/view_forum.js index 53c12969e..d073b99ee 100644 --- a/webcit-ng/static/js/view_forum.js +++ b/webcit-ng/static/js/view_forum.js @@ -140,14 +140,14 @@ function forum_render_one(prefix, msgnum, scroll_to) { + "" // end header info on left side + "" // begin buttons on right side - + "" // Reply button FIXME make this work - + "" + + "" // Reply + + "" + " " + _("Reply") + "" - + "" // ReplyQuoted , only show in forums FIXME - + "" + + "" // ReplyQuoted + + "" + " " + _("ReplyQuoted") + "" @@ -185,10 +185,34 @@ function forum_render_one(prefix, msgnum, scroll_to) { } +// Compose a references string using existing references plus the message being replied to +function compose_references(references, msgid) { + if (references.includes("@")) { + refs = references + "|"; + } + else { + refs = ""; + } + refs += msgid; + + console.log("initial len: " + refs.length); + // If the resulting string is too big, we can trim it here + while (refs.length > 900) { + r = refs.split("|"); + r.splice(1,1); // remove the second element so we keep the root + refs = r.join("|"); + console.log("split len: " + refs.length); + } + + + return refs; +} + + // Open a reply box directly below a specific message -function open_reply_box(prefix, msgnum, is_quoted) { +function open_reply_box(prefix, msgnum, is_quoted, references, msgid) { target_div_name = prefix+msgnum; - new_div_name = prefix + "_reply_to_" + msgnum; + new_div_name = prefix + "reply_to_" + msgnum; document.getElementById(target_div_name).outerHTML += "
reply box put here
"; // FIXME - we need to retain the message number being replied to @@ -238,9 +262,9 @@ function open_reply_box(prefix, msgnum, is_quoted) { } replybox += "
" // end header - // begin body + "
" + + "refs: " + compose_references(references,msgid) + "
" + "\n" // empty initial content + "
" // end body @@ -339,7 +363,7 @@ function forum_save_message(div_name, reply_to_msgnum) { for (var i in headers) { if (headers[i].startsWith("etag: ")) { new_msg_num = headers[i].split(" ")[1]; - alert(new_msg_num); + alert("div_name=" + div_name + " , reply_to_msgnum = " + reply_to_msgnum + " , new_msg_num = " + new_msg_num); } } document.getElementById(div_name).outerHTML = ""; // close the editor -- 2.39.2