diff sat/memory/encryption.py @ 3171:d073d82d9044

core (memory/encryption): new "isEncrypted" method to check if encrypted flag is set in message data
author Goffi <goffi@goffi.org>
date Tue, 18 Feb 2020 18:13:18 +0100
parents 559a625a236b
children 826bca181226
line wrap: on
line diff
--- a/sat/memory/encryption.py	Tue Feb 18 18:13:17 2020 +0100
+++ b/sat/memory/encryption.py	Tue Feb 18 18:13:18 2020 +0100
@@ -430,17 +430,26 @@
     def markAsEncrypted(self, mess_data):
         """Helper method to mark a message as having been e2e encrypted.
 
-        This should be used in the post_treat workflow of MessageReceived trigger of
+        This should be used in the post_treat workflow of messageReceived trigger of
         the plugin
         @param mess_data(dict): message data as used in post treat workflow
         """
         mess_data[C.MESS_KEY_ENCRYPTED] = True
         return mess_data
 
+    def isEncrypted(self, mess_data):
+        """Helper method to check if a message has the e2e encrypted flag
+
+        @param mess_data(dict): message data
+        @return (bool): True if the encrypted flag is present
+        """
+        return mess_data.get(C.MESS_KEY_ENCRYPTED, False)
+
+
     def markAsTrusted(self, mess_data):
         """Helper methor to mark a message as sent from a trusted entity.
 
-        This should be used in the post_treat workflow of MessageReceived trigger of
+        This should be used in the post_treat workflow of messageReceived trigger of
         the plugin
         @param mess_data(dict): message data as used in post treat workflow
         """
@@ -450,7 +459,7 @@
     def markAsUntrusted(self, mess_data):
         """Helper methor to mark a message as sent from an untrusted entity.
 
-        This should be used in the post_treat workflow of MessageReceived trigger of
+        This should be used in the post_treat workflow of messageReceived trigger of
         the plugin
         @param mess_data(dict): message data as used in post treat workflow
         """