diff options
author | Philipp Hörist <philipp@hoerist.com> | 2019-04-14 13:19:59 +0300 |
---|---|---|
committer | Philipp Hörist <philipp@hoerist.com> | 2019-04-14 13:20:33 +0300 |
commit | d343e2be5b162607e08081c4378ca7895af4b1b1 (patch) | |
tree | d96cec6fd0f6b5acb8a1d9c9e24fc77de0a00b25 /nbxmpp/modules | |
parent | 11dffacfefb7db839ab5bdd47749edc935089dfa (diff) |
Add PGP Legacy (XEP-0027) module
Diffstat (limited to 'nbxmpp/modules')
-rw-r--r-- | nbxmpp/modules/pgplegacy.py (renamed from nbxmpp/modules/signed.py) | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/nbxmpp/modules/signed.py b/nbxmpp/modules/pgplegacy.py index 159e491..256b89f 100644 --- a/nbxmpp/modules/signed.py +++ b/nbxmpp/modules/pgplegacy.py @@ -18,15 +18,20 @@ import logging from nbxmpp.protocol import NS_SIGNED +from nbxmpp.protocol import NS_ENCRYPTED from nbxmpp.structs import StanzaHandler log = logging.getLogger('nbxmpp.m.signed') -class Signed: +class PGPLegacy: def __init__(self, client): self._client = client self.handlers = [ + StanzaHandler(name='message', + callback=self._process_pgplegacy_message, + ns=NS_ENCRYPTED, + priority=7), StanzaHandler(name='presence', callback=self._process_signed, ns=NS_SIGNED, @@ -40,3 +45,20 @@ class Signed: return properties.signed = signed.getData() + + @staticmethod + def _process_pgplegacy_message(_con, stanza, properties): + pgplegacy = stanza.getTag('x', namespace=NS_ENCRYPTED) + if pgplegacy is None: + log.warning('No x node found') + log.warning(stanza) + return + + data = pgplegacy.getData() + if not data: + log.warning('No data in x node found') + log.warning(stanza) + return + + log.info('Encrypted message received') + properties.pgp_legacy = data |