diff options
author | Kali Kaneko <kali@leap.se> | 2015-01-26 23:41:52 -0400 |
---|---|---|
committer | Kali Kaneko <kali@leap.se> | 2015-02-11 14:05:44 -0400 |
commit | 8b7485bf81e2e46561dad26895c27cc1d0359e70 (patch) | |
tree | f889f6f597ba0bfb056c4c1d42706a4de26dc41f /mail/src/leap/mail/adaptors/soledad.py | |
parent | 1cc6f2198f38e1f4b53171056ec67aa114634f35 (diff) |
save drafts: search by msg-id
Diffstat (limited to 'mail/src/leap/mail/adaptors/soledad.py')
-rw-r--r-- | mail/src/leap/mail/adaptors/soledad.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/mail/src/leap/mail/adaptors/soledad.py b/mail/src/leap/mail/adaptors/soledad.py index 542ad949..4dc02a11 100644 --- a/mail/src/leap/mail/adaptors/soledad.py +++ b/mail/src/leap/mail/adaptors/soledad.py @@ -966,6 +966,30 @@ class SoledadMailAdaptor(SoledadIndexMixin): d.addErrback(self._errback) return d + # search api + + def get_mdoc_id_from_msgid(self, store, mbox_uuid, msgid): + """ + Get the UID for a message with the passed msgid (the one in the headers + msg-id). + This is used by the MUA to retrieve the recently saved draft. + """ + type_ = HeaderDocWrapper.model.type_ + uuid = mbox_uuid.replace('-', '_') + + msgid_index = indexes.TYPE_MSGID_IDX + + def get_mdoc_id(hdoc): + if not hdoc: + return None + hdoc = hdoc[0] + mdoc_id = hdoc.doc_id.replace("H-", "M-%s-" % uuid) + return mdoc_id + + d = store.get_from_index(msgid_index, type_, msgid) + d.addCallback(get_mdoc_id) + return d + # Mailbox handling def get_or_create_mbox(self, store, name): |