comparison sat_frontends/quick_frontend/quick_contact_list.py @ 2978:bad0b4280b77

quick frontends (contact list): ignore roster entities with a resource: cache uses bare entities, as a result when a jid with a resource is used in roster, it is not handled properly. As this case is rare and probably resulting from bugs in clients, entities with resources are ignored and a warning is logged when this happens. fix 306
author Goffi <goffi@goffi.org>
date Sun, 30 Jun 2019 15:52:27 +0200
parents 82d8243e6ad1
children 8990ed9aad31
comparison
equal deleted inserted replaced
2977:06f30ad8e110 2978:bad0b4280b77
20 """Contact List handling multi profiles at once, 20 """Contact List handling multi profiles at once,
21 should replace quick_contact_list module in the future""" 21 should replace quick_contact_list module in the future"""
22 22
23 from sat.core.i18n import _ 23 from sat.core.i18n import _
24 from sat.core.log import getLogger 24 from sat.core.log import getLogger
25
26 log = getLogger(__name__)
27 from sat.core import exceptions 25 from sat.core import exceptions
28 from sat_frontends.quick_frontend.quick_widgets import QuickWidget 26 from sat_frontends.quick_frontend.quick_widgets import QuickWidget
29 from sat_frontends.quick_frontend.constants import Const as C 27 from sat_frontends.quick_frontend.constants import Const as C
30 from sat_frontends.tools import jid 28 from sat_frontends.tools import jid
31 from collections import OrderedDict 29 from collections import OrderedDict
32 30
31 log = getLogger(__name__)
33 32
34 try: 33 try:
35 # FIXME: to be removed when an acceptable solution is here 34 # FIXME: to be removed when an acceptable solution is here
36 unicode("") # XXX: unicode doesn't exist in pyjamas 35 unicode("") # XXX: unicode doesn't exist in pyjamas
37 except (TypeError, AttributeError): # Error raised is not the same depending on 36 except (TypeError, AttributeError): # Error raised is not the same depending on
232 231
233 Called during initial contact list filling 232 Called during initial contact list filling
234 @param contacts(tuple): all contacts 233 @param contacts(tuple): all contacts
235 """ 234 """
236 for contact in contacts: 235 for contact in contacts:
236 entity = jid.JID(contact[0])
237 if entity.resource:
238 # we use entity's bare jid to cache data, so a resource here
239 # will cause troubles
240 log.warning(
241 "Roster entities with resources are not managed, ignoring {entity}"
242 .format(entity=entity))
243 continue
237 self.host.newContactHandler(*contact, profile=self.profile) 244 self.host.newContactHandler(*contact, profile=self.profile)
238 handler._contactsFilled(self.profile) 245 handler._contactsFilled(self.profile)
239 246
240 def _fill(self): 247 def _fill(self):
241 """Get all contacts from backend 248 """Get all contacts from backend