From 9f5885fc7fc725e8541bf2b0cd60527d3b96b87e Mon Sep 17 00:00:00 2001 From: Bruno Wagner Date: Wed, 16 Sep 2015 17:34:20 -0300 Subject: Moved account to after sync function #458 Imap account creation was firing post sync hooks and that was trying to use the mailboxes that were not synced yet. Just moved that for the after sync together with the incoming mail fetcher --- service/pixelated/bitmask_libraries/session.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'service/pixelated/bitmask_libraries') diff --git a/service/pixelated/bitmask_libraries/session.py b/service/pixelated/bitmask_libraries/session.py index ca3c80ff..7abe2a63 100644 --- a/service/pixelated/bitmask_libraries/session.py +++ b/service/pixelated/bitmask_libraries/session.py @@ -55,7 +55,7 @@ class LeapSession(object): - ``incoming_mail_fetcher`` Background job for fetching incoming mails from LEAP server (LeapIncomingMail) """ - def __init__(self, provider, user_auth, mail_store, soledad_session, nicknym, soledad_account, smtp): + def __init__(self, provider, user_auth, mail_store, soledad_session, nicknym, smtp): self.smtp = smtp self.config = provider.config self.provider = provider @@ -63,15 +63,17 @@ class LeapSession(object): self.mail_store = mail_store self.soledad_session = soledad_session self.nicknym = nicknym - self.account = soledad_account @defer.inlineCallbacks def initial_sync(self): yield self.sync() yield self.after_first_sync() + defer.returnValue(self) + @defer.inlineCallbacks def after_first_sync(self): yield self.nicknym.generate_openpgp_key() + self.account = self._create_account(self.account_email, self.soledad_session) self.incoming_mail_fetcher = yield self._create_incoming_mail_fetcher( self.nicknym, self.soledad_session, @@ -79,6 +81,10 @@ class LeapSession(object): self.account_email()) reactor.callFromThread(self.incoming_mail_fetcher.startService) + def _create_account(self, user_mail, soledad_session): + account = IMAPAccount(user_mail, soledad_session.soledad) + return account + def account_email(self): name = self.user_auth.username return self.provider.address_for(name) @@ -131,11 +137,10 @@ class LeapSessionFactory(object): mail_store = LeapMailStore(soledad.soledad) nicknym = self._create_nicknym(account_email, auth.token, auth.uuid, soledad) - account = self._create_account(account_email, soledad) smtp = LeapSmtp(self._provider, auth, nicknym.keymanager) - return LeapSession(self._provider, auth, mail_store, soledad, nicknym, account, smtp) + return LeapSession(self._provider, auth, mail_store, soledad, nicknym, smtp) def _lookup_session(self, key): global SESSIONS @@ -163,8 +168,5 @@ class LeapSessionFactory(object): def _create_nicknym(self, email_address, token, uuid, soledad_session): return NickNym(self._provider, self._config, soledad_session, email_address, token, uuid) - def _create_account(self, user_mail, soledad_session): - account = IMAPAccount(user_mail, soledad_session.soledad) - return account # memstore = MemoryStore(permanent_store=SoledadStore(soledad_session.soledad)) # return SoledadBackedAccount(uuid, soledad_session.soledad, memstore) -- cgit v1.2.3