comparison sat/core/xmpp.py @ 2994:94708a7d3ecf

core, plugin XEP-0045: fixed message type autodetection + ENTITY_TYPE_MUC constant: an old hardcoded value was used in several places to detect if an entity is a MUC, but this value was not valid anymore. This has been fixed, and ENTITY_TYPE_MUC constant is now used instead. This fixes message type autodetection for "groupchat" messages. fixes 300
author Goffi <goffi@goffi.org>
date Tue, 09 Jul 2019 09:06:45 +0200
parents 1d92ad95185f
children ab2696e34d29
comparison
equal deleted inserted replaced
2993:d58dccd9e4b4 2994:94708a7d3ecf
564 data["type"] = C.MESS_TYPE_NORMAL 564 data["type"] = C.MESS_TYPE_NORMAL
565 elif not data["to"].resource: # if to JID has a resource, 565 elif not data["to"].resource: # if to JID has a resource,
566 # the type is not 'groupchat' 566 # the type is not 'groupchat'
567 # we may have a groupchat message, we check if the we know this jid 567 # we may have a groupchat message, we check if the we know this jid
568 try: 568 try:
569 entity_type = self.host_app.memory.getEntityData( 569 entity_type = self.host_app.memory.getEntityDatum(
570 data["to"], ["type"], self.profile 570 data["to"], C.ENTITY_TYPE, self.profile
571 )["type"] 571 )
572 # FIXME: should entity_type manage resources ? 572 # FIXME: should entity_type manage resources ?
573 except (exceptions.UnknownEntityError, KeyError): 573 except (exceptions.UnknownEntityError, KeyError):
574 entity_type = "contact" 574 entity_type = "contact"
575 575
576 if entity_type == "chatroom": 576 if entity_type == C.ENTITY_TYPE_MUC:
577 data["type"] = C.MESS_TYPE_GROUPCHAT 577 data["type"] = C.MESS_TYPE_GROUPCHAT
578 else: 578 else:
579 data["type"] = C.MESS_TYPE_CHAT 579 data["type"] = C.MESS_TYPE_CHAT
580 else: 580 else:
581 data["type"] == C.MESS_TYPE_CHAT 581 data["type"] == C.MESS_TYPE_CHAT