New XEP: 0421 Occupant-id
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
13
slixmpp/plugins/xep_0421/__init__.py
Normal file
13
slixmpp/plugins/xep_0421/__init__.py
Normal file
@@ -0,0 +1,13 @@
|
||||
"""
|
||||
Slixmpp: The Slick XMPP Library
|
||||
Copyright (C) 2020 "Maxime “pep” Buquet <pep@bouah.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_0421.stanza import OccupantId
|
||||
from slixmpp.plugins.xep_0421.occupant_id import XEP_0421
|
||||
|
||||
register_plugin(XEP_0421)
|
||||
26
slixmpp/plugins/xep_0421/occupant_id.py
Normal file
26
slixmpp/plugins/xep_0421/occupant_id.py
Normal file
@@ -0,0 +1,26 @@
|
||||
"""
|
||||
Slixmpp: The Slick XMPP Library
|
||||
Copyright (C) 2020 "Maxime “pep” Buquet <pep@bouah.net>"
|
||||
This file is part of Slixmpp.
|
||||
|
||||
See the file LICENSE for copying permission.
|
||||
"""
|
||||
|
||||
from slixmpp import Message
|
||||
from slixmpp.plugins import BasePlugin
|
||||
from slixmpp.xmlstream import register_stanza_plugin
|
||||
from slixmpp.plugins.xep_0421 import stanza
|
||||
from slixmpp.plugins.xep_0421.stanza import OccupantId
|
||||
|
||||
|
||||
class XEP_0421(BasePlugin):
|
||||
'''XEP-0421: Anonymous unique occupant identifiers for MUCs'''
|
||||
|
||||
name = 'xep_0421'
|
||||
description = 'Anonymous unique occupant identifiers for MUCs'
|
||||
dependencies = {'xep_0045'}
|
||||
stanza = stanza
|
||||
|
||||
def plugin_init(self) -> None:
|
||||
# XXX: This should be MucMessage. Someday..
|
||||
register_stanza_plugin(Message, OccupantId)
|
||||
37
slixmpp/plugins/xep_0421/stanza.py
Normal file
37
slixmpp/plugins/xep_0421/stanza.py
Normal file
@@ -0,0 +1,37 @@
|
||||
"""
|
||||
Slixmpp: The Slick XMPP Library
|
||||
Copyright (C) 2020 "Maxime “pep” Buquet <pep@bouah.net>"
|
||||
This file is part of Slixmpp.
|
||||
|
||||
See the file LICENSE for copying permission.
|
||||
"""
|
||||
|
||||
from slixmpp.xmlstream import ElementBase
|
||||
|
||||
|
||||
class OccupantId(ElementBase):
|
||||
'''
|
||||
An Occupant-id tag.
|
||||
|
||||
An <occupant-id/> tag is set by the MUC.
|
||||
|
||||
This is useful in semi-anon MUCs (and MUC-PMs) as a stable identifier to
|
||||
prevent the usual races with nicknames.
|
||||
|
||||
Without occupant-id, getting the following messages from MUC history would
|
||||
prevent a client from asserting senders are the same entity:
|
||||
|
||||
<message type='groupchat' from='foo@muc/nick1' id='message1'>
|
||||
<body>Some message</body>
|
||||
<occupant-id xmlns='urn:xmpp:occupant-id:0' id='unique-opaque-id1'/>
|
||||
</message>
|
||||
<message type='groupchat' from='foo@muc/nick2' id='message2'>
|
||||
<body>Some correction</body>
|
||||
<occupant-id xmlns='urn:xmpp:occupant-id:0' id='unique-opaque-id1'/>
|
||||
<replace xmlns='urn:xmpp:message-correct:0' id='message1'/>
|
||||
</message>
|
||||
'''
|
||||
|
||||
name = 'occupant-id'
|
||||
namespace = 'urn:xmpp:occupant-id:0'
|
||||
interface = {'id'}
|
||||
Reference in New Issue
Block a user