From c63e9a32b9481ccd52f5ccf3dcdd3a61f0109f21 Mon Sep 17 00:00:00 2001 From: mathieui Date: Wed, 2 Dec 2020 19:47:46 +0100 Subject: XEP-0359: Unique and Stable Stanza IDs (was partially supported in places before) --- slixmpp/plugins/__init__.py | 1 + slixmpp/plugins/xep_0359/__init__.py | 13 +++++++++++++ slixmpp/plugins/xep_0359/stanza.py | 35 +++++++++++++++++++++++++++++++++++ slixmpp/plugins/xep_0359/stanzaid.py | 22 ++++++++++++++++++++++ 4 files changed, 71 insertions(+) create mode 100644 slixmpp/plugins/xep_0359/__init__.py create mode 100644 slixmpp/plugins/xep_0359/stanza.py create mode 100644 slixmpp/plugins/xep_0359/stanzaid.py diff --git a/slixmpp/plugins/__init__.py b/slixmpp/plugins/__init__.py index dce69083..758cccd1 100644 --- a/slixmpp/plugins/__init__.py +++ b/slixmpp/plugins/__init__.py @@ -86,6 +86,7 @@ __all__ = [ 'xep_0325', # IoT Systems Control 'xep_0332', # HTTP Over XMPP Transport 'xep_0353', # Jingle Message Initiation + 'xep_0359', # Unique and Stable Stanza IDs 'xep_0363', # HTTP File Upload 'xep_0369', # MIX-CORE 'xep_0377', # Spam reporting diff --git a/slixmpp/plugins/xep_0359/__init__.py b/slixmpp/plugins/xep_0359/__init__.py new file mode 100644 index 00000000..dd01ea1e --- /dev/null +++ b/slixmpp/plugins/xep_0359/__init__.py @@ -0,0 +1,13 @@ +""" + Slixmpp: The Slick XMPP Library + Copyright (C) 2020 Mathieu Pasquet + This file is part of Slixmpp. + + See the file LICENSE for copying permission. +""" + +from slixmpp.plugins.base import register_plugin +from slixmpp.plugins.xep_0359.stanza import * +from slixmpp.plugins.xep_0359.stanzaid import XEP_0359 + +register_plugin(XEP_0359) diff --git a/slixmpp/plugins/xep_0359/stanza.py b/slixmpp/plugins/xep_0359/stanza.py new file mode 100644 index 00000000..db8e9fff --- /dev/null +++ b/slixmpp/plugins/xep_0359/stanza.py @@ -0,0 +1,35 @@ +""" + Slixmpp: The Slick XMPP Library + Copyright (C) 2020 Mathieu Pasquet + This file is part of Slixmpp. + + See the file LICENSE for copying permissio +""" + +from slixmpp.stanza import Message +from slixmpp.xmlstream import ( + ElementBase, + register_stanza_plugin, +) + + +NS = 'urn:xmpp:sid:0' + + +class StanzaID(ElementBase): + namespace = NS + name = 'stanza-id' + plugin_attrib = 'stanza_id' + interfaces = {'id', 'by'} + + +class OriginID(ElementBase): + namespace = NS + name = 'origin-id' + plugin_attrib = 'origin_id' + interfaces = {'id'} + + +def register_plugins(): + register_stanza_plugin(Message, StanzaID) + register_stanza_plugin(Message, OriginID) diff --git a/slixmpp/plugins/xep_0359/stanzaid.py b/slixmpp/plugins/xep_0359/stanzaid.py new file mode 100644 index 00000000..2235e74b --- /dev/null +++ b/slixmpp/plugins/xep_0359/stanzaid.py @@ -0,0 +1,22 @@ +""" + Slixmpp: The Slick XMPP Library + Copyright (C) 2020 Mathieu Pasquet + This file is part of Slixmpp. + + See the file LICENSE for copying permission. +""" +from slixmpp.plugins import BasePlugin +from slixmpp.plugins.xep_0359 import stanza + + +class XEP_0359(BasePlugin): + '''XEP-0359: Unique and Stable Stanza IDs''' + + name = 'xep_0359' + description = 'Unique and Stable Stanza IDs' + dependencies = set() + stanza = stanza + namespace = stanza.NS + + def plugin_init(self) -> None: + stanza.register_plugins() -- cgit v1.2.3