comparison 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
comparison
equal deleted inserted replaced
3170:39d7327583e1 3171:d073d82d9044
428 ## Misc ## 428 ## Misc ##
429 429
430 def markAsEncrypted(self, mess_data): 430 def markAsEncrypted(self, mess_data):
431 """Helper method to mark a message as having been e2e encrypted. 431 """Helper method to mark a message as having been e2e encrypted.
432 432
433 This should be used in the post_treat workflow of MessageReceived trigger of 433 This should be used in the post_treat workflow of messageReceived trigger of
434 the plugin 434 the plugin
435 @param mess_data(dict): message data as used in post treat workflow 435 @param mess_data(dict): message data as used in post treat workflow
436 """ 436 """
437 mess_data[C.MESS_KEY_ENCRYPTED] = True 437 mess_data[C.MESS_KEY_ENCRYPTED] = True
438 return mess_data 438 return mess_data
439 439
440 def isEncrypted(self, mess_data):
441 """Helper method to check if a message has the e2e encrypted flag
442
443 @param mess_data(dict): message data
444 @return (bool): True if the encrypted flag is present
445 """
446 return mess_data.get(C.MESS_KEY_ENCRYPTED, False)
447
448
440 def markAsTrusted(self, mess_data): 449 def markAsTrusted(self, mess_data):
441 """Helper methor to mark a message as sent from a trusted entity. 450 """Helper methor to mark a message as sent from a trusted entity.
442 451
443 This should be used in the post_treat workflow of MessageReceived trigger of 452 This should be used in the post_treat workflow of messageReceived trigger of
444 the plugin 453 the plugin
445 @param mess_data(dict): message data as used in post treat workflow 454 @param mess_data(dict): message data as used in post treat workflow
446 """ 455 """
447 mess_data[C.MESS_KEY_TRUSTED] = True 456 mess_data[C.MESS_KEY_TRUSTED] = True
448 return mess_data 457 return mess_data
449 458
450 def markAsUntrusted(self, mess_data): 459 def markAsUntrusted(self, mess_data):
451 """Helper methor to mark a message as sent from an untrusted entity. 460 """Helper methor to mark a message as sent from an untrusted entity.
452 461
453 This should be used in the post_treat workflow of MessageReceived trigger of 462 This should be used in the post_treat workflow of messageReceived trigger of
454 the plugin 463 the plugin
455 @param mess_data(dict): message data as used in post treat workflow 464 @param mess_data(dict): message data as used in post treat workflow
456 """ 465 """
457 mess_data['trusted'] = False 466 mess_data['trusted'] = False
458 return mess_data 467 return mess_data