changeset 1174:bc811915a96a

plugin OTR: do not save in history the encrypted messages for skipped profiles
author souliane <souliane@mailoo.org>
date Sun, 07 Sep 2014 20:08:56 +0200
parents cae023216bba
children 1beb207e9267
files src/plugins/plugin_sec_otr.py
diffstat 1 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/plugins/plugin_sec_otr.py	Fri Sep 05 19:29:30 2014 +0200
+++ b/src/plugins/plugin_sec_otr.py	Sun Sep 07 20:08:56 2014 +0200
@@ -429,10 +429,19 @@
             else:
                 raise failure.Failure(exceptions.CancelError()) # no message at all (no history, no signal)
 
+    def _receivedTreatmentForSkippedProfiles(self, data, profile):
+        """This profile must be skipped because the frontend manages OTR itself,
+        but we still need to check if the message must be stored in history or not"""
+        body = data['body'].encode('utf-8')
+        if body.startswith(potr.proto.OTRTAG):
+            raise failure.Failure(exceptions.SkipHistory())
+        return data
+
     def MessageReceivedTrigger(self, message, post_treat, profile):
         if profile in self.skipped_profiles:
-            return True
-        post_treat.addCallback(self._receivedTreatment, profile)
+            post_treat.addCallback(self._receivedTreatmentForSkippedProfiles, profile)
+        else:
+            post_treat.addCallback(self._receivedTreatment, profile)
         return True
 
     def sendMessageTrigger(self, mess_data, pre_xml_treatments, post_xml_treatments, profile):