upload.c: skeleton code for load_attachments_from_message()
authorArt Cancro <ajc@citadel.org>
Wed, 13 Dec 2023 22:52:18 +0000 (17:52 -0500)
committerArt Cancro <ajc@citadel.org>
Wed, 13 Dec 2023 22:52:18 +0000 (17:52 -0500)
webcit-ng/api.txt
webcit-ng/server/upload.c

index f148f53c5e03fa790ff0b5f87cf0f08f2f30fd14..378b5b59a252040d870726ec05ed4fce041270c9 100644 (file)
@@ -44,5 +44,7 @@ POST            /ctdl/p                            Handler for uploading attachm
                                                        "contentlength" : 56222252
                                                      }
                                                    ]
-GET             /ctdl/p/<id>                       Fetch a specific item that was uploaded
-DELETE          /ctdl/p/<id>                       Delete a specific item that was uploaded
+GET             /ctdl/p/<ref>                      Fetch a specific item that was uploaded ("ref" was returned by the upload)
+DELETE          /ctdl/p/<ref>                      Delete a specific item that was uploaded ("ref" was returned by the upload)
+GET             /ctdl/p/<msgnum>                   Load the attachments from message <msgnum> in, as if they were uploaded
+                                                   by the client.  Returns the same JSON as "POST /ctdl/p".
index 6854acf8ae726f4fdb6e3a7ab9421e7f1faa2766..3c40d9fed412857f6fe863679be5caeeda8cb661 100644 (file)
@@ -146,12 +146,28 @@ struct uploaded_file pop_upload(char *id) {
 }
 
 
+// Load the attachments from an existing message.  This is typically used when forwarding a message,
+// so the attachments don't have to be sent out to the browser and back.
+void load_attachments_from_message(struct http_transaction *h, struct ctdlsession *c, char *name) {
+       syslog(LOG_DEBUG, "\033[33mload_attachments_from_message: method is \033[35m%s\033[33m, name is \033[33m%s\033[0m", h->method, name);
+       do_405(h);
+}
+
+
 // Handle operations on a specific upload
 void specific_upload(struct http_transaction *h, struct ctdlsession *c, char *name) {
        int i;
        struct uploaded_file *u;
        struct uploaded_file this_one;
 
+       syslog(LOG_DEBUG, "\033[33mspecific_upload: method is \033[35m%s\033[33m, name is \033[33m%s\033[0m", h->method, name);
+
+       // GET of a msgnum is a request to load the attachments from an existing message.
+       if ( (!strcasecmp(h->method, "GET")) && (atol(name) > 0) ) {
+               load_attachments_from_message(h, c, name);
+               return;
+       }
+
        if (upload_list == NULL) {
                do_404(h);
                return;