From d8ee6357c518a17a243840e42aeeae948bc03b2f Mon Sep 17 00:00:00 2001 From: Caio Carrara Date: Wed, 13 Apr 2016 16:12:09 -0300 Subject: [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 --- src/leap/mail/mail.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/leap/mail/mail.py') 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) -- cgit v1.2.3