XEP-0045: Add a specific handler for MUC presence errors

This commit is contained in:
mathieui 2021-01-31 17:03:39 +01:00
parent eda692d1c6
commit a8113dca49

View file

@ -91,6 +91,9 @@ class XEP_0045(BasePlugin):
StanzaPath("presence/muc"),
self.handle_groupchat_presence,
))
# <x xmlns="http://jabber.org/protocol/muc"/> is only used in
# presence when joining on the client side, and for errors on
# the server side.
if self.xmpp.is_component:
self.xmpp.register_handler(
Callback(
@ -98,6 +101,13 @@ class XEP_0045(BasePlugin):
StanzaPath("presence/muc_join"),
self.handle_groupchat_join,
))
self.xmpp.register_handler(
Callback(
"MUCPresenceError",
StanzaPath("presence@type=error/muc_join"),
self._handle_presence_error,
)
)
self.xmpp.register_handler(
Callback(
@ -192,6 +202,10 @@ class XEP_0045(BasePlugin):
if got_online:
self.xmpp.event("muc::%s::got_online" % entry['room'], pr)
def _handle_presence_error(self, pr: Presence):
"""Generate MUC presence error events"""
self.xmpp.event("muc::%s::presence-error" % pr['from'].bare, pr)
def handle_groupchat_presence(self, pr: Presence):
""" Handle a presence in a muc."""
if self.xmpp.is_component: