annotate sat/plugins/plugin_xep_0465.py @ 3786:cebfdfff3e99

doc (components): message delivery documentation: fix 366
author Goffi <goffi@goffi.org>
date Tue, 24 May 2022 17:57:41 +0200
parents b7cef1b24f83
children 56e5b18f4d06
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3758
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/env python3
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
2
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
3 # Libervia plugin for XEP-0465
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
4 # Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
5
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
6 # This program is free software: you can redistribute it and/or modify
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
7 # it under the terms of the GNU Affero General Public License as published by
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
8 # the Free Software Foundation, either version 3 of the License, or
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
9 # (at your option) any later version.
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
10
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
11 # This program is distributed in the hope that it will be useful,
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
14 # GNU Affero General Public License for more details.
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
15
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
16 # You should have received a copy of the GNU Affero General Public License
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
18
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
19 from typing import Optional, List, Dict, Union
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
20
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
21 from twisted.words.protocols.jabber.xmlstream import XMPPHandler
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
22 from twisted.words.protocols.jabber import jid
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
23 from twisted.words.xish import domish
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
24 from zope.interface import implementer
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
25 from wokkel import disco, iwokkel
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
26
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
27 from sat.core.constants import Const as C
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
28 from sat.core.i18n import _
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
29 from sat.core.log import getLogger
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
30 from sat.core import exceptions
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
31 from sat.core.core_types import SatXMPPEntity
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
32 from sat.tools import utils
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
33 from sat.tools.common import data_format
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
34
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
35 log = getLogger(__name__)
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
36
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
37 PLUGIN_INFO = {
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
38 C.PI_NAME: "Pubsub Public Subscriptions",
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
39 C.PI_IMPORT_NAME: "XEP-0465",
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
40 C.PI_TYPE: C.PLUG_TYPE_XEP,
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
41 C.PI_MODES: C.PLUG_MODE_BOTH,
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
42 C.PI_PROTOCOLS: ["XEP-0465"],
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
43 C.PI_DEPENDENCIES: ["XEP-0060", "XEP-0376"],
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
44 C.PI_MAIN: "XEP_0465",
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
45 C.PI_HANDLER: "yes",
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
46 C.PI_DESCRIPTION: _("""Pubsub Public Subscriptions implementation"""),
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
47 }
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
48
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
49 NS_PPS = "urn:xmpp:pps:0"
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
50 NS_PPS_SUBSCRIPTIONS = "urn:xmpp:pps:subscriptions:0"
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
51 NS_PPS_SUBSCRIBERS = "urn:xmpp:pps:subscribers:0"
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
52 SUBSCRIBERS_NODE_PREFIX = f"{NS_PPS_SUBSCRIBERS}/"
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
53
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
54
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
55 class XEP_0465:
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
56
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
57 def __init__(self, host):
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
58 log.info(_("Pubsub Public Subscriptions initialization"))
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
59 host.registerNamespace("pps", NS_PPS)
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
60 self.host = host
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
61 host.bridge.addMethod(
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
62 "psPublicSubscriptionsGet",
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
63 ".plugin",
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
64 in_sign="sss",
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
65 out_sign="s",
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
66 method=self._subscriptions,
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
67 async_=True,
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
68 )
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
69 host.bridge.addMethod(
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
70 "psPublicSubscriptionsGet",
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
71 ".plugin",
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
72 in_sign="sss",
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
73 out_sign="s",
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
74 method=self._subscriptions,
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
75 async_=True,
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
76 )
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
77 host.bridge.addMethod(
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
78 "psPublicNodeSubscriptionsGet",
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
79 ".plugin",
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
80 in_sign="sss",
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
81 out_sign="a{ss}",
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
82 method=self._getPublicNodeSubscriptions,
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
83 async_=True,
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
84 )
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
85
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
86 def getHandler(self, client):
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
87 return XEP_0465_Handler()
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
88
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
89 @property
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
90 def subscriptions_node(self) -> str:
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
91 return NS_PPS_SUBSCRIPTIONS
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
92
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
93 @property
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
94 def subscribers_node_prefix(self) -> str:
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
95 return SUBSCRIBERS_NODE_PREFIX
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
96
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
97 def buildSubscriptionElt(self, node: str, service: jid.JID) -> domish.Element:
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
98 """Generate a <subscriptions> element
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
99
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
100 This is the element that a service returns on public subscriptions request
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
101 """
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
102 subscription_elt = domish.Element((NS_PPS, "subscription"))
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
103 subscription_elt["node"] = node
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
104 subscription_elt["service"] = service.full()
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
105 return subscription_elt
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
106
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
107 def buildSubscriberElt(self, subscriber: jid.JID) -> domish.Element:
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
108 """Generate a <subscriber> element
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
109
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
110 This is the element that a service returns on node public subscriptions request
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
111 """
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
112 subscriber_elt = domish.Element((NS_PPS, "subscriber"))
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
113 subscriber_elt["jid"] = subscriber.full()
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
114 return subscriber_elt
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
115
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
116 @utils.ensure_deferred
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
117 async def _subscriptions(
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
118 self,
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
119 service="",
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
120 nodeIdentifier="",
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
121 profile_key=C.PROF_KEY_NONE
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
122 ) -> str:
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
123 client = self.host.getClient(profile_key)
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
124 service = None if not service else jid.JID(service)
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
125 subs = await self.subscriptions(client, service, nodeIdentifier or None)
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
126 return data_format.serialise(subs)
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
127
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
128 async def subscriptions(
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
129 self,
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
130 client: SatXMPPEntity,
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
131 service: Optional[jid.JID] = None,
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
132 node: Optional[str] = None
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
133 ) -> List[Dict[str, Union[str, bool]]]:
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
134 """Retrieve public subscriptions from a service
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
135
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
136 @param service(jid.JID): PubSub service
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
137 @param nodeIdentifier(unicode, None): node to filter
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
138 None to get all subscriptions
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
139 """
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
140 if service is None:
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
141 service = client.jid.userhostJID()
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
142 items, __ = await self.host.plugins["XEP-0060"].getItems(
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
143 client, service, NS_PPS_SUBSCRIPTIONS
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
144 )
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
145 ret = []
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
146 for item in items:
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
147 try:
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
148 subscription_elt = next(item.elements(NS_PPS, "subscription"))
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
149 except StopIteration:
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
150 log.warning(f"no <subscription> element found: {item.toXml()}")
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
151 continue
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
152
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
153 try:
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
154 sub_dict = {
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
155 "service": subscription_elt["service"],
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
156 "node": subscription_elt["node"],
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
157 "subscriber": service.full(),
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
158 "state": subscription_elt.getAttribute("subscription", "subscribed"),
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
159 }
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
160 except KeyError:
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
161 log.warning(
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
162 f"invalid <subscription> element: {subscription_elt.toXml()}"
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
163 )
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
164 continue
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
165 if node is not None and sub_dict["node"] != node:
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
166 # if not is specified, we filter out any other node
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
167 # FIXME: should node filtering be done by server?
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
168 continue
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
169 ret.append(sub_dict)
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
170 return ret
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
171
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
172 @utils.ensure_deferred
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
173 async def _getPublicNodeSubscriptions(
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
174 self,
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
175 service: str,
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
176 node: str,
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
177 profile_key: str
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
178 ) -> Dict[str, str]:
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
179 client = self.host.getClient(profile_key)
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
180 subs = await self.getPublicNodeSubscriptions(
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
181 client, jid.JID(service) if service else None, node
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
182 )
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
183 return {j.full(): a for j, a in subs.items()}
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
184
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
185 def getPublicSubscribersNode(self, node: str) -> str:
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
186 """Return prefixed node to retrieve public subscribers"""
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
187 return f"{NS_PPS_SUBSCRIBERS}/{node}"
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
188
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
189 async def getPublicNodeSubscriptions(
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
190 self,
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
191 client: SatXMPPEntity,
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
192 service: Optional[jid.JID],
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
193 nodeIdentifier: str
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
194 ) -> Dict[jid.JID, str]:
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
195 """Retrieve public subscriptions to a node
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
196
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
197 @param nodeIdentifier(unicode): node to get subscriptions from
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
198 """
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
199 if not nodeIdentifier:
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
200 raise exceptions.DataError("node identifier can't be empty")
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
201
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
202 if service is None:
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
203 service = client.jid.userhostJID()
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
204
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
205 subscribers_node = self.getPublicSubscribersNode(nodeIdentifier)
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
206
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
207 items, __ = await self.host.plugins["XEP-0060"].getItems(
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
208 client, service, subscribers_node
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
209 )
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
210 ret = {}
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
211 for item in items:
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
212 try:
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
213 subscriber_elt = next(item.elements(NS_PPS, "subscriber"))
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
214 except StopIteration:
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
215 log.warning(f"no <subscriber> element found: {item.toXml()}")
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
216 continue
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
217
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
218 try:
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
219 ret[jid.JID(subscriber_elt["jid"])] = "subscribed"
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
220 except (KeyError, RuntimeError):
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
221 log.warning(
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
222 f"invalid <subscriber> element: {subscriber_elt.toXml()}"
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
223 )
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
224 continue
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
225 return ret
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
226
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
227 def setPublicOpt(self, options: Optional[dict] = None) -> dict:
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
228 """Set option to make a subscription public
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
229
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
230 @param options: dict where the option must be set
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
231 if None, a new dict will be created
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
232
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
233 @return: the options dict
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
234 """
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
235 if options is None:
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
236 options = {}
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
237 options[f'{{{NS_PPS}}}public'] = True
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
238 return options
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
239
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
240
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
241 @implementer(iwokkel.IDisco)
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
242 class XEP_0465_Handler(XMPPHandler):
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
243
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
244 def getDiscoInfo(self, requestor, service, nodeIdentifier=""):
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
245 return [disco.DiscoFeature(NS_PPS)]
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
246
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
247 def getDiscoItems(self, requestor, service, nodeIdentifier=""):
b7cef1b24f83 plugins XEP-0060, XEP-0376, XEP-0465, CLI: PAM + PSS implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
248 return []