diff sat/plugins/plugin_sec_otr.py @ 3795:967a8e109cda

core (xmpp): adapt message workflow to components: message workflow were not used for components so far. This patch activate it, normalise namespace to the client one to simplify parsing, and use SatXMPPComponent.sendHistory and SatXMPPComponent.receiveHistory to indicate if a component should store sent and received message in database (they both default to False). OTR plugin is deactivated for components. rel 367
author Goffi <goffi@goffi.org>
date Fri, 17 Jun 2022 14:15:23 +0200
parents be6d91572633
children 524856bd7b19
line wrap: on
line diff
--- a/sat/plugins/plugin_sec_otr.py	Fri Jun 17 14:15:23 2022 +0200
+++ b/sat/plugins/plugin_sec_otr.py	Fri Jun 17 14:15:23 2022 +0200
@@ -42,6 +42,7 @@
 PLUGIN_INFO = {
     C.PI_NAME: "OTR",
     C.PI_IMPORT_NAME: "OTR",
+    C.PI_MODES: [C.PLUG_MODE_CLIENT],
     C.PI_TYPE: "SEC",
     C.PI_PROTOCOLS: ["XEP-0364"],
     C.PI_DEPENDENCIES: ["XEP-0280", "XEP-0334"],
@@ -731,6 +732,8 @@
         return data
 
     def messageReceivedTrigger(self, client, message_elt, post_treat):
+        if client.is_component:
+            return True
         if message_elt.getAttribute("type") == C.MESS_TYPE_GROUPCHAT:
             # OTR is not possible in group chats
             return True
@@ -745,6 +748,8 @@
         return True
 
     def _sendMessageDataTrigger(self, client, mess_data):
+        if client.is_component:
+            return True
         encryption = mess_data.get(C.MESS_KEY_ENCRYPTION)
         if encryption is None or encryption['plugin'].namespace != NS_OTR:
             return
@@ -788,6 +793,8 @@
 
     def sendMessageTrigger(self, client, mess_data, pre_xml_treatments,
                            post_xml_treatments):
+        if client.is_component:
+            return True
         if mess_data["type"] == "groupchat":
             return True