# HG changeset patch # User souliane # Date 1410113336 -7200 # Node ID bc811915a96a1cd7f67eb30c6e8e95ae2d462887 # Parent cae023216bbaabd5a7a01fb75fb44043453dfa94 plugin OTR: do not save in history the encrypted messages for skipped profiles diff -r cae023216bba -r bc811915a96a src/plugins/plugin_sec_otr.py --- 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):