diff options
author | lovetox <philipp@hoerist.com> | 2020-04-19 23:12:13 +0300 |
---|---|---|
committer | lovetox <philipp@hoerist.com> | 2020-04-19 23:14:06 +0300 |
commit | fcaa83e3d2d3b81aedcad3d5a787abb66643303a (patch) | |
tree | cd69293dfcd615e2e9196ffb7b1f19e424a54a19 /omemo/modules | |
parent | 7097f868349faaa5af8638a8523872eca23e0628 (diff) |
[omemo] Use nbxmpp.namespaces
Diffstat (limited to 'omemo/modules')
-rw-r--r-- | omemo/modules/omemo.py | 31 | ||||
-rw-r--r-- | omemo/modules/util.py | 4 |
2 files changed, 18 insertions, 17 deletions
diff --git a/omemo/modules/omemo.py b/omemo/modules/omemo.py index 60750ac..ba3da50 100644 --- a/omemo/modules/omemo.py +++ b/omemo/modules/omemo.py @@ -20,6 +20,7 @@ import os import time import nbxmpp +from nbxmpp.namespaces import Namespace from nbxmpp.protocol import NodeProcessed from nbxmpp.protocol import JID from nbxmpp.util import is_error_result @@ -50,19 +51,19 @@ from omemo.modules.util import prepare_stanza ALLOWED_TAGS = [ - ('request', nbxmpp.NS_RECEIPTS), - ('active', nbxmpp.NS_CHATSTATES), - ('gone', nbxmpp.NS_CHATSTATES), - ('inactive', nbxmpp.NS_CHATSTATES), - ('paused', nbxmpp.NS_CHATSTATES), - ('composing', nbxmpp.NS_CHATSTATES), - ('no-store', nbxmpp.NS_MSG_HINTS), - ('store', nbxmpp.NS_MSG_HINTS), - ('no-copy', nbxmpp.NS_MSG_HINTS), - ('no-permanent-store', nbxmpp.NS_MSG_HINTS), - ('replace', nbxmpp.NS_CORRECT), + ('request', Namespace.RECEIPTS), + ('active', Namespace.CHATSTATES), + ('gone', Namespace.CHATSTATES), + ('inactive', Namespace.CHATSTATES), + ('paused', Namespace.CHATSTATES), + ('composing', Namespace.CHATSTATES), + ('no-store', Namespace.HINTS), + ('store', Namespace.HINTS), + ('no-copy', Namespace.HINTS), + ('no-permanent-store', Namespace.HINTS), + ('replace', Namespace.CORRECT), ('thread', None), - ('origin-id', nbxmpp.NS_SID), + ('origin-id', Namespace.SID), ] ENCRYPTION_NAME = 'OMEMO' @@ -88,11 +89,11 @@ class OMEMO(BaseModule): self.handlers = [ StanzaHandler(name='message', callback=self._message_received, - ns=nbxmpp.NS_OMEMO_TEMP, + ns=Namespace.OMEMO_TEMP, priority=9), StanzaHandler(name='presence', callback=self._on_muc_user_presence, - ns=nbxmpp.NS_MUC_USER, + ns=Namespace.MUC_USER, priority=48), ] @@ -470,7 +471,7 @@ class OMEMO(BaseModule): self._process_devicelist_update(jid, devicelist) - @event_node(nbxmpp.NS_OMEMO_TEMP_DL) + @event_node(Namespace.OMEMO_TEMP_DL) def _devicelist_notification_received(self, _con, _stanza, properties): if properties.pubsub_event.retracted: return diff --git a/omemo/modules/util.py b/omemo/modules/util.py index 5706d06..b93c435 100644 --- a/omemo/modules/util.py +++ b/omemo/modules/util.py @@ -15,11 +15,11 @@ # along with OMEMO Gajim Plugin. If not, see <http://www.gnu.org/licenses/>. -import nbxmpp +from nbxmpp.namespaces import Namespace def prepare_stanza(stanza, plaintext): - delete_nodes(stanza, 'encrypted', nbxmpp.NS_OMEMO_TEMP) + delete_nodes(stanza, 'encrypted', Namespace.OMEMO_TEMP) delete_nodes(stanza, 'body') stanza.setBody(plaintext) |