[openpgp] Use nbxmpp.namespaces

This commit is contained in:
lovetox
2020-04-19 22:12:31 +02:00
parent fcaa83e3d2
commit 4a95f1d5bc
3 changed files with 13 additions and 13 deletions

View File

@@ -18,7 +18,7 @@ import time
import logging
from pathlib import Path
import nbxmpp
from nbxmpp.namespaces import Namespace
from nbxmpp import Node
from nbxmpp import StanzaMalformed
from nbxmpp.util import is_error_result
@@ -72,7 +72,7 @@ class OpenPGP(BaseModule):
self.handlers = [
StanzaHandler(name='message',
callback=self.decrypt_message,
ns=nbxmpp.NS_OPENPGP,
ns=Namespace.OPENPGP,
priority=9),
]
@@ -133,7 +133,7 @@ class OpenPGP(BaseModule):
log.info('%s => Publish keylist', self._account)
self._nbxmpp('OpenPGP').set_keylist(keylist)
@event_node(nbxmpp.NS_OPENPGP_PK)
@event_node(Namespace.OPENPGP_PK)
def _keylist_notification_received(self, _con, _stanza, properties):
if properties.pubsub_event.retracted:
return

View File

@@ -17,17 +17,17 @@
from enum import IntEnum
from collections import namedtuple
import nbxmpp
from nbxmpp.namespaces import Namespace
ENCRYPTION_NAME = 'OpenPGP'
NOT_ENCRYPTED_TAGS = [
('no-store', nbxmpp.NS_MSG_HINTS),
('store', nbxmpp.NS_MSG_HINTS),
('no-copy', nbxmpp.NS_MSG_HINTS),
('no-permanent-store', nbxmpp.NS_MSG_HINTS),
('origin-id', nbxmpp.NS_SID),
('no-store', Namespace.HINTS),
('store', Namespace.HINTS),
('no-copy', Namespace.HINTS),
('no-permanent-store', Namespace.HINTS),
('origin-id', Namespace.SID),
('thread', None)
]
@@ -42,7 +42,7 @@ class Trust(IntEnum):
def prepare_stanza(stanza, payload):
delete_nodes(stanza, 'openpgp', nbxmpp.NS_OPENPGP)
delete_nodes(stanza, 'openpgp', Namespace.OPENPGP)
delete_nodes(stanza, 'body')
nodes = [(node.getName(), node.getNamespace()) for node in payload]
@@ -56,7 +56,7 @@ def prepare_stanza(stanza, payload):
def delete_nodes(stanza, name, namespace=None):
attrs = None
if namespace is not None:
attrs = {'xmlns': nbxmpp.NS_OPENPGP}
attrs = {'xmlns': Namespace.OPENPGP}
nodes = stanza.getTags(name, attrs)
for node in nodes:
stanza.delChild(node)