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) {
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");
+ "</span>" // end header info on left side
+ "<span class=\"ctdl-msg-header-buttons\">" // begin buttons on right side
- + "<span class=\"ctdl-msg-button\">" // Reply button FIXME make this work
- + "<a href=\"javascript:open_reply_box('"+prefix+"',"+msgnum+",false);\">"
+ + "<span class=\"ctdl-msg-button\">" // Reply
+ + "<a href=\"javascript:open_reply_box('"+prefix+"',"+msgnum+",false,'"+msg.wefw+"','"+msg.msgn+"');\">"
+ "<i class=\"fa fa-reply\"></i> "
+ _("Reply")
+ "</a></span>"
- + "<span class=\"ctdl-msg-button\">" // ReplyQuoted , only show in forums FIXME
- + "<a href=\"javascript:open_reply_box('"+prefix+"',"+msgnum+",true);\">"
+ + "<span class=\"ctdl-msg-button\">" // ReplyQuoted
+ + "<a href=\"javascript:open_reply_box('"+prefix+"',"+msgnum+",true,'"+msg.wefw+"','"+msg.msgn+"');\">"
+ "<i class=\"fa fa-comment\"></i> "
+ _("ReplyQuoted")
+ "</a></span>"
}
+// 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 += "<div id=\"" + new_div_name + "\">reply box put here</div>";
// FIXME - we need to retain the message number being replied to
}
replybox +=
"</div><br>" // end header
-
// begin body
+ "<div class=\"ctdl-msg-body\" id=\"ctdl-editor-body\" style=\"padding:5px;\" contenteditable=\"true\">"
+ + "refs: " + compose_references(references,msgid) + "<br>"
+ "\n" // empty initial content
+ "</div>" // end body
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