component AP gateway: fix wrong exception + use of mb_data["xml"] when it may be absent

This commit is contained in:
Goffi 2022-07-14 12:55:30 +02:00
commit e73d4ebeff

View file

@ -1404,7 +1404,7 @@ class APGateway:
Can be either an activity of an object
@return: AP Item's Object and microblog data
@raise exceptions.DataError: something is invalid in the AP item
@raise NotImplemented: some AP data is not handled yet
@raise NotImplementedError: some AP data is not handled yet
@raise error.StanzaError: error while contacting the AP server
"""
is_activity = self.isActivity(ap_item)
@ -1751,14 +1751,14 @@ class APGateway:
if client != self.client:
return mess_data
if mess_data["type"] not in ("chat", "normal"):
log.warning(f"ignoring message with unexpected type: {mess_data['xml'].toXml()}")
log.warning(f"ignoring message with unexpected type: {mess_data}")
return mess_data
if not self.isLocal(mess_data["from"]):
log.warning(f"ignoring non local message: {mess_data['xml'].toXml()}")
log.warning(f"ignoring non local message: {mess_data}")
return mess_data
if not mess_data["to"].user:
log.warning(
f"ignoring message addressed to gateway itself: {mess_data['xml'].toXml()}"
f"ignoring message addressed to gateway itself: {mess_data}"
)
return mess_data
@ -1967,7 +1967,7 @@ class APGateway:
# we don't have a comment node set for this item
from sat.tools.xml_tools import ppElt
log.info(f"{ppElt(parent_item_elt.toXml())}")
raise NotImplemented()
raise NotImplementedError()
else:
__, item_elt = await self.apItem2MbDataAndElt(ap_item)
await self._p.publish(client, comment_service, comment_node, [item_elt])