summaryrefslogtreecommitdiff
path: root/src/leap/mail/mail.py
diff options
context:
space:
mode:
authorCaio Carrara <ccarrara@thoughtworks.com>2016-04-13 16:12:09 -0300
committerKali Kaneko <kali@leap.se>2016-04-15 16:10:42 -0400
commitd8ee6357c518a17a243840e42aeeae948bc03b2f (patch)
treea178aee1d356140e866a71553d7198cfd4a2fb68 /src/leap/mail/mail.py
parentec7ccd73dd80b51c349fc6240d5bc2a7a556fbd4 (diff)
[bug] Adds user_id to Account
Previously Account used user id from the store, but this attribute is optional and None by default. This caused the collection_mapping to be unable to distinct between multiple users message collections. This chance adds a non optional user_id attribute to Account and use it to index the collection_mapping. - Resolves: https://github.com/pixelated/pixelated-user-agent/issues/674 - Releases: 0.4.0
Diffstat (limited to 'src/leap/mail/mail.py')
-rw-r--r--src/leap/mail/mail.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/leap/mail/mail.py b/src/leap/mail/mail.py
index c6e053c..d3659de 100644
--- a/src/leap/mail/mail.py
+++ b/src/leap/mail/mail.py
@@ -941,8 +941,9 @@ class Account(object):
# tree we can let it be an instance attribute.
_collection_mapping = defaultdict(weakref.WeakValueDictionary)
- def __init__(self, store, ready_cb=None):
+ def __init__(self, store, user_id, ready_cb=None):
self.store = store
+ self.user_id = user_id
self.adaptor = self.adaptor_class()
self.mbox_indexer = MailboxIndexer(self.store)
@@ -1077,7 +1078,7 @@ class Account(object):
:rtype: deferred
:return: a deferred that will fire with a MessageCollection
"""
- collection = self._collection_mapping[self.store.userid].get(
+ collection = self._collection_mapping[self.user_id].get(
name, None)
if collection:
return defer.succeed(collection)
@@ -1086,7 +1087,7 @@ class Account(object):
def get_collection_for_mailbox(mbox_wrapper):
collection = MessageCollection(
self.adaptor, self.store, self.mbox_indexer, mbox_wrapper)
- self._collection_mapping[self.store.userid][name] = collection
+ self._collection_mapping[self.user_id][name] = collection
return collection
d = self.adaptor.get_or_create_mbox(self.store, name)