plugin XEP-0280: priority and "sent" fixes:

- carbon prioriy must be bigger than ones of encryption plugins, because the carbon copied messages must be unwrapped to be decrypted, this patch fixes it
- "sent" carbon elements was only stored and notified to frontends, it is now unwrapped and injected in normal traffic, this way other plugin can manage it, in particular encrypted elements can be decrypted
This commit is contained in:
Goffi 2019-02-28 18:57:06 +01:00
commit fc007dae38

View file

@ -75,7 +75,7 @@ class XEP_0280(object):
log.info(_("Plugin XEP_0280 initialization"))
self.host = host
host.memory.updateParams(self.params)
host.trigger.add("MessageReceived", self.messageReceivedTrigger, priority=1000)
host.trigger.add("MessageReceived", self.messageReceivedTrigger, priority=200000)
def getHandler(self, client):
return XEP_0280_handler()
@ -138,30 +138,26 @@ class XEP_0280(object):
return
forwarded_elt = next(carbons_elt.elements(C.NS_FORWARD, "forwarded"))
cc_message_elt = next(forwarded_elt.elements(C.NS_CLIENT, "message"))
# we replace the wrapping message with the CCed one
# and continue the normal behaviour
if carbons_elt.name == "received":
# on receive we replace the wrapping message with the CCed one
# and continue the normal behaviour
message_elt["from"] = cc_message_elt["from"]
del message_elt.children[:]
for c in cc_message_elt.children:
message_elt.addChild(c)
return True
elif carbons_elt.name == "sent":
# on sent we parse the message and just add it to history
# and send it to frontends (without normal sending treatments)
mess_data = client.messageProt.parseMessage(cc_message_elt)
if not mess_data["message"] and not mess_data["subject"]:
return False
client.messageAddToHistory(mess_data)
client.messageSendToBridge(mess_data)
message_elt["to"] = cc_message_elt["to"]
else:
log.warning(
u"invalid message carbons received:\n{xml}".format(
xml=message_elt.toXml()
)
)
return False
return False
del message_elt.children[:]
for c in cc_message_elt.children:
message_elt.addChild(c)
return True
class XEP_0280_handler(XMPPHandler):
implements(iwokkel.IDisco)