Re: [Jmap] message copying and moving

Neil Jenkins <neilj@fastmailteam.com> Tue, 01 August 2017 03:38 UTC

Return-Path: <neilj@fastmailteam.com>
X-Original-To: jmap@ietfa.amsl.com
Delivered-To: jmap@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 0CDDF131CF9 for <jmap@ietfa.amsl.com>; Mon, 31 Jul 2017 20:38:39 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.72
X-Spam-Level:
X-Spam-Status: No, score=-2.72 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=fastmailteam.com header.b=Wv5Cqpd8; dkim=pass (2048-bit key) header.d=messagingengine.com header.b=a6KYh73r
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3CVXGLhpPqcm for <jmap@ietfa.amsl.com>; Mon, 31 Jul 2017 20:38:37 -0700 (PDT)
Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 2136D1317AD for <jmap@ietf.org>; Mon, 31 Jul 2017 20:38:36 -0700 (PDT)
Received: from betaweb1.internal (betaweb1.nyi.internal [10.202.2.10]) by mailout.nyi.internal (Postfix) with ESMTP id 188B520B69 for <jmap@ietf.org>; Mon, 31 Jul 2017 23:38:36 -0400 (EDT)
Received: from betaweb1 ([::ffff:10.202.2.10]) by betaweb1.internal (MEProxy); Mon, 31 Jul 2017 23:38:36 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= fastmailteam.com; h=content-transfer-encoding:content-type:date :from:in-reply-to:message-id:mime-version:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=ymfRLgI8UEI3T3H29 Xfv9H/a6hBJi1x79y3bBeuR01o=; b=Wv5Cqpd8dxqrCQBow53jXfoIynMeNtibB RWFnUqFhkLb4KyMEEkJNn1gHFjM3Nh/RMFE12n4KIxtTSBhQjvF8UpYol0qcpTFs F9WgW/+tqr9wxTqkHPHFNElreUks4AuqUgJSraO8M2/k/L2gDRVK4WlEnU/ggAXx O0GBLznW/KgVcC1+4ym1cJBjIwytvH/H1DQRGn2qI70PUMaqjqratFPOED4LDZkN IpSRpf/DW6HbVgW9Fx8ftyzWje6J6HYHBys+MEuhMrkHYsp0xWq3JWwXEC2a+VRn TG0hIDxUCdVWARNzbDElqM50/UGe4h0kLg7vdH5zYeFIv394Hdifw==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=ymfRLg I8UEI3T3H29Xfv9H/a6hBJi1x79y3bBeuR01o=; b=a6KYh73rRokU4SiRG6dnYY 5UhAa76r3YoFPwL2/SkJGf9Ajchs0LN22aqUSomkFiGTJOQ/HVftWw8c6TveBlnt vmTUVD1SUdbNqbvZ7Du9JMnLgUrX7bhaAG5EJhnvNFEyBDPcPHKpvGROhWA632uY 6TxRxlH5bepsU4XaSh1msFU04TTYU6GBv5EopCoQctpyjKv/++oPhDol0A2lZ2PO s927MdRxysgyHdI/D3Y5FeJHIznXriyAVsvFtPC0o69i509htYhOrKjyMldzO9mk 9u0MP1iRFdbKKPGDBbo8qYpnH08IBN/XRQqvYNjnX1ZMMF2llCWnZ+rXnriO9tXw ==
X-ME-Sender: <xms:u_d_WWRiDx6fB3SJ4qfjbP-iXfWNi2grSQYZGuq7yn3KX2n02hsODA>
Received: by mailuser.nyi.internal (Postfix, from userid 99) id D293DE22C2; Mon, 31 Jul 2017 23:38:35 -0400 (EDT)
Message-Id: <1501558715.3114940.1059090760.3D266D17@webmail.messagingengine.com>
From: Neil Jenkins <neilj@fastmailteam.com>
To: IETF JMAP Mailing List <jmap@ietf.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Type: multipart/alternative; boundary="_----------=_150155871531149403"
X-Mailer: MessagingEngine.com Webmail Interface - ajax-4aa8b2c4
In-Reply-To: <20170731134452.GB1402@meili>
References: <20170731134452.GB1402@meili>
Date: Tue, 01 Aug 2017 13:38:35 +1000
Archived-At: <https://mailarchive.ietf.org/arch/msg/jmap/tZ5Rh5iK0TBulV2iNoV_BfjfDbI>
Subject: Re: [Jmap] message copying and moving
X-BeenThere: jmap@ietf.org
X-Mailman-Version: 2.1.22
Precedence: list
List-Id: JSON Message Access Protocol <jmap.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/jmap>, <mailto:jmap-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/jmap/>
List-Post: <mailto:jmap@ietf.org>
List-Help: <mailto:jmap-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/jmap>, <mailto:jmap-request@ietf.org?subject=subscribe>
X-List-Received-Date: Tue, 01 Aug 2017 03:38:39 -0000

On Mon, 31 Jul 2017, at 11:44 PM, Josef 'Jeff' Sipek wrote:
> There appear to be three different ways in jmap mail to "copy" an email> from one mailbox to another.  That is, duplicating a message but leaving the> original in place (like COPY in IMAP).  They are:
> 
> 1. setMessages on an existing message's messageId with destination
>   mailbox's mailboxId added to mailboxIds

Not exactly. JMAP is currently designed so it's optional for servers to support the concept of a single message appearing in multiple mailboxes ("labels" rather than "folders"). This is designated by the mustBeOnlyMailbox property on the mailbox objects, but I think we should re-evaluate this. It seems likely to be the same for every mailbox in the account. A simpler (and better IMO) method would be to add a maxMailboxesPerMessage property to the capabilities given for an account, which would be 1 for simple IMAP proxies and >1 for more sophisticated servers.
> 2. importMessages with blobId referencing an existing message's blobId> 3. copyMessages with fromAccountId == toAccountId

While not intended for this purpose, yes these could be used to copy messages. However, 
> The first method creates a "hardlink" copy - any keyword changes will be> shared by all the copies of the message.
> The second method creates a total duplicate of the message and its
> metadata.

Looking at the spec, this needs to be clarified. However I believe we definitely need to make it so that (2)/(3) MAY return an existing message id if the content is the same as an existing message (or alternatively an error; either works for me). For example, the Cyrus implementation of JMAP uses a secure hash of the message content to generate the message id, so you cannot have two identical messages within the same user with different message ids.
> When it comes to moving mails from one mailbox to another (like MOVE or> COPY+EXPUNGE in IMAP) the situation is equally complex.  The options are:> 
> 1. setMessages on an existing message's messageId with destination
>   mailbox's mailboxId replacing the source mailbox's mailboxId in
>   mailboxIds

Yes, this is the expected way clients would do it.

> 2. importMessages with blobId referencing an existing message's blobId,>   followed by a setMessages on the original message but removing the
>   source mailbox's mailboxId from mailboxIds
> 3. copyMessages with fromAccountId == toAccountId, followed by
> setMessages on the original message but removing the source mailbox's mailboxId from mailboxIds
Again, what this does depends on whether the server supports multiple copies of the same message content with different ids.
So I think the following would help:
 * Remove mustBeOnlyMailbox property from individual mailbox objects and add a capability for maxMailboxesPerMessage instead. Add an appropriate error for setMailboxes if you try to go over this limit.
 * Allow servers to return an error instead of copy/import if the message already exists, rather than creating a duplicate with separate metadata. (But if it does succeed, then it MUST have separate metadata, be a new message id). 
A lot of this depends on how much flexibility we want to give servers for making it easier to proxy/build-on IMAP. Every extra option does make it harder for clients. I'd be happy to forbid having two copies of the same message in the same user if people think this is reasonable. So something like:
 * maxMailboxesPerMessage MUST be at least 10 (or greater)
 * copyMessages fromAccount MUST be different to toAccount
 * (import|copy)Messages MUST reject attempts to import/copy a message whose content already exists.
Or similar.

On Tue, 1 Aug 2017, at 12:54 AM, Ted Lemon wrote:
> it's unlikely that the user ever wants a copy when a link is possible.
Agreed. The current spec was designed for allowing the possibility that a link is not possible. But maybe we can be more prescriptive about what servers must support.
Neil.