diff options
author | Kali Kaneko (leap communications) <kali@leap.se> | 2017-04-27 15:20:24 +0200 |
---|---|---|
committer | Ruben Pollan <meskio@sindominio.net> | 2017-05-16 19:28:35 +0200 |
commit | c980cae46d101c0def23bf3398b65b2e0c614d2a (patch) | |
tree | 6e421dc1d1a65572ab621f564b281ed1ffe5a0f3 /src/leap/bitmask/mail/mail.py | |
parent | 401bf8067bf6eb1fd27477550a6edc0ab08647e4 (diff) |
[bug] fix notification for incoming mail with several listeners registered
When setting the listeners in the IMAP Folder, we avoid setting more
than one listener for the same imap mailbox (because in some situations
we were registering way too many listeners).
this was making the pixelated inbox registering the notification and
therefore the imap mailbox not being registered.
this MR also refactors the way pixelated is initialized, so that it
avoid creating a second Account instance. In this way, we make sure that
the pixelated mua and the imap server share the same collections for a
given mailbox, and therefore any of the two is able to get a
notification whenever the other adds a message to the mailbox.
- Resolves: #8846, #8798
Diffstat (limited to 'src/leap/bitmask/mail/mail.py')
-rw-r--r-- | src/leap/bitmask/mail/mail.py | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/leap/bitmask/mail/mail.py b/src/leap/bitmask/mail/mail.py index 8cc01e2..92435fd 100644 --- a/src/leap/bitmask/mail/mail.py +++ b/src/leap/bitmask/mail/mail.py @@ -970,6 +970,10 @@ class Account(object): return d def add_mailbox(self, name, creation_ts=None): + return self.adaptor.atomic.run( + self._add_mailbox, name, creation_ts=creation_ts) + + def _add_mailbox(self, name, creation_ts=None): if creation_ts is None: # by default, we pass an int value @@ -1004,6 +1008,10 @@ class Account(object): return d def delete_mailbox(self, name): + return self.adaptor.atomic.run( + self._delete_mailbox, name) + + def _delete_mailbox(self, name): def delete_uid_table_cb(wrapper): d = self.mbox_indexer.delete_table(wrapper.uuid) @@ -1017,6 +1025,10 @@ class Account(object): return d def rename_mailbox(self, oldname, newname): + return self.adaptor.atomic.run( + self._rename_mailbox, oldname, newname) + + def _rename_mailbox(self, oldname, newname): def _rename_mbox(wrapper): wrapper.mbox = newname @@ -1035,6 +1047,10 @@ class Account(object): :rtype: deferred :return: a deferred that will fire with a MessageCollection """ + return self.adaptor.atomic.run( + self._get_collection_by_mailbox, name) + + def _get_collection_by_mailbox(self, name): collection = self._collection_mapping[self.user_id].get( name, None) if collection: @@ -1056,8 +1072,7 @@ class Account(object): :rtype: MessageCollection """ # get a collection of docs by a list of doc_id - # get.docs(...) --> it should be a generator. does it behave in the - # threadpool? + # get.docs(...) --> it should be a generator raise NotImplementedError() def get_collection_by_tag(self, tag): |