Mercurial > libervia-backend
annotate sat/plugins/plugin_exp_events.py @ 3809:04b57c0b2278
tests (unit/ap gateway): message/item retractation tests:
this patch adds 4 tests to check pubsub <=> AP item retractation and message <=> AP item
retractation.
rel 367
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 17 Jun 2022 15:50:34 +0200 |
parents | 09f5ac48ffe3 |
children | 32b38dd3ac18 |
rev | line source |
---|---|
3028 | 1 #!/usr/bin/env python3 |
3137 | 2 |
2231 | 3 |
4 # SAT plugin to detect language (experimental) | |
3479 | 5 # Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org) |
2231 | 6 |
7 # This program is free software: you can redistribute it and/or modify | |
8 # it under the terms of the GNU Affero General Public License as published by | |
9 # the Free Software Foundation, either version 3 of the License, or | |
10 # (at your option) any later version. | |
11 | |
12 # This program is distributed in the hope that it will be useful, | |
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 # GNU Affero General Public License for more details. | |
16 | |
17 # You should have received a copy of the GNU Affero General Public License | |
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 | |
3462
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
20 from typing import Optional |
2912
a3faf1c86596
plugin events: refactored invitation and personal lists logic:
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
21 import shortuuid |
2231 | 22 from sat.core.i18n import _ |
2243
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
23 from sat.core import exceptions |
2231 | 24 from sat.core.constants import Const as C |
25 from sat.core.log import getLogger | |
3462
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
26 from sat.core.xmpp import SatXMPPEntity |
2243
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
27 from sat.tools import utils |
2616
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
28 from sat.tools.common import uri as xmpp_uri |
2612
3e4e78de9cca
tools (date_utils): moved date_parse to common.date_utils, because it can be used in frontends
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
29 from sat.tools.common import date_utils |
2231 | 30 from twisted.internet import defer |
2243
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
31 from twisted.words.protocols.jabber import jid, error |
2231 | 32 from twisted.words.xish import domish |
2616
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
33 from wokkel import disco, iwokkel |
3028 | 34 from zope.interface import implementer |
2616
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
35 from twisted.words.protocols.jabber.xmlstream import XMPPHandler |
2912
a3faf1c86596
plugin events: refactored invitation and personal lists logic:
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
36 from wokkel import pubsub |
2616
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
37 |
2912
a3faf1c86596
plugin events: refactored invitation and personal lists logic:
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
38 log = getLogger(__name__) |
2231 | 39 |
40 | |
41 PLUGIN_INFO = { | |
2912
a3faf1c86596
plugin events: refactored invitation and personal lists logic:
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
42 C.PI_NAME: "Events", |
2303
37887b5acb25
plugin events: changed import names to EVENTS uppercase for consistency with other plugins
Goffi <goffi@goffi.org>
parents:
2294
diff
changeset
|
43 C.PI_IMPORT_NAME: "EVENTS", |
2231 | 44 C.PI_TYPE: "EXP", |
45 C.PI_PROTOCOLS: [], | |
3462
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
46 C.PI_DEPENDENCIES: ["XEP-0060", "INVITATION", "PUBSUB_INVITATION", "LIST_INTEREST"], |
2912
a3faf1c86596
plugin events: refactored invitation and personal lists logic:
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
47 C.PI_RECOMMENDATIONS: ["XEP-0277", "EMAIL_INVITATION"], |
2231 | 48 C.PI_MAIN: "Events", |
2616
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
49 C.PI_HANDLER: "yes", |
3028 | 50 C.PI_DESCRIPTION: _("""Experimental implementation of XMPP events management"""), |
2231 | 51 } |
52 | |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
53 NS_EVENT = "org.salut-a-toi.event:0" |
2231 | 54 |
55 | |
56 class Events(object): | |
57 """Q&D module to handle event attendance answer, experimentation only""" | |
58 | |
59 def __init__(self, host): | |
3028 | 60 log.info(_("Event plugin initialization")) |
2231 | 61 self.host = host |
62 self._p = self.host.plugins["XEP-0060"] | |
2912
a3faf1c86596
plugin events: refactored invitation and personal lists logic:
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
63 self._i = self.host.plugins.get("EMAIL_INVITATION") |
2287
ea869f30f204
plugin events: added eventInvite command as a helper for the complex invitation workflow:
Goffi <goffi@goffi.org>
parents:
2272
diff
changeset
|
64 self._b = self.host.plugins.get("XEP-0277") |
3028 | 65 self.host.registerNamespace("event", NS_EVENT) |
3462
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
66 self.host.plugins["PUBSUB_INVITATION"].register(NS_EVENT, self) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
67 host.bridge.addMethod( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
68 "eventGet", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
69 ".plugin", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
70 in_sign="ssss", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
71 out_sign="(ia{ss})", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
72 method=self._eventGet, |
3028 | 73 async_=True, |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
74 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
75 host.bridge.addMethod( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
76 "eventCreate", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
77 ".plugin", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
78 in_sign="ia{ss}ssss", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
79 out_sign="s", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
80 method=self._eventCreate, |
3028 | 81 async_=True, |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
82 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
83 host.bridge.addMethod( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
84 "eventModify", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
85 ".plugin", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
86 in_sign="sssia{ss}s", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
87 out_sign="", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
88 method=self._eventModify, |
3028 | 89 async_=True, |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
90 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
91 host.bridge.addMethod( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
92 "eventsList", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
93 ".plugin", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
94 in_sign="sss", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
95 out_sign="aa{ss}", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
96 method=self._eventsList, |
3028 | 97 async_=True, |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
98 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
99 host.bridge.addMethod( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
100 "eventInviteeGet", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
101 ".plugin", |
3083
3c924cb207d9
plugin events: fixed eventInviteeGet signature
Goffi <goffi@goffi.org>
parents:
3040
diff
changeset
|
102 in_sign="ssss", |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
103 out_sign="a{ss}", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
104 method=self._eventInviteeGet, |
3028 | 105 async_=True, |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
106 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
107 host.bridge.addMethod( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
108 "eventInviteeSet", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
109 ".plugin", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
110 in_sign="ssa{ss}s", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
111 out_sign="", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
112 method=self._eventInviteeSet, |
3028 | 113 async_=True, |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
114 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
115 host.bridge.addMethod( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
116 "eventInviteesList", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
117 ".plugin", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
118 in_sign="sss", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
119 out_sign="a{sa{ss}}", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
120 method=self._eventInviteesList, |
3028 | 121 async_=True, |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
122 ), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
123 host.bridge.addMethod( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
124 "eventInvite", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
125 ".plugin", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
126 in_sign="sssss", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
127 out_sign="", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
128 method=self._invite, |
3028 | 129 async_=True, |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
130 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
131 host.bridge.addMethod( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
132 "eventInviteByEmail", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
133 ".plugin", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
134 in_sign="ssssassssssss", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
135 out_sign="", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
136 method=self._inviteByEmail, |
3028 | 137 async_=True, |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
138 ) |
2231 | 139 |
2616
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
140 def getHandler(self, client): |
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
141 return EventsHandler(self) |
2243
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
142 |
2616
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
143 def _parseEventElt(self, event_elt): |
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
144 """Helper method to parse event element |
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
145 |
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
146 @param (domish.Element): event_elt |
2941
83cbd4545274
plugin events: fixed invitation + set name and thumb_url from event element
Goffi <goffi@goffi.org>
parents:
2935
diff
changeset
|
147 @return (tuple[int, dict[unicode, unicode]): timestamp, event_data |
2243
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
148 """ |
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
149 try: |
2612
3e4e78de9cca
tools (date_utils): moved date_parse to common.date_utils, because it can be used in frontends
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
150 timestamp = date_utils.date_parse(next(event_elt.elements(NS_EVENT, "date"))) |
2243
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
151 except StopIteration: |
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
152 timestamp = -1 |
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
153 |
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
154 data = {} |
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
155 |
3028 | 156 for key in ("name",): |
2243
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
157 try: |
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
158 data[key] = event_elt[key] |
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
159 except KeyError: |
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
160 continue |
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
161 |
3028 | 162 for elt_name in ("description",): |
2243
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
163 try: |
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
164 elt = next(event_elt.elements(NS_EVENT, elt_name)) |
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
165 except StopIteration: |
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
166 continue |
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
167 else: |
3028 | 168 data[elt_name] = str(elt) |
2243
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
169 |
3028 | 170 for elt_name in ("image", "background-image"): |
2243
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
171 try: |
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
172 image_elt = next(event_elt.elements(NS_EVENT, elt_name)) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
173 data[elt_name] = image_elt["src"] |
2243
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
174 except StopIteration: |
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
175 continue |
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
176 except KeyError: |
3028 | 177 log.warning(_("no src found for image")) |
2243
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
178 |
3028 | 179 for uri_type in ("invitees", "blog"): |
2243
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
180 try: |
2246
e8641b7718dc
plugin events: fixed blog/invitees uri handling
Goffi <goffi@goffi.org>
parents:
2243
diff
changeset
|
181 elt = next(event_elt.elements(NS_EVENT, uri_type)) |
3028 | 182 uri = data[uri_type + "_uri"] = elt["uri"] |
2616
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
183 uri_data = xmpp_uri.parseXMPPUri(uri) |
3028 | 184 if uri_data["type"] != "pubsub": |
2243
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
185 raise ValueError |
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
186 except StopIteration: |
3028 | 187 log.warning(_("no {uri_type} element found!").format(uri_type=uri_type)) |
2243
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
188 except KeyError: |
3028 | 189 log.warning(_("incomplete {uri_type} element").format(uri_type=uri_type)) |
2243
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
190 except ValueError: |
3028 | 191 log.warning(_("bad {uri_type} element").format(uri_type=uri_type)) |
2243
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
192 else: |
3028 | 193 data[uri_type + "_service"] = uri_data["path"] |
194 data[uri_type + "_node"] = uri_data["node"] | |
2243
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
195 |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
196 for meta_elt in event_elt.elements(NS_EVENT, "meta"): |
3028 | 197 key = meta_elt["name"] |
2243
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
198 if key in data: |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
199 log.warning( |
3028 | 200 "Ignoring conflicting meta element: {xml}".format( |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
201 xml=meta_elt.toXml() |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
202 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
203 ) |
2243
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
204 continue |
3028 | 205 data[key] = str(meta_elt) |
2616
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
206 if event_elt.link: |
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
207 link_elt = event_elt.link |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
208 data["service"] = link_elt["service"] |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
209 data["node"] = link_elt["node"] |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
210 data["item"] = link_elt["item"] |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
211 if event_elt.getAttribute("creator") == "true": |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
212 data["creator"] = True |
2616
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
213 return timestamp, data |
2243
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
214 |
3584
edc79cefe968
plugin XEP-0060: `getItem(s)`, `publish` and `(un)subscribe` are now coroutines
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
215 async def getEventElement(self, client, service, node, id_): |
2616
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
216 """Retrieve event element |
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
217 |
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
218 @param service(jid.JID): pubsub service |
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
219 @param node(unicode): pubsub node |
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
220 @param id_(unicode, None): event id |
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
221 @return (domish.Element): event element |
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
222 @raise exceptions.NotFound: no event element found |
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
223 """ |
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
224 if not id_: |
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
225 id_ = NS_EVENT |
3584
edc79cefe968
plugin XEP-0060: `getItem(s)`, `publish` and `(un)subscribe` are now coroutines
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
226 items, metadata = await self._p.getItems(client, service, node, item_ids=[id_]) |
2616
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
227 try: |
3028 | 228 event_elt = next(items[0].elements(NS_EVENT, "event")) |
2912
a3faf1c86596
plugin events: refactored invitation and personal lists logic:
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
229 except StopIteration: |
3028 | 230 raise exceptions.NotFound(_("No event element has been found")) |
2616
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
231 except IndexError: |
3028 | 232 raise exceptions.NotFound(_("No event with this id has been found")) |
3584
edc79cefe968
plugin XEP-0060: `getItem(s)`, `publish` and `(un)subscribe` are now coroutines
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
233 return event_elt |
2616
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
234 |
3028 | 235 def _eventGet(self, service, node, id_="", profile_key=C.PROF_KEY_NONE): |
2616
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
236 service = jid.JID(service) if service else None |
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
237 node = node if node else NS_EVENT |
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
238 client = self.host.getClient(profile_key) |
3584
edc79cefe968
plugin XEP-0060: `getItem(s)`, `publish` and `(un)subscribe` are now coroutines
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
239 return defer.ensureDeferred( |
edc79cefe968
plugin XEP-0060: `getItem(s)`, `publish` and `(un)subscribe` are now coroutines
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
240 self.eventGet(client, service, node, id_) |
edc79cefe968
plugin XEP-0060: `getItem(s)`, `publish` and `(un)subscribe` are now coroutines
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
241 ) |
2616
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
242 |
3584
edc79cefe968
plugin XEP-0060: `getItem(s)`, `publish` and `(un)subscribe` are now coroutines
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
243 async def eventGet(self, client, service, node, id_=NS_EVENT): |
2616
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
244 """Retrieve event data |
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
245 |
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
246 @param service(unicode, None): PubSub service |
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
247 @param node(unicode): PubSub node of the event |
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
248 @param id_(unicode): id_ with even data |
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
249 @return (tuple[int, dict[unicode, unicode]): event data: |
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
250 - timestamp of the event |
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
251 - event metadata where key can be: |
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
252 location: location of the event |
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
253 image: URL of a picture to use to represent event |
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
254 background-image: URL of a picture to use in background |
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
255 """ |
3584
edc79cefe968
plugin XEP-0060: `getItem(s)`, `publish` and `(un)subscribe` are now coroutines
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
256 event_elt = await self.getEventElement(client, service, node, id_) |
2616
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
257 |
3584
edc79cefe968
plugin XEP-0060: `getItem(s)`, `publish` and `(un)subscribe` are now coroutines
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
258 return self._parseEventElt(event_elt) |
2243
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
259 |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
260 def _eventCreate( |
3028 | 261 self, timestamp, data, service, node, id_="", profile_key=C.PROF_KEY_NONE |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
262 ): |
2243
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
263 service = jid.JID(service) if service else None |
2616
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
264 node = node or None |
2243
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
265 client = self.host.getClient(profile_key) |
3028 | 266 data["register"] = C.bool(data.get("register", C.BOOL_FALSE)) |
3462
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
267 return defer.ensureDeferred( |
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
268 self.eventCreate(client, timestamp, data, service, node, id_ or NS_EVENT) |
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
269 ) |
2231 | 270 |
3462
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
271 async def eventCreate(self, client, timestamp, data, service, node=None, event_id=NS_EVENT): |
2243
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
272 """Create or replace an event |
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
273 |
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
274 @param service(jid.JID, None): PubSub service |
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
275 @param node(unicode, None): PubSub node of the event |
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
276 None will create instant node. |
2616
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
277 @param event_id(unicode): ID of the item to create. |
2243
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
278 @param timestamp(timestamp, None) |
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
279 @param data(dict[unicode, unicode]): data to update |
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
280 dict will be cleared, do a copy if data are still needed |
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
281 key can be: |
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
282 - name: name of the event |
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
283 - description: details |
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
284 - image: main picture of the event |
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
285 - background-image: image to use as background |
2616
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
286 - register: bool, True if we want to register the event in our local list |
2243
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
287 @return (unicode): created node |
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
288 """ |
2616
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
289 if not event_id: |
3028 | 290 raise ValueError(_("event_id must be set")) |
2243
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
291 if not service: |
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
292 service = client.jid.userhostJID() |
2616
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
293 if not node: |
3028 | 294 node = NS_EVENT + "__" + shortuuid.uuid() |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
295 event_elt = domish.Element((NS_EVENT, "event")) |
2243
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
296 if timestamp is not None and timestamp != -1: |
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
297 formatted_date = utils.xmpp_date(timestamp) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
298 event_elt.addElement((NS_EVENT, "date"), content=formatted_date) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
299 register = data.pop("register", False) |
3028 | 300 for key in ("name",): |
2243
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
301 if key in data: |
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
302 event_elt[key] = data.pop(key) |
3028 | 303 for key in ("description",): |
2243
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
304 if key in data: |
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
305 event_elt.addElement((NS_EVENT, key), content=data.pop(key)) |
3028 | 306 for key in ("image", "background-image"): |
2243
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
307 if key in data: |
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
308 elt = event_elt.addElement((NS_EVENT, key)) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
309 elt["src"] = data.pop(key) |
2243
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
310 |
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
311 # we first create the invitees and blog nodes (if not specified in data) |
3028 | 312 for uri_type in ("invitees", "blog"): |
313 key = uri_type + "_uri" | |
314 for to_delete in ("service", "node"): | |
315 k = uri_type + "_" + to_delete | |
2246
e8641b7718dc
plugin events: fixed blog/invitees uri handling
Goffi <goffi@goffi.org>
parents:
2243
diff
changeset
|
316 if k in data: |
e8641b7718dc
plugin events: fixed blog/invitees uri handling
Goffi <goffi@goffi.org>
parents:
2243
diff
changeset
|
317 del data[k] |
2243
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
318 if key not in data: |
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
319 # FIXME: affiliate invitees |
3462
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
320 uri_node = await self._p.createNode(client, service) |
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
321 await self._p.setConfiguration( |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
322 client, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
323 service, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
324 uri_node, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
325 {self._p.OPT_ACCESS_MODEL: self._p.ACCESS_WHITELIST}, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
326 ) |
2243
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
327 uri_service = service |
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
328 else: |
2246
e8641b7718dc
plugin events: fixed blog/invitees uri handling
Goffi <goffi@goffi.org>
parents:
2243
diff
changeset
|
329 uri = data.pop(key) |
2616
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
330 uri_data = xmpp_uri.parseXMPPUri(uri) |
3028 | 331 if uri_data["type"] != "pubsub": |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
332 raise ValueError( |
3028 | 333 _("The given URI is not valid: {uri}").format(uri=uri) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
334 ) |
3028 | 335 uri_service = jid.JID(uri_data["path"]) |
336 uri_node = uri_data["node"] | |
2243
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
337 |
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
338 elt = event_elt.addElement((NS_EVENT, uri_type)) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
339 elt["uri"] = xmpp_uri.buildXMPPUri( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
340 "pubsub", path=uri_service.full(), node=uri_node |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
341 ) |
2243
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
342 |
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
343 # remaining data are put in <meta> elements |
3028 | 344 for key in list(data.keys()): |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
345 elt = event_elt.addElement((NS_EVENT, "meta"), content=data.pop(key)) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
346 elt["name"] = key |
2243
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
347 |
2616
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
348 item_elt = pubsub.Item(id=event_id, payload=event_elt) |
2243
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
349 try: |
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
350 # TODO: check auto-create, no need to create node first if available |
3462
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
351 node = await self._p.createNode(client, service, nodeIdentifier=node) |
2243
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
352 except error.StanzaError as e: |
3028 | 353 if e.condition == "conflict": |
354 log.debug(_("requested node already exists")) | |
2243
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
355 |
3462
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
356 await self._p.publish(client, service, node, items=[item_elt]) |
2243
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
357 |
2616
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
358 if register: |
3462
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
359 extra = {} |
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
360 self.onInvitationPreflight( |
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
361 client, "", extra, service, node, event_id, item_elt |
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
362 ) |
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
363 await self.host.plugins['LIST_INTEREST'].registerPubsub( |
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
364 client, NS_EVENT, service, node, event_id, True, |
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
365 extra.pop("name", ""), extra.pop("element"), extra |
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
366 ) |
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
367 return node |
2243
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
368 |
2912
a3faf1c86596
plugin events: refactored invitation and personal lists logic:
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
369 def _eventModify(self, service, node, id_, timestamp_update, data_update, |
a3faf1c86596
plugin events: refactored invitation and personal lists logic:
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
370 profile_key=C.PROF_KEY_NONE): |
2243
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
371 service = jid.JID(service) if service else None |
2912
a3faf1c86596
plugin events: refactored invitation and personal lists logic:
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
372 if not node: |
3028 | 373 raise ValueError(_("missing node")) |
2243
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
374 client = self.host.getClient(profile_key) |
3462
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
375 return defer.ensureDeferred( |
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
376 self.eventModify( |
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
377 client, service, node, id_ or NS_EVENT, timestamp_update or None, |
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
378 data_update |
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
379 ) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
380 ) |
2243
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
381 |
3462
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
382 async def eventModify( |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
383 self, client, service, node, id_=NS_EVENT, timestamp_update=None, data_update=None |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
384 ): |
2243
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
385 """Update an event |
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
386 |
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
387 Similar as create instead that it update existing item instead of |
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
388 creating or replacing it. Params are the same as for [eventCreate]. |
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
389 """ |
3462
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
390 event_timestamp, event_metadata = await self.eventGet(client, service, node, id_) |
2243
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
391 new_timestamp = event_timestamp if timestamp_update is None else timestamp_update |
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
392 new_data = event_metadata |
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
393 if data_update: |
3028 | 394 for k, v in data_update.items(): |
2243
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
395 new_data[k] = v |
3462
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
396 await self.eventCreate(client, new_timestamp, new_data, service, node, id_) |
2243
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
397 |
2616
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
398 def _eventsListSerialise(self, events): |
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
399 for timestamp, data in events: |
3028 | 400 data["date"] = str(timestamp) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
401 data["creator"] = C.boolConst(data.get("creator", False)) |
2616
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
402 return [e[1] for e in events] |
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
403 |
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
404 def _eventsList(self, service, node, profile): |
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
405 service = jid.JID(service) if service else None |
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
406 node = node or None |
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
407 client = self.host.getClient(profile) |
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
408 d = self.eventsList(client, service, node) |
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
409 d.addCallback(self._eventsListSerialise) |
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
410 return d |
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
411 |
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
412 @defer.inlineCallbacks |
2912
a3faf1c86596
plugin events: refactored invitation and personal lists logic:
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
413 def eventsList(self, client, service, node=None): |
2616
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
414 """Retrieve list of registered events |
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
415 |
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
416 @return list(tuple(int, dict)): list of events (timestamp + metadata) |
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
417 """ |
3028 | 418 items, metadata = yield self.host.plugins['LIST_INTEREST'].listInterests( |
2912
a3faf1c86596
plugin events: refactored invitation and personal lists logic:
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
419 client, service, node, namespace=NS_EVENT) |
2616
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
420 events = [] |
2912
a3faf1c86596
plugin events: refactored invitation and personal lists logic:
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
421 for item in items: |
2616
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
422 try: |
3028 | 423 event_elt = next(item.interest.pubsub.elements(NS_EVENT, "event")) |
2941
83cbd4545274
plugin events: fixed invitation + set name and thumb_url from event element
Goffi <goffi@goffi.org>
parents:
2935
diff
changeset
|
424 except StopIteration: |
2912
a3faf1c86596
plugin events: refactored invitation and personal lists logic:
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
425 log.warning( |
3028 | 426 _("No event found in item {item_id}, ignoring").format( |
2941
83cbd4545274
plugin events: fixed invitation + set name and thumb_url from event element
Goffi <goffi@goffi.org>
parents:
2935
diff
changeset
|
427 item_id=item["id"]) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
428 ) |
2912
a3faf1c86596
plugin events: refactored invitation and personal lists logic:
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
429 else: |
a3faf1c86596
plugin events: refactored invitation and personal lists logic:
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
430 timestamp, data = self._parseEventElt(event_elt) |
3708
09112b1c3e05
plugin events: store `interest_id` in data:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
431 data["interest_id"] = item["id"] |
2912
a3faf1c86596
plugin events: refactored invitation and personal lists logic:
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
432 events.append((timestamp, data)) |
2616
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
433 defer.returnValue(events) |
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
434 |
3040 | 435 def _eventInviteeGet(self, service, node, invitee_jid_s, profile_key): |
2243
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
436 service = jid.JID(service) if service else None |
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
437 node = node if node else NS_EVENT |
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
438 client = self.host.getClient(profile_key) |
3040 | 439 invitee_jid = jid.JID(invitee_jid_s) if invitee_jid_s else None |
3584
edc79cefe968
plugin XEP-0060: `getItem(s)`, `publish` and `(un)subscribe` are now coroutines
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
440 return defer.ensureDeferred( |
edc79cefe968
plugin XEP-0060: `getItem(s)`, `publish` and `(un)subscribe` are now coroutines
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
441 self.eventInviteeGet(client, service, node, invitee_jid) |
edc79cefe968
plugin XEP-0060: `getItem(s)`, `publish` and `(un)subscribe` are now coroutines
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
442 ) |
2243
5e12fc5ae52a
plugin events: separation of event node and invitees node
Goffi <goffi@goffi.org>
parents:
2231
diff
changeset
|
443 |
3584
edc79cefe968
plugin XEP-0060: `getItem(s)`, `publish` and `(un)subscribe` are now coroutines
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
444 async def eventInviteeGet(self, client, service, node, invitee_jid=None): |
2231 | 445 """Retrieve attendance from event node |
446 | |
447 @param service(unicode, None): PubSub service | |
3040 | 448 @param node(unicode): PubSub node of the event's invitees |
449 @param invitee_jid(jid.JId, None): jid of the invitee to retrieve (None to | |
450 retrieve profile's invitation). The bare jid correspond to the PubSub item id. | |
2231 | 451 @return (dict): a dict with current attendance status, |
452 an empty dict is returned if nothing has been answered yed | |
453 """ | |
3040 | 454 if invitee_jid is None: |
455 invitee_jid = client.jid | |
2231 | 456 try: |
3584
edc79cefe968
plugin XEP-0060: `getItem(s)`, `publish` and `(un)subscribe` are now coroutines
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
457 items, metadata = await self._p.getItems( |
3040 | 458 client, service, node, item_ids=[invitee_jid.userhost()] |
2912
a3faf1c86596
plugin events: refactored invitation and personal lists logic:
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
459 ) |
3028 | 460 event_elt = next(items[0].elements(NS_EVENT, "invitee")) |
2912
a3faf1c86596
plugin events: refactored invitation and personal lists logic:
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
461 except (exceptions.NotFound, IndexError): |
2231 | 462 # no item found, event data are not set yet |
3584
edc79cefe968
plugin XEP-0060: `getItem(s)`, `publish` and `(un)subscribe` are now coroutines
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
463 return {} |
2231 | 464 data = {} |
3028 | 465 for key in ("attend", "guests"): |
2231 | 466 try: |
467 data[key] = event_elt[key] | |
468 except KeyError: | |
469 continue | |
3584
edc79cefe968
plugin XEP-0060: `getItem(s)`, `publish` and `(un)subscribe` are now coroutines
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
470 return data |
2231 | 471 |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
472 def _eventInviteeSet(self, service, node, event_data, profile_key): |
2231 | 473 service = jid.JID(service) if service else None |
474 node = node if node else NS_EVENT | |
475 client = self.host.getClient(profile_key) | |
3584
edc79cefe968
plugin XEP-0060: `getItem(s)`, `publish` and `(un)subscribe` are now coroutines
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
476 return defer.ensureDeferred( |
edc79cefe968
plugin XEP-0060: `getItem(s)`, `publish` and `(un)subscribe` are now coroutines
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
477 self.eventInviteeSet(client, service, node, event_data) |
edc79cefe968
plugin XEP-0060: `getItem(s)`, `publish` and `(un)subscribe` are now coroutines
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
478 ) |
2231 | 479 |
3584
edc79cefe968
plugin XEP-0060: `getItem(s)`, `publish` and `(un)subscribe` are now coroutines
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
480 async def eventInviteeSet(self, client, service, node, data): |
2231 | 481 """Set or update attendance data in event node |
482 | |
483 @param service(unicode, None): PubSub service | |
484 @param node(unicode): PubSub node of the event | |
485 @param data(dict[unicode, unicode]): data to update | |
486 key can be: | |
487 attend: one of "yes", "no", "maybe" | |
488 guests: an int | |
489 """ | |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
490 event_elt = domish.Element((NS_EVENT, "invitee")) |
3028 | 491 for key in ("attend", "guests"): |
2231 | 492 try: |
493 event_elt[key] = data.pop(key) | |
494 except KeyError: | |
495 pass | |
496 item_elt = pubsub.Item(id=client.jid.userhost(), payload=event_elt) | |
3584
edc79cefe968
plugin XEP-0060: `getItem(s)`, `publish` and `(un)subscribe` are now coroutines
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
497 return await self._p.publish(client, service, node, items=[item_elt]) |
2287
ea869f30f204
plugin events: added eventInvite command as a helper for the complex invitation workflow:
Goffi <goffi@goffi.org>
parents:
2272
diff
changeset
|
498 |
2294
78048f002a3c
plugin events: added eventInviteesList method to get all R.S.V.P. at once.
Goffi <goffi@goffi.org>
parents:
2291
diff
changeset
|
499 def _eventInviteesList(self, service, node, profile_key): |
78048f002a3c
plugin events: added eventInviteesList method to get all R.S.V.P. at once.
Goffi <goffi@goffi.org>
parents:
2291
diff
changeset
|
500 service = jid.JID(service) if service else None |
78048f002a3c
plugin events: added eventInviteesList method to get all R.S.V.P. at once.
Goffi <goffi@goffi.org>
parents:
2291
diff
changeset
|
501 node = node if node else NS_EVENT |
78048f002a3c
plugin events: added eventInviteesList method to get all R.S.V.P. at once.
Goffi <goffi@goffi.org>
parents:
2291
diff
changeset
|
502 client = self.host.getClient(profile_key) |
3584
edc79cefe968
plugin XEP-0060: `getItem(s)`, `publish` and `(un)subscribe` are now coroutines
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
503 return defer.ensureDeferred( |
edc79cefe968
plugin XEP-0060: `getItem(s)`, `publish` and `(un)subscribe` are now coroutines
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
504 self.eventInviteesList(client, service, node) |
edc79cefe968
plugin XEP-0060: `getItem(s)`, `publish` and `(un)subscribe` are now coroutines
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
505 ) |
2294
78048f002a3c
plugin events: added eventInviteesList method to get all R.S.V.P. at once.
Goffi <goffi@goffi.org>
parents:
2291
diff
changeset
|
506 |
3584
edc79cefe968
plugin XEP-0060: `getItem(s)`, `publish` and `(un)subscribe` are now coroutines
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
507 async def eventInviteesList(self, client, service, node): |
2294
78048f002a3c
plugin events: added eventInviteesList method to get all R.S.V.P. at once.
Goffi <goffi@goffi.org>
parents:
2291
diff
changeset
|
508 """Retrieve attendance from event node |
78048f002a3c
plugin events: added eventInviteesList method to get all R.S.V.P. at once.
Goffi <goffi@goffi.org>
parents:
2291
diff
changeset
|
509 |
78048f002a3c
plugin events: added eventInviteesList method to get all R.S.V.P. at once.
Goffi <goffi@goffi.org>
parents:
2291
diff
changeset
|
510 @param service(unicode, None): PubSub service |
78048f002a3c
plugin events: added eventInviteesList method to get all R.S.V.P. at once.
Goffi <goffi@goffi.org>
parents:
2291
diff
changeset
|
511 @param node(unicode): PubSub node of the event |
78048f002a3c
plugin events: added eventInviteesList method to get all R.S.V.P. at once.
Goffi <goffi@goffi.org>
parents:
2291
diff
changeset
|
512 @return (dict): a dict with current attendance status, |
78048f002a3c
plugin events: added eventInviteesList method to get all R.S.V.P. at once.
Goffi <goffi@goffi.org>
parents:
2291
diff
changeset
|
513 an empty dict is returned if nothing has been answered yed |
78048f002a3c
plugin events: added eventInviteesList method to get all R.S.V.P. at once.
Goffi <goffi@goffi.org>
parents:
2291
diff
changeset
|
514 """ |
3584
edc79cefe968
plugin XEP-0060: `getItem(s)`, `publish` and `(un)subscribe` are now coroutines
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
515 items, metadata = await self._p.getItems(client, service, node) |
2294
78048f002a3c
plugin events: added eventInviteesList method to get all R.S.V.P. at once.
Goffi <goffi@goffi.org>
parents:
2291
diff
changeset
|
516 invitees = {} |
78048f002a3c
plugin events: added eventInviteesList method to get all R.S.V.P. at once.
Goffi <goffi@goffi.org>
parents:
2291
diff
changeset
|
517 for item in items: |
78048f002a3c
plugin events: added eventInviteesList method to get all R.S.V.P. at once.
Goffi <goffi@goffi.org>
parents:
2291
diff
changeset
|
518 try: |
3028 | 519 event_elt = next(item.elements(NS_EVENT, "invitee")) |
2616
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
520 except StopIteration: |
2294
78048f002a3c
plugin events: added eventInviteesList method to get all R.S.V.P. at once.
Goffi <goffi@goffi.org>
parents:
2291
diff
changeset
|
521 # no item found, event data are not set yet |
2912
a3faf1c86596
plugin events: refactored invitation and personal lists logic:
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
522 log.warning(_( |
3028 | 523 "no data found for {item_id} (service: {service}, node: {node})" |
2912
a3faf1c86596
plugin events: refactored invitation and personal lists logic:
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
524 .format(item_id=item["id"], service=service, node=node))) |
2616
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
525 else: |
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
526 data = {} |
3028 | 527 for key in ("attend", "guests"): |
2616
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
528 try: |
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
529 data[key] = event_elt[key] |
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
530 except KeyError: |
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
531 continue |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
532 invitees[item["id"]] = data |
3584
edc79cefe968
plugin XEP-0060: `getItem(s)`, `publish` and `(un)subscribe` are now coroutines
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
533 return invitees |
2294
78048f002a3c
plugin events: added eventInviteesList method to get all R.S.V.P. at once.
Goffi <goffi@goffi.org>
parents:
2291
diff
changeset
|
534 |
3462
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
535 async def invitePreflight( |
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
536 self, |
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
537 client: SatXMPPEntity, |
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
538 invitee_jid: jid.JID, |
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
539 service: jid.JID, |
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
540 node: str, |
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
541 item_id: Optional[str] = None, |
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
542 name: str = '', |
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
543 extra: Optional[dict] = None, |
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
544 ) -> None: |
2616
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
545 if self._b is None: |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
546 raise exceptions.FeatureNotFound( |
3028 | 547 _('"XEP-0277" (blog) plugin is needed for this feature') |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
548 ) |
2616
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
549 if item_id is None: |
3462
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
550 item_id = extra["default_item_id"] = NS_EVENT |
2616
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
551 |
3462
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
552 __, event_data = await self.eventGet(client, service, node, item_id) |
3028 | 553 log.debug(_("got event data")) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
554 invitees_service = jid.JID(event_data["invitees_service"]) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
555 invitees_node = event_data["invitees_node"] |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
556 blog_service = jid.JID(event_data["blog_service"]) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
557 blog_node = event_data["blog_node"] |
3462
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
558 await self._p.setNodeAffiliations( |
3028 | 559 client, invitees_service, invitees_node, {invitee_jid: "publisher"} |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
560 ) |
3462
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
561 log.debug( |
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
562 f"affiliation set on invitee node (jid: {invitees_service}, " |
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
563 f"node: {invitees_node!r})" |
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
564 ) |
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
565 await self._p.setNodeAffiliations( |
3028 | 566 client, blog_service, blog_node, {invitee_jid: "member"} |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
567 ) |
3462
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
568 blog_items, __ = await self._b.mbGet(client, blog_service, blog_node, None) |
2616
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
569 |
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
570 for item in blog_items: |
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
571 try: |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
572 comments_service = jid.JID(item["comments_service"]) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
573 comments_node = item["comments_node"] |
2616
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
574 except KeyError: |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
575 log.debug( |
3028 | 576 "no comment service set for item {item_id}".format( |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
577 item_id=item["id"] |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
578 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
579 ) |
2616
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
580 else: |
3462
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
581 await self._p.setNodeAffiliations( |
3028 | 582 client, comments_service, comments_node, {invitee_jid: "publisher"} |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
583 ) |
3028 | 584 log.debug(_("affiliation set on blog and comments nodes")) |
2616
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
585 |
3462
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
586 def _invite(self, invitee_jid, service, node, item_id, profile): |
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
587 return self.host.plugins["PUBSUB_INVITATION"]._sendPubsubInvitation( |
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
588 invitee_jid, service, node, item_id or NS_EVENT, profile_key=profile |
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
589 ) |
2616
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
590 |
3028 | 591 def _inviteByEmail(self, service, node, id_=NS_EVENT, email="", emails_extra=None, |
592 name="", host_name="", language="", url_template="", | |
593 message_subject="", message_body="", | |
2912
a3faf1c86596
plugin events: refactored invitation and personal lists logic:
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
594 profile_key=C.PROF_KEY_NONE): |
2287
ea869f30f204
plugin events: added eventInvite command as a helper for the complex invitation workflow:
Goffi <goffi@goffi.org>
parents:
2272
diff
changeset
|
595 client = self.host.getClient(profile_key) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
596 kwargs = { |
3028 | 597 "profile": client.profile, |
598 "emails_extra": [str(e) for e in emails_extra], | |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
599 } |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
600 for key in ( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
601 "email", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
602 "name", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
603 "host_name", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
604 "language", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
605 "url_template", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
606 "message_subject", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
607 "message_body", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
608 ): |
2287
ea869f30f204
plugin events: added eventInvite command as a helper for the complex invitation workflow:
Goffi <goffi@goffi.org>
parents:
2272
diff
changeset
|
609 value = locals()[key] |
3028 | 610 kwargs[key] = str(value) |
3462
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
611 return defer.ensureDeferred(self.inviteByEmail( |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
612 client, jid.JID(service) if service else None, node, id_ or NS_EVENT, **kwargs |
3462
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
613 )) |
2287
ea869f30f204
plugin events: added eventInvite command as a helper for the complex invitation workflow:
Goffi <goffi@goffi.org>
parents:
2272
diff
changeset
|
614 |
3462
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
615 async def inviteByEmail(self, client, service, node, id_=NS_EVENT, **kwargs): |
2287
ea869f30f204
plugin events: added eventInvite command as a helper for the complex invitation workflow:
Goffi <goffi@goffi.org>
parents:
2272
diff
changeset
|
616 """High level method to create an email invitation to an event |
ea869f30f204
plugin events: added eventInvite command as a helper for the complex invitation workflow:
Goffi <goffi@goffi.org>
parents:
2272
diff
changeset
|
617 |
ea869f30f204
plugin events: added eventInvite command as a helper for the complex invitation workflow:
Goffi <goffi@goffi.org>
parents:
2272
diff
changeset
|
618 @param service(unicode, None): PubSub service |
ea869f30f204
plugin events: added eventInvite command as a helper for the complex invitation workflow:
Goffi <goffi@goffi.org>
parents:
2272
diff
changeset
|
619 @param node(unicode): PubSub node of the event |
ea869f30f204
plugin events: added eventInvite command as a helper for the complex invitation workflow:
Goffi <goffi@goffi.org>
parents:
2272
diff
changeset
|
620 @param id_(unicode): id_ with even data |
ea869f30f204
plugin events: added eventInvite command as a helper for the complex invitation workflow:
Goffi <goffi@goffi.org>
parents:
2272
diff
changeset
|
621 """ |
ea869f30f204
plugin events: added eventInvite command as a helper for the complex invitation workflow:
Goffi <goffi@goffi.org>
parents:
2272
diff
changeset
|
622 if self._i is None: |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
623 raise exceptions.FeatureNotFound( |
3028 | 624 _('"Invitations" plugin is needed for this feature') |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
625 ) |
2287
ea869f30f204
plugin events: added eventInvite command as a helper for the complex invitation workflow:
Goffi <goffi@goffi.org>
parents:
2272
diff
changeset
|
626 if self._b is None: |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
627 raise exceptions.FeatureNotFound( |
3028 | 628 _('"XEP-0277" (blog) plugin is needed for this feature') |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
629 ) |
2616
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
630 service = service or client.jid.userhostJID() |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
631 event_uri = xmpp_uri.buildXMPPUri( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
632 "pubsub", path=service.full(), node=node, item=id_ |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
633 ) |
3028 | 634 kwargs["extra"] = {"event_uri": event_uri} |
3462
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
635 invitation_data = await self._i.create(**kwargs) |
3028 | 636 invitee_jid = invitation_data["jid"] |
637 log.debug(_("invitation created")) | |
2616
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
638 # now that we have a jid, we can send normal invitation |
3462
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
639 await self.invite(client, invitee_jid, service, node, id_) |
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
640 |
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
641 def onInvitationPreflight( |
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
642 self, |
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
643 client: SatXMPPEntity, |
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
644 name: str, |
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
645 extra: dict, |
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
646 service: jid.JID, |
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
647 node: str, |
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
648 item_id: Optional[str], |
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
649 item_elt: domish.Element |
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
650 ) -> None: |
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
651 event_elt = item_elt.event |
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
652 link_elt = event_elt.addElement("link") |
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
653 link_elt["service"] = service.full() |
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
654 link_elt["node"] = node |
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
655 link_elt["item"] = item_id |
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
656 __, event_data = self._parseEventElt(event_elt) |
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
657 try: |
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
658 name = event_data["name"] |
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
659 except KeyError: |
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
660 pass |
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
661 else: |
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
662 extra["name"] = name |
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
663 if 'image' in event_data: |
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
664 extra["thumb_url"] = event_data['image'] |
12dc234f698c
plugin invitation: pubsub invitations:
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
665 extra["element"] = event_elt |
2287
ea869f30f204
plugin events: added eventInvite command as a helper for the complex invitation workflow:
Goffi <goffi@goffi.org>
parents:
2272
diff
changeset
|
666 |
ea869f30f204
plugin events: added eventInvite command as a helper for the complex invitation workflow:
Goffi <goffi@goffi.org>
parents:
2272
diff
changeset
|
667 |
3028 | 668 @implementer(iwokkel.IDisco) |
2616
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
669 class EventsHandler(XMPPHandler): |
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
670 |
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
671 def __init__(self, plugin_parent): |
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
672 self.plugin_parent = plugin_parent |
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
673 |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
674 def getDiscoInfo(self, requestor, target, nodeIdentifier=""): |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
675 return [ |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
676 disco.DiscoFeature(NS_EVENT), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
677 ] |
2616
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
678 |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2616
diff
changeset
|
679 def getDiscoItems(self, requestor, target, nodeIdentifier=""): |
2616
1cc88adb5142
plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents:
2612
diff
changeset
|
680 return [] |