Re: [Imap-protocol] COPYUID message order

Brandon Long <[email protected]> Fri, 22 May 2015 17:17:52 -0700
Newsgroups gmane.mail.imap.general
Message-ID <CABa8R6tpd-2GPoSTX0_d8wnROvQpm4_zmMxconJDPPud3NNdww@mail.gmail.com>
--===============1521088630325087554==
Content-Type: multipart/alternative; boundary=001a11c30bf02260e00516b4b573

--001a11c30bf02260e00516b4b573
Content-Type: text/plain; charset=UTF-8

At least for Gmail, we always re-order the given set into sequence order
(which is the same as uid order) before doing any operation.  So, the
source UIDs in COPYUID are in the order in which they were copied.

Since a COPY in Gmail is the equivalent of adding a label to a message, the
message may already have that label, so it may already be in the recipient
mailbox.  We always return the destination UIDs in the order which matches
the source UID order, so in your example, source UID 1 is destination UID
2, and source UID 2 is destination UID 1.

When APPEND'ing a duplicate message, we update the UID assigned to the
original to be the newest UID in the mailbox (and that's returned with
APPENDUID), since we found clients typically assumed that was the case and
could get confused.

We could have done this with COPY, I guess, but we didn't see any client
issues in testing, so we left it this way since the performance is better.

Brandon

On Fri, May 22, 2015 at 4:46 PM, Bill Shannon <[email protected]>
wrote:

> I'm unclear on the requirements around the COPY command and the COPYUID
> response code.
>
> Is there any guarantee that the order of messages in the COPY command is
> the order they'll appear in the destination mailbox?  Or are they
> allowed to appear in any arbitrary order in the destination mailbox?
> (After any existing messages, of course.)
>
> RFC 4315 says of the COPYUID response:
>
>       The source UID set is in the order the message(s) were copied; the
>       destination UID set corresponds to the source UID set and is in
>       the same order.
>
> Exactly what order is that?  Is it the order in which the messages were
> mentioned in the COPY command?  Is it the order they actually appear in
> the destination mailbox (assuming it can be different)?  Or is it in
> some other undefined order?
>
> With Gmail I'm getting
>
> A1 COPY 1:2 dest
> A1 OK [COPYUID 123456 1:2 2,1]
>
> and
>
> A1 COPY 2,1 dest
> A1 OK [COPYUID 123456 1:2 2,1]
>
> The order of the source UIDs is unrelated to the order the messages
> are mentioned in the COPY command and unrelated to the order they
> appear in the destination mailbox.
>
> If I don't know the UIDs of the source messages, is there any way to
> determine which message was copied to which UID in the destination
> mailbox?
> _______________________________________________
> Imap-protocol mailing list
> [email protected]
> http://mailman13.u.washington.edu/mailman/listinfo/imap-protocol
>

--001a11c30bf02260e00516b4b573
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">At least for Gmail, we always re-order the given set into =
sequence order (which is the same as uid order) before doing any operation.=
=C2=A0 So, the source UIDs in COPYUID are in the order in which they were c=
opied.<div><br><div>Since a COPY in Gmail is the equivalent of adding a lab=
el to a message, the message may already have that label, so it may already=
 be in the recipient mailbox.=C2=A0 We always return the destination UIDs i=
n the order which matches the source UID order, so in your example, source =
UID 1 is destination UID 2, and source UID 2 is destination UID 1.</div><di=
v><br></div><div>When APPEND&#39;ing a duplicate message, we update the UID=
 assigned to the original to be the newest UID in the mailbox (and that&#39=
;s returned with APPENDUID), since we found clients typically assumed that =
was the case and could get confused.</div><div><br></div><div>We could have=
 done this with COPY, I guess, but we didn&#39;t see any client issues in t=
esting, so we left it this way since the performance is better.</div><div><=
br></div><div>Brandon</div></div></div><div class=3D"gmail_extra"><br><div =
class=3D"gmail_quote">On Fri, May 22, 2015 at 4:46 PM, Bill Shannon <span d=
ir=3D"ltr">&lt;<a href=3D"mailto:[email protected]" target=3D"_blank">=
[email protected]</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_=
quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1=
ex">I&#39;m unclear on the requirements around the COPY command and the COP=
YUID<br>
response code.<br>
<br>
Is there any guarantee that the order of messages in the COPY command is<br=
>
the order they&#39;ll appear in the destination mailbox?=C2=A0 Or are they<=
br>
allowed to appear in any arbitrary order in the destination mailbox?<br>
(After any existing messages, of course.)<br>
<br>
RFC 4315 says of the COPYUID response:<br>
<br>
=C2=A0 =C2=A0 =C2=A0 The source UID set is in the order the message(s) were=
 copied; the<br>
=C2=A0 =C2=A0 =C2=A0 destination UID set corresponds to the source UID set =
and is in<br>
=C2=A0 =C2=A0 =C2=A0 the same order.<br>
<br>
Exactly what order is that?=C2=A0 Is it the order in which the messages wer=
e<br>
mentioned in the COPY command?=C2=A0 Is it the order they actually appear i=
n<br>
the destination mailbox (assuming it can be different)?=C2=A0 Or is it in<b=
r>
some other undefined order?<br>
<br>
With Gmail I&#39;m getting<br>
<br>
A1 COPY 1:2 dest<br>
A1 OK [COPYUID 123456 1:2 2,1]<br>
<br>
and<br>
<br>
A1 COPY 2,1 dest<br>
A1 OK [COPYUID 123456 1:2 2,1]<br>
<br>
The order of the source UIDs is unrelated to the order the messages<br>
are mentioned in the COPY command and unrelated to the order they<br>
appear in the destination mailbox.<br>
<br>
If I don&#39;t know the UIDs of the source messages, is there any way to<br=
>
determine which message was copied to which UID in the destination<br>
mailbox?<br>
_______________________________________________<br>
Imap-protocol mailing list<br>
<a href=3D"mailto:[email protected]">[email protected]=
n.edu</a><br>
<a href=3D"http://mailman13.u.washington.edu/mailman/listinfo/imap-protocol=
" target=3D"_blank">http://mailman13.u.washington.edu/mailman/listinfo/imap=
-protocol</a><br>
</blockquote></div><br></div>

--001a11c30bf02260e00516b4b573--

--===============1521088630325087554==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Imap-protocol mailing list
[email protected]
http://mailman13.u.washington.edu/mailman/listinfo/imap-protocol
--===============1521088630325087554==--