From: Art Cancro Date: Wed, 11 Oct 2023 02:37:48 +0000 (-0400) Subject: upload: reduce attachment identifiers to 9 characters. X-Git-Tag: v997~122 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=18f1d6b9e7e27816d0ba7d455bcfd26c4c457c22 upload: reduce attachment identifiers to 9 characters. Also switched from a unicode X to a fontawesome rounded-X for the 'remove attachment' button. The unicode one was too big. --- diff --git a/webcit-ng/server/upload.c b/webcit-ng/server/upload.c index 110241c3c..101d78948 100644 --- a/webcit-ng/server/upload.c +++ b/webcit-ng/server/upload.c @@ -28,7 +28,13 @@ void upload_handler(char *name, char *filename, char *partnum, char *disp, syslog(LOG_DEBUG, " id: %s", cbid); struct uploaded_file u; - generate_uuid(u.id); + + // create a random ID for the attachment + for (int i=0; iid, id)) { + ret = *u; + array_delete_element_at(upload_list, i); + i = array_len(upload_list) + 1; // Go out of scope; we're done here + } + } + pthread_mutex_unlock(&upload_list_mutex); + + return(ret); // ret will be all-zeroes if we didn't find it +} + + // Handle operations on a specific upload void specific_upload(struct http_transaction *h, struct ctdlsession *c, char *name) { int i; diff --git a/webcit-ng/server/webcit.h b/webcit-ng/server/webcit.h index 64368b0e5..0b415ade0 100644 --- a/webcit-ng/server/webcit.h +++ b/webcit-ng/server/webcit.h @@ -96,7 +96,7 @@ struct ctdlsession { }; struct uploaded_file { // things that have been uploaded to the server (such as email attachments) - char id[64]; + char id[10]; char filename[256]; char content_type[256]; long length; diff --git a/webcit-ng/static/js/upload.js b/webcit-ng/static/js/upload.js index 28c374edb..96e02b972 100644 --- a/webcit-ng/static/js/upload.js +++ b/webcit-ng/static/js/upload.js @@ -85,7 +85,8 @@ function upload_file(file) { j_response.forEach((item) => { let new_upl = document.createElement("li"); // item["ref"] is what we need - new_upl.innerHTML = `❌` + new_upl.innerHTML = `` + + ` ` + item["uploadfilename"] + " (" + item["contenttype"] + ", " + item["contentlength"] + " " + _("bytes") + ")"; document.getElementById("ctdl-upload_list").appendChild(new_upl); });