summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2020-12-02 19:47:46 +0100
committermathieui <mathieui@mathieui.net>2020-12-04 19:14:30 +0100
commitc63e9a32b9481ccd52f5ccf3dcdd3a61f0109f21 (patch)
treefc6fe876ef5ba588b901a5997350010877525301
parent58c3579f74e2827c0be973cac9b0a0ae9a606a1e (diff)
downloadslixmpp-c63e9a32b9481ccd52f5ccf3dcdd3a61f0109f21.tar.gz
slixmpp-c63e9a32b9481ccd52f5ccf3dcdd3a61f0109f21.tar.bz2
slixmpp-c63e9a32b9481ccd52f5ccf3dcdd3a61f0109f21.tar.xz
slixmpp-c63e9a32b9481ccd52f5ccf3dcdd3a61f0109f21.zip
XEP-0359: Unique and Stable Stanza IDs
(was partially supported in places before)
-rw-r--r--slixmpp/plugins/__init__.py1
-rw-r--r--slixmpp/plugins/xep_0359/__init__.py13
-rw-r--r--slixmpp/plugins/xep_0359/stanza.py35
-rw-r--r--slixmpp/plugins/xep_0359/stanzaid.py22
4 files changed, 71 insertions, 0 deletions
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 <mathieui@mathieui.net>
+ 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 <mathieui@mathieui.net>
+ 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 <mathieui@mathieui.net>
+ 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()