plugin XEP-0465: log a warning and return empty list/dict when forbidden error is received:
this error probably means that the service doesn't support PPS.
This commit is contained in:
parent
199f18366c
commit
3f6ef10bac
1 changed files with 25 additions and 6 deletions
|
|
@ -20,6 +20,7 @@ from typing import Optional, List, Dict, Union
|
|||
|
||||
from twisted.words.protocols.jabber.xmlstream import XMPPHandler
|
||||
from twisted.words.protocols.jabber import jid
|
||||
from twisted.words.protocols.jabber import error
|
||||
from twisted.words.xish import domish
|
||||
from zope.interface import implementer
|
||||
from wokkel import disco, iwokkel
|
||||
|
|
@ -50,6 +51,10 @@ NS_PPS = "urn:xmpp:pps:0"
|
|||
NS_PPS_SUBSCRIPTIONS = "urn:xmpp:pps:subscriptions:0"
|
||||
NS_PPS_SUBSCRIBERS = "urn:xmpp:pps:subscribers:0"
|
||||
SUBSCRIBERS_NODE_PREFIX = f"{NS_PPS_SUBSCRIBERS}/"
|
||||
NOT_IMPLEMENTED_MSG = (
|
||||
"The service at {service!s} doesn't seem to support Pubsub Public Subscriptions "
|
||||
"(XEP-0465), please request support from your service administrator."
|
||||
)
|
||||
|
||||
|
||||
class XEP_0465:
|
||||
|
|
@ -139,9 +144,16 @@ class XEP_0465:
|
|||
"""
|
||||
if service is None:
|
||||
service = client.jid.userhostJID()
|
||||
items, __ = await self.host.plugins["XEP-0060"].getItems(
|
||||
client, service, NS_PPS_SUBSCRIPTIONS
|
||||
)
|
||||
try:
|
||||
items, __ = await self.host.plugins["XEP-0060"].getItems(
|
||||
client, service, NS_PPS_SUBSCRIPTIONS
|
||||
)
|
||||
except error.StanzaError as e:
|
||||
if e.condition == "forbidden":
|
||||
log.warning(NOT_IMPLEMENTED_MSG.format(service=service))
|
||||
return []
|
||||
else:
|
||||
raise e
|
||||
ret = []
|
||||
for item in items:
|
||||
try:
|
||||
|
|
@ -204,9 +216,16 @@ class XEP_0465:
|
|||
|
||||
subscribers_node = self.getPublicSubscribersNode(nodeIdentifier)
|
||||
|
||||
items, __ = await self.host.plugins["XEP-0060"].getItems(
|
||||
client, service, subscribers_node
|
||||
)
|
||||
try:
|
||||
items, __ = await self.host.plugins["XEP-0060"].getItems(
|
||||
client, service, subscribers_node
|
||||
)
|
||||
except error.StanzaError as e:
|
||||
if e.condition == "forbidden":
|
||||
log.warning(NOT_IMPLEMENTED_MSG.format(service=service))
|
||||
return {}
|
||||
else:
|
||||
raise e
|
||||
ret = {}
|
||||
for item in items:
|
||||
try:
|
||||
|
|
|
|||
Loading…
Reference in a new issue