broken: attachments window cannot be a child of the editor body
authorArt Cancro <ajc@citadel.org>
Wed, 11 Oct 2023 03:18:07 +0000 (23:18 -0400)
committerArt Cancro <ajc@citadel.org>
Wed, 11 Oct 2023 03:18:07 +0000 (23:18 -0400)
It causes the attachments window to be saved as part of the message text.
Oof.

webcit-ng/server/messages.c
webcit-ng/static/js/upload.js
webcit-ng/static/js/view_mail.js

index 4152413684128738dcec1b63557d651dc650f713..ee5f3424964720c6c90759a6e866faa0432265f6 100644 (file)
@@ -185,6 +185,12 @@ void dav_put_message(struct http_transaction *h, struct ctdlsession *c, char *eu
        char *mailbcc = get_url_param(h, "mailbcc");    // Bcc:
        if (!mailbcc) mailbcc = "";
 
+       // If there are attachments, we have to merge them into the message text.
+       char *att = get_url_param(h, "att");
+       if (!att) {
+               syslog(LOG_DEBUG, "attachments: <%s>", att);            // FIXME write this
+       }
+
        // Mode 4 will give us metadata back after upload
        ctdl_printf(c, "ENT0 1|%s||4|%s||1|%s|%s|||%s|", mailto, subj, mailcc, mailbcc, wefw);
        ctdl_readline(c, buf, sizeof buf);
index 96e02b972e7a53b90b556155c293723140ac91cf..228e97aceb5f2e0b57f07f68049cfb852cc6f6a0 100644 (file)
@@ -89,10 +89,10 @@ function upload_file(file) {
                                + `&nbsp;`
                                + item["uploadfilename"] + " (" + item["contenttype"] + ", " + item["contentlength"] + " " + _("bytes") + ")";
                                document.getElementById("ctdl-upload_list").appendChild(new_upl);
-                       });
 
-                       // append it to the global list of uploads
-                       uploads.push(j_response);
+                               // append it to the global list of uploads
+                               uploads.push(item);
+                       });
                        document.getElementById("num_attachments").innerHTML = uploads.length;
                }
                else if (xhr.readyState == 4 && xhr.status != 200) {
index 8e31a18cf5c67cfaf7f928b1be175e64305b4a03..3071496e8612ae816dc420dfa93e8152a2186e3f 100644 (file)
@@ -525,7 +525,7 @@ function mail_compose(is_quoted, references, quoted_msgnum, m_to, m_cc, m_subjec
                document.getElementById("ctdl-compose-cc-field").style.display = "block";
        }
 
-       activate_uploads("ctdl-editor-body");
+       activate_uploads("ctdl-compose-mail");
 }
 
 // Called when the user clicks the button to make the hidden "CC" and "BCC" lines appear.
@@ -561,6 +561,15 @@ function mail_send_message() {
                + "&mailcc="    + msm_field("ctdl-compose-cc-field", ",")                       // Cc: (if present)
                + "&mailbcc="   + msm_field("ctdl-compose-bcc-field", ",")                      // Bcc: (if present)
        ;
+       if (uploads.length > 0) {
+               url += "&att=";
+               for (let i=0; i<uploads.length; ++i) {
+                       url += uploads[i]["ref"];
+                       if (i != uploads.length - 1) {
+                               url += ",";
+                       }
+               }
+       }
        boundary = randomString();
        body_text =
                "--" + boundary + "\r\n"
@@ -587,6 +596,9 @@ function mail_send_message() {
                                        }
                                }
 
+                               // successfully saving a message means the attachments are now gone from the server.
+                               uploads = [];
+
                                // After saving the message, go back to the mailbox view.
                                gotoroom(current_room);