Fix output of UID COPY operation
authorArt Cancro <ajc@citadel.org>
Tue, 18 Apr 2017 17:31:35 +0000 (13:31 -0400)
committerArt Cancro <ajc@citadel.org>
Tue, 18 Apr 2017 17:31:35 +0000 (13:31 -0400)
citadel/modules/imap/imap_misc.c

index e7940d1cb95d25e71bd957653a5893e097ca8e23..39ae34b82356cf43060f25a6462b698890979a55 100644 (file)
@@ -159,28 +159,25 @@ int imap_do_copy(const char *destination_folder) {
  * messages in our source room.  Since the Citadel system uses UID's that
  * are both globally unique and persistent across a room-to-room copy, we
  * can get this done quite easily.
- *
- * FIXME this is outputing WRONG !!!   See https://tools.ietf.org/html/rfc2359#section-4.3
  */
 void imap_output_copyuid_response(citimap *Imap) {
        int i;
-       int num_output = 0;
-  
+       StrBuf *MsgsCopied = NewStrBuf();
+
        for (i = 0; i < Imap->num_msgs; ++i) {
                if (Imap->flags[i] & IMAP_SELECTED) {
-                       ++num_output;
-                       if (num_output == 1) {
-                               IAPuts("[COPYUID ");
-                       }
-                       else if (num_output > 1) {
-                               IAPuts(",");
+                       if (StrLength(MsgsCopied) > 0) {
+                               StrBufAppendBufPlain(MsgsCopied, HKEY(","), 0);
                        }
-                       IAPrintf("%ld", Imap->msgids[i]);
+                       StrBufAppendPrintf(MsgsCopied, "%ld", Imap->msgids[i]);
                }
        }
-       if (num_output > 0) {
-               IAPuts("] ");
+
+       if (StrLength(MsgsCopied) > 0) {
+               IAPrintf("[COPYUID %ld %s %s] ", GLOBAL_UIDVALIDITY_VALUE, ChrPtr(MsgsCopied), ChrPtr(MsgsCopied));
        }
+
+       FreeStrBuf(&MsgsCopied);
 }