plugin OTR: do not save in history the encrypted messages for skipped profiles

This commit is contained in:
souliane 2014-09-07 20:08:56 +02:00
commit 8654193b40

View file

@ -429,10 +429,19 @@ class OTR(object):
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):