comparison src/plugins/plugin_sec_otr.py @ 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 0abce7f17782
children eb1144a22e20
comparison
equal deleted inserted replaced
1173:cae023216bba 1174:bc811915a96a
427 data['body'] = res[0].decode('utf-8') 427 data['body'] = res[0].decode('utf-8')
428 raise failure.Failure(exceptions.SkipHistory()) # we send the decrypted message to frontends, but we don't want it in history 428 raise failure.Failure(exceptions.SkipHistory()) # we send the decrypted message to frontends, but we don't want it in history
429 else: 429 else:
430 raise failure.Failure(exceptions.CancelError()) # no message at all (no history, no signal) 430 raise failure.Failure(exceptions.CancelError()) # no message at all (no history, no signal)
431 431
432 def _receivedTreatmentForSkippedProfiles(self, data, profile):
433 """This profile must be skipped because the frontend manages OTR itself,
434 but we still need to check if the message must be stored in history or not"""
435 body = data['body'].encode('utf-8')
436 if body.startswith(potr.proto.OTRTAG):
437 raise failure.Failure(exceptions.SkipHistory())
438 return data
439
432 def MessageReceivedTrigger(self, message, post_treat, profile): 440 def MessageReceivedTrigger(self, message, post_treat, profile):
433 if profile in self.skipped_profiles: 441 if profile in self.skipped_profiles:
434 return True 442 post_treat.addCallback(self._receivedTreatmentForSkippedProfiles, profile)
435 post_treat.addCallback(self._receivedTreatment, profile) 443 else:
444 post_treat.addCallback(self._receivedTreatment, profile)
436 return True 445 return True
437 446
438 def sendMessageTrigger(self, mess_data, pre_xml_treatments, post_xml_treatments, profile): 447 def sendMessageTrigger(self, mess_data, pre_xml_treatments, post_xml_treatments, profile):
439 if profile in self.skipped_profiles: 448 if profile in self.skipped_profiles:
440 return True 449 return True