summaryrefslogtreecommitdiff
path: root/mail/src
diff options
context:
space:
mode:
Diffstat (limited to 'mail/src')
-rw-r--r--mail/src/leap/mail/imap/account.py2
-rw-r--r--mail/src/leap/mail/mail.py7
-rw-r--r--mail/src/leap/mail/smtp/bounces.py3
-rw-r--r--mail/src/leap/mail/tests/test_mail.py14
4 files changed, 14 insertions, 12 deletions
diff --git a/mail/src/leap/mail/imap/account.py b/mail/src/leap/mail/imap/account.py
index 2f9ed1d..0b8e019 100644
--- a/mail/src/leap/mail/imap/account.py
+++ b/mail/src/leap/mail/imap/account.py
@@ -88,7 +88,7 @@ class IMAPAccount(object):
# about user_id, only the client backend.
self.user_id = user_id
- self.account = Account(store, ready_cb=lambda: d.callback(self))
+ self.account = Account(store, user_id, ready_cb=lambda: d.callback(self))
def end_session(self):
"""
diff --git a/mail/src/leap/mail/mail.py b/mail/src/leap/mail/mail.py
index c6e053c..d3659de 100644
--- a/mail/src/leap/mail/mail.py
+++ b/mail/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)
diff --git a/mail/src/leap/mail/smtp/bounces.py b/mail/src/leap/mail/smtp/bounces.py
index 64f2dd7..7a4674b 100644
--- a/mail/src/leap/mail/smtp/bounces.py
+++ b/mail/src/leap/mail/smtp/bounces.py
@@ -83,7 +83,8 @@ class Bouncer(object):
def bouncerFactory(soledad):
- acc = Account(soledad)
+ user_id = soledad.uuid
+ acc = Account(soledad, user_id)
d = acc.callWhenReady(lambda _: acc.get_collection_by_mailbox(INBOX_NAME))
d.addCallback(lambda inbox: Bouncer(inbox))
return d
diff --git a/mail/src/leap/mail/tests/test_mail.py b/mail/src/leap/mail/tests/test_mail.py
index 9f40ffb..aca406f 100644
--- a/mail/src/leap/mail/tests/test_mail.py
+++ b/mail/src/leap/mail/tests/test_mail.py
@@ -317,12 +317,12 @@ class AccountTestCase(SoledadTestMixin):
"""
Tests for the Account class.
"""
- def get_account(self):
+ def get_account(self, user_id):
store = self._soledad
- return Account(store)
+ return Account(store, user_id)
def test_add_mailbox(self):
- acc = self.get_account()
+ acc = self.get_account('some_user_id')
d = acc.callWhenReady(lambda _: acc.add_mailbox("TestMailbox"))
d.addCallback(lambda _: acc.list_all_mailbox_names())
d.addCallback(self._test_add_mailbox_cb)
@@ -333,7 +333,7 @@ class AccountTestCase(SoledadTestMixin):
self.assertItemsEqual(mboxes, expected)
def test_delete_mailbox(self):
- acc = self.get_account()
+ acc = self.get_account('some_user_id')
d = acc.callWhenReady(lambda _: acc.delete_mailbox("Inbox"))
d.addCallback(lambda _: acc.list_all_mailbox_names())
d.addCallback(self._test_delete_mailbox_cb)
@@ -344,7 +344,7 @@ class AccountTestCase(SoledadTestMixin):
self.assertItemsEqual(mboxes, expected)
def test_rename_mailbox(self):
- acc = self.get_account()
+ acc = self.get_account('some_user_id')
d = acc.callWhenReady(lambda _: acc.add_mailbox("OriginalMailbox"))
d.addCallback(lambda _: acc.rename_mailbox(
"OriginalMailbox", "RenamedMailbox"))
@@ -357,7 +357,7 @@ class AccountTestCase(SoledadTestMixin):
self.assertItemsEqual(mboxes, expected)
def test_get_all_mailboxes(self):
- acc = self.get_account()
+ acc = self.get_account('some_user_id')
d = acc.callWhenReady(lambda _: acc.add_mailbox("OneMailbox"))
d.addCallback(lambda _: acc.add_mailbox("TwoMailbox"))
d.addCallback(lambda _: acc.add_mailbox("ThreeMailbox"))
@@ -374,7 +374,7 @@ class AccountTestCase(SoledadTestMixin):
self.assertItemsEqual(names, expected)
def test_get_collection_by_mailbox(self):
- acc = self.get_account()
+ acc = self.get_account('some_user_id')
d = acc.callWhenReady(lambda _: acc.get_collection_by_mailbox("INBOX"))
d.addCallback(self._test_get_collection_by_mailbox_cb)
return d