fix getting accused status for messages
This commit is contained in:
parent
41827c4160
commit
776f5d3ac8
1 changed files with 41 additions and 44 deletions
|
|
@ -135,7 +135,7 @@ class AuMBackend(BaseBackend, ICapMessages, ICapMessagesPost, ICapDating, ICapCh
|
||||||
profiles[mail.profile_link] = self.browser.get_profile(mail.profile_link)
|
profiles[mail.profile_link] = self.browser.get_profile(mail.profile_link)
|
||||||
mail.signature += u'\n%s' % profiles[mail.profile_link].get_profile_text()
|
mail.signature += u'\n%s' % profiles[mail.profile_link].get_profile_text()
|
||||||
|
|
||||||
if mail.sender != my_name:
|
if mail.sender == my_name:
|
||||||
if mail.new:
|
if mail.new:
|
||||||
flags |= Message.IS_NOT_ACCUSED
|
flags |= Message.IS_NOT_ACCUSED
|
||||||
else:
|
else:
|
||||||
|
|
@ -235,49 +235,46 @@ class AuMBackend(BaseBackend, ICapMessages, ICapMessagesPost, ICapDating, ICapCh
|
||||||
self.browser.post_mail(message.thread.id, message.content)
|
self.browser.post_mail(message.thread.id, message.content)
|
||||||
|
|
||||||
def get_contact(self, contact):
|
def get_contact(self, contact):
|
||||||
try:
|
with self.browser:
|
||||||
with self.browser:
|
if isinstance(contact, Contact):
|
||||||
if isinstance(contact, Contact):
|
_id = contact.id
|
||||||
_id = contact.id
|
elif isinstance(contact, (int,long,str,unicode)):
|
||||||
elif isinstance(contact, (int,long,str,unicode)):
|
_id = contact
|
||||||
_id = contact
|
else:
|
||||||
else:
|
raise TypeError("The parameter 'contact' isn't a contact nor a int/long/str/unicode: %s" % contact)
|
||||||
raise TypeError("The parameter 'contact' isn't a contact nor a int/long/str/unicode: %s" % contact)
|
|
||||||
|
|
||||||
profile = self.browser.get_profile(_id)
|
profile = self.browser.get_profile(_id)
|
||||||
|
|
||||||
if profile.is_online():
|
if profile.is_online():
|
||||||
s = Contact.STATUS_ONLINE
|
s = Contact.STATUS_ONLINE
|
||||||
else:
|
else:
|
||||||
s = Contact.STATUS_OFFLINE
|
s = Contact.STATUS_OFFLINE
|
||||||
|
|
||||||
if isinstance(contact, Contact):
|
if isinstance(contact, Contact):
|
||||||
contact.id = _id
|
contact.id = _id
|
||||||
contact.name = profile.get_name()
|
contact.name = profile.get_name()
|
||||||
contact.status = s
|
contact.status = s
|
||||||
else:
|
else:
|
||||||
contact = Contact(_id, profile.get_name(), s)
|
contact = Contact(_id, profile.get_name(), s)
|
||||||
contact.status_msg = u'%s old' % profile.table['details']['old']
|
contact.status_msg = u'%s old' % profile.table['details']['old']
|
||||||
contact.summary = profile.description
|
contact.summary = profile.description
|
||||||
contact.avatar = None
|
contact.avatar = None
|
||||||
for photo in profile.photos:
|
for photo in profile.photos:
|
||||||
contact.set_photo(photo.split('/')[-1], url=photo, thumbnail_url=photo.replace('image', 'thumb1_'))
|
contact.set_photo(photo.split('/')[-1], url=photo, thumbnail_url=photo.replace('image', 'thumb1_'))
|
||||||
contact.profile = []
|
contact.profile = []
|
||||||
|
|
||||||
stats = ProfileNode('stats', 'Stats', [], flags=ProfileNode.HEAD|ProfileNode.SECTION)
|
stats = ProfileNode('stats', 'Stats', [], flags=ProfileNode.HEAD|ProfileNode.SECTION)
|
||||||
for label, value in profile.get_stats().iteritems():
|
for label, value in profile.get_stats().iteritems():
|
||||||
stats.value.append(ProfileNode(label, label.capitalize(), value))
|
stats.value.append(ProfileNode(label, label.capitalize(), value))
|
||||||
contact.profile.append(stats)
|
contact.profile.append(stats)
|
||||||
|
|
||||||
for section, d in profile.get_table().iteritems():
|
for section, d in profile.get_table().iteritems():
|
||||||
s = ProfileNode(section, section.capitalize(), [], flags=ProfileNode.SECTION)
|
s = ProfileNode(section, section.capitalize(), [], flags=ProfileNode.SECTION)
|
||||||
for key, value in d.iteritems():
|
for key, value in d.iteritems():
|
||||||
s.value.append(ProfileNode(key, key.capitalize(), value))
|
s.value.append(ProfileNode(key, key.capitalize(), value))
|
||||||
contact.profile.append(s)
|
contact.profile.append(s)
|
||||||
|
|
||||||
return contact
|
return contact
|
||||||
except BrowserUnavailable:
|
|
||||||
return None
|
|
||||||
|
|
||||||
def init_optimizations(self):
|
def init_optimizations(self):
|
||||||
self.OPTIM_PROFILE_WALKER = ProfilesWalker(self.weboob.scheduler, self.storage, self.browser)
|
self.OPTIM_PROFILE_WALKER = ProfilesWalker(self.weboob.scheduler, self.storage, self.browser)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue