annotate libervia/backend/plugins/plugin_exp_invitation_pubsub.py @ 4332:71c939e34ca6

XEP-0373 (OX): Adjust to gpgme updates: generate with explicit algorithm and subkeys
author Syndace <me@syndace.dev>
date Sat, 13 Jul 2024 18:28:28 +0200
parents 0d7bb4df2343
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3462
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/env python3
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
2
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
3 # SàT plugin to send invitations for Pubsub
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
4 # Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
5
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
6 # This program is free software: you can redistribute it and/or modify
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
7 # it under the terms of the GNU Affero General Public License as published by
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
8 # the Free Software Foundation, either version 3 of the License, or
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
9 # (at your option) any later version.
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
10
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
11 # This program is distributed in the hope that it will be useful,
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
14 # GNU Affero General Public License for more details.
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
15
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
16 # You should have received a copy of the GNU Affero General Public License
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
18
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
19 from typing import Optional
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
20 from twisted.internet import defer
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
21 from twisted.words.protocols.jabber import jid
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
22 from twisted.words.xish import domish
4071
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4037
diff changeset
23 from libervia.backend.core.i18n import _
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4037
diff changeset
24 from libervia.backend.core.constants import Const as C
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4037
diff changeset
25 from libervia.backend.core.log import getLogger
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4037
diff changeset
26 from libervia.backend.core.xmpp import SatXMPPEntity
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4037
diff changeset
27 from libervia.backend.tools import utils
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4037
diff changeset
28 from libervia.backend.tools.common import data_format
3462
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
29
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
30 log = getLogger(__name__)
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
31
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
32
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
33 PLUGIN_INFO = {
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
34 C.PI_NAME: "Pubsub Invitation",
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
35 C.PI_IMPORT_NAME: "PUBSUB_INVITATION",
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
36 C.PI_TYPE: "EXP",
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
37 C.PI_PROTOCOLS: [],
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
38 C.PI_DEPENDENCIES: ["XEP-0060", "INVITATION"],
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
39 C.PI_RECOMMENDATIONS: [],
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
40 C.PI_MAIN: "PubsubInvitation",
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
41 C.PI_HANDLER: "no",
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
42 C.PI_DESCRIPTION: _("Invitations for pubsub based features"),
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
43 }
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
44
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
45
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
46 class PubsubInvitation:
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
47
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
48 def __init__(self, host):
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
49 log.info(_("Pubsub Invitation plugin initialization"))
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
50 self.host = host
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
51 self._p = host.plugins["XEP-0060"]
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
52 # namespace to handler map
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
53 self._ns_handler = {}
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 4027
diff changeset
54 host.bridge.add_method(
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 4027
diff changeset
55 "ps_invite",
3462
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
56 ".plugin",
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
57 in_sign="sssssss",
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
58 out_sign="",
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 4027
diff changeset
59 method=self._send_pubsub_invitation,
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
60 async_=True,
3462
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
61 )
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
62
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
63 def register(self, namespace: str, handler) -> None:
3462
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
64 self._ns_handler[namespace] = handler
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 4027
diff changeset
65 self.host.plugins["INVITATION"].register_namespace(namespace, self.on_invitation)
3462
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
66
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 4027
diff changeset
67 def _send_pubsub_invitation(
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
68 self,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
69 invitee_jid_s,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
70 service_s,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
71 node,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
72 item_id=None,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
73 name=None,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
74 extra_s="",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
75 profile_key=C.PROF_KEY_NONE,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
76 ):
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 4027
diff changeset
77 client = self.host.get_client(profile_key)
3462
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
78 invitee_jid = jid.JID(invitee_jid_s)
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
79 service = jid.JID(service_s)
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
80 extra = data_format.deserialise(extra_s)
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
81 return defer.ensureDeferred(
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
82 self.invite(
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
83 client,
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
84 invitee_jid,
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
85 service,
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
86 node,
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
87 item_id or None,
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
88 name=name or None,
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
89 extra=extra,
3462
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
90 )
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
91 )
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
92
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
93 async def invite(
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
94 self,
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
95 client: SatXMPPEntity,
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
96 invitee_jid: jid.JID,
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
97 service: jid.JID,
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
98 node: str,
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
99 item_id: Optional[str] = None,
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
100 name: str = "",
3462
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
101 extra: Optional[dict] = None,
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
102 ) -> None:
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
103 if extra is None:
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
104 extra = {}
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
105 else:
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
106 namespace = extra.get("namespace")
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
107 if namespace:
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
108 try:
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
109 handler = self._ns_handler[namespace]
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 4027
diff changeset
110 preflight = handler.invite_preflight
3462
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
111 except KeyError:
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
112 pass
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
113 except AttributeError:
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 4027
diff changeset
114 log.debug(f"no invite_preflight method found for {namespace!r}")
3462
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
115 else:
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 4027
diff changeset
116 await utils.as_deferred(
3462
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
117 preflight,
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
118 client,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
119 invitee_jid,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
120 service,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
121 node,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
122 item_id,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
123 name,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
124 extra,
3462
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
125 )
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
126 if item_id is None:
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
127 item_id = extra.pop("default_item_id", None)
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
128
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
129 # we authorize our invitee to see the nodes of interest
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
130 await self._p.set_node_affiliations(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
131 client, service, node, {invitee_jid: "member"}
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
132 )
3462
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
133 log.debug(f"affiliation set on {service}'s {node!r} node")
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
134
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
135 # now we send the invitation
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 4027
diff changeset
136 self.host.plugins["INVITATION"].send_pubsub_invitation(
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
137 client, invitee_jid, service, node, item_id, name=name or None, extra=extra
3462
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
138 )
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
139
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 4027
diff changeset
140 async def on_invitation(
3462
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
141 self,
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
142 client: SatXMPPEntity,
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
143 namespace: str,
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
144 name: str,
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
145 extra: dict,
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
146 service: jid.JID,
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
147 node: str,
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
148 item_id: Optional[str],
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
149 item_elt: domish.Element,
3462
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
150 ) -> None:
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
151 if extra is None:
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
152 extra = {}
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
153 try:
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
154 handler = self._ns_handler[namespace]
4027
26c3e1bc7fb7 plugin XEP-0471: renamed "events" plugin to XEP-0471 now that there is a XEP
Goffi <goffi@goffi.org>
parents: 3584
diff changeset
155 preflight = handler.on_invitation_preflight
3462
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
156 except KeyError:
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
157 pass
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
158 except AttributeError:
4027
26c3e1bc7fb7 plugin XEP-0471: renamed "events" plugin to XEP-0471 now that there is a XEP
Goffi <goffi@goffi.org>
parents: 3584
diff changeset
159 log.debug(f"no on_invitation_preflight method found for {namespace!r}")
3462
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
160 else:
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 4027
diff changeset
161 await utils.as_deferred(
3462
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
162 preflight,
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
163 client,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
164 namespace,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
165 name,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
166 extra,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
167 service,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
168 node,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
169 item_id,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
170 item_elt,
3462
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
171 )
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
172 if item_id is None:
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
173 item_id = extra.pop("default_item_id", None)
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
174 creator = extra.pop("creator", False)
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
175 element = extra.pop("element", None)
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
176 if not name:
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
177 name = extra.pop("name", "")
12dc234f698c plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
diff changeset
178
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
179 return await self.host.plugins["LIST_INTEREST"].register_pubsub(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
180 client, namespace, service, node, item_id, creator, name, element, extra
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
181 )