changeset be6f8c2de101 in /home/hg/repos/gajim-plugins
author: lovetox forenjunkie@chello.at branches: details:gajim-plugins?cmd=changeset;node=be6f8c2de101 description: Send info message to non OMEMO resources
A Body is added with an info message, if there is a resource online that doesnt support OMEMO
diffstat:
omemo/__init__.py | 16 +++++++++++++++- 1 files changed, 15 insertions(+), 1 deletions(-)
diffs (26 lines):
diff -r 5d2895e298d8 -r be6f8c2de101 omemo/__init__.py --- a/omemo/__init__.py Sat Aug 13 13:05:11 2016 +0200 +++ b/omemo/__init__.py Mon Aug 15 11:05:43 2016 +0200 @@ -671,7 +671,21 @@ return True
encrypted_node = OmemoMessage(msg_dict) - event.msg_iq.delChild('body') + contacts = gajim.contacts.get_contacts(account, to_jid) + non_omemo_resource_online = False + for contact in contacts: + if contact.show == 'offline': + continue + if not contact.supports(NS_NOTIFY): + log.debug(contact.get_full_jid() + + ' => Contact doesnt support OMEMO, ' + 'adding Info Message to Body') + support_msg = 'You received a message encrypted with ' \ + 'OMEMO but your client doesnt support OMEMO.' + event.msg_iq.setBody(support_msg) + non_omemo_resource_online = True + if not non_omemo_resource_online: + event.msg_iq.delChild('body') event.msg_iq.addChild(node=encrypted_node) store = Node('store', attrs={'xmlns': NS_HINTS}) event.msg_iq.addChild(node=store)