From 9d1b50ebe709155a76885df0d1c3372bedd09a52 Mon Sep 17 00:00:00 2001 From: Romain Bignon Date: Sat, 25 Sep 2010 01:55:29 -0400 Subject: [PATCH] add profile information in mail signatures (fix regression) --- weboob/backends/aum/backend.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/weboob/backends/aum/backend.py b/weboob/backends/aum/backend.py index 9bdc6032..37d23676 100644 --- a/weboob/backends/aum/backend.py +++ b/weboob/backends/aum/backend.py @@ -97,7 +97,12 @@ class AuMBackend(BaseBackend, ICapMessages, ICapMessagesPost, ICapDating, ICapCh thread = Thread(contact.get_id()) yield thread - def get_thread(self, id): + def get_thread(self, id, profiles=None): + """ + Get a thread and its messages. + + The 'profiles' parameter is only used for internal calls. + """ thread = None if isinstance(id, Thread): thread = id @@ -116,6 +121,8 @@ class AuMBackend(BaseBackend, ICapMessages, ICapMessagesPost, ICapDating, ICapCh child = None msg = None slut = self._get_slut(id) + if not profiles: + profiles = {} for mail in mails: flags = 0 if mail.date > slut['lastmsg']: @@ -126,6 +133,10 @@ class AuMBackend(BaseBackend, ICapMessages, ICapMessagesPost, ICapDating, ICapCh else: flags |= Message.IS_ACCUSED + if not mail.profile_link in profiles: + profiles[mail.profile_link] = self.browser.get_profile(mail.profile_link) + mail.signature += u'\n%s' % profiles[mail.profile_link].get_profile_text() + msg = Message(thread=thread, id=mail.message_id, title=mail.title, @@ -152,12 +163,13 @@ class AuMBackend(BaseBackend, ICapMessages, ICapMessagesPost, ICapDating, ICapCh def iter_unread_messages(self, thread=None): try: + profiles = {} with self.browser: contacts = self.browser.get_threads_list() for contact in contacts: slut = self._get_slut(contact.get_id()) if contact.get_lastmsg_date() > slut['lastmsg']: - thread = self.get_thread(contact.get_id()) + thread = self.get_thread(contact.get_id(), profiles) for m in thread.iter_all_messages(): if m.flags & m.IS_UNREAD: yield m