Mercurial > libervia-backend
annotate libervia/backend/plugins/plugin_misc_groupblog.py @ 4387:a6270030968d default tip
doc (components): Document the handling of mailing lists in Email Gateway:
fix 462
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 03 Aug 2025 23:45:48 +0200 |
parents | 7c1d77efc752 |
children |
rev | line source |
---|---|
3028 | 1 #!/usr/bin/env python3 |
3137 | 2 |
307 | 3 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
594
diff
changeset
|
4 # SAT plugin for microbloging with roster access |
3479 | 5 # Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org) |
307 | 6 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
594
diff
changeset
|
7 # This program is free software: you can redistribute it and/or modify |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
594
diff
changeset
|
8 # it under the terms of the GNU Affero General Public License as published by |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
594
diff
changeset
|
9 # the Free Software Foundation, either version 3 of the License, or |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
594
diff
changeset
|
10 # (at your option) any later version. |
307 | 11 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
594
diff
changeset
|
12 # This program is distributed in the hope that it will be useful, |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
594
diff
changeset
|
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
594
diff
changeset
|
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
594
diff
changeset
|
15 # GNU Affero General Public License for more details. |
307 | 16 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
594
diff
changeset
|
17 # You should have received a copy of the GNU Affero General Public License |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
594
diff
changeset
|
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
307 | 19 |
4383
7c1d77efc752
plugin XEP-0277: Make MbData a Pydantic model:
Goffi <goffi@goffi.org>
parents:
4270
diff
changeset
|
20 from twisted.words.xish import domish |
7c1d77efc752
plugin XEP-0277: Make MbData a Pydantic model:
Goffi <goffi@goffi.org>
parents:
4270
diff
changeset
|
21 from libervia.backend.core.core_types import SatXMPPClient |
4071
4b842c1fb686
refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents:
4037
diff
changeset
|
22 from libervia.backend.core.i18n import _ |
4b842c1fb686
refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents:
4037
diff
changeset
|
23 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
|
24 from libervia.backend.core.log import getLogger |
4383
7c1d77efc752
plugin XEP-0277: Make MbData a Pydantic model:
Goffi <goffi@goffi.org>
parents:
4270
diff
changeset
|
25 from libervia.backend.plugins.plugin_xep_0277 import MbData |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
26 |
993
301b342c697a
core: use of the new core.log module:
Goffi <goffi@goffi.org>
parents:
944
diff
changeset
|
27 log = getLogger(__name__) |
476
b9fd32b46306
plugin groupblog: added disco info + misc fixes
Goffi <goffi@goffi.org>
parents:
471
diff
changeset
|
28 from twisted.internet import defer |
4071
4b842c1fb686
refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents:
4037
diff
changeset
|
29 from libervia.backend.core import exceptions |
476
b9fd32b46306
plugin groupblog: added disco info + misc fixes
Goffi <goffi@goffi.org>
parents:
471
diff
changeset
|
30 from wokkel import disco, data_form, iwokkel |
3028 | 31 from zope.interface import implementer |
615
6f4c31192c7c
plugins XEP-0060, XEP-0277, groupblog: comments implementation (first draft, not finished yet):
Goffi <goffi@goffi.org>
parents:
609
diff
changeset
|
32 |
476
b9fd32b46306
plugin groupblog: added disco info + misc fixes
Goffi <goffi@goffi.org>
parents:
471
diff
changeset
|
33 try: |
b9fd32b46306
plugin groupblog: added disco info + misc fixes
Goffi <goffi@goffi.org>
parents:
471
diff
changeset
|
34 from twisted.words.protocols.xmlstream import XMPPHandler |
b9fd32b46306
plugin groupblog: added disco info + misc fixes
Goffi <goffi@goffi.org>
parents:
471
diff
changeset
|
35 except ImportError: |
b9fd32b46306
plugin groupblog: added disco info + misc fixes
Goffi <goffi@goffi.org>
parents:
471
diff
changeset
|
36 from wokkel.subprotocols import XMPPHandler |
307 | 37 |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
38 NS_PUBSUB = "http://jabber.org/protocol/pubsub" |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
39 NS_GROUPBLOG = "http://salut-a-toi.org/protocol/groupblog" |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
40 # NS_PUBSUB_EXP = 'http://goffi.org/protocol/pubsub' #for non official features |
4270
0d7bb4df2343
Reformatted code base using black.
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
41 NS_PUBSUB_EXP = NS_PUBSUB # XXX: we can't use custom namespace as Wokkel's PubSubService use official NS |
1485
9fcc16ef163a
plugin groupblog: groupblog compatible pubsub service is checked in profileConected + getFeatures implementation
Goffi <goffi@goffi.org>
parents:
1459
diff
changeset
|
42 NS_PUBSUB_GROUPBLOG = NS_PUBSUB_EXP + "#groupblog" |
462
d9456d94cd12
plugin groupblog: next-gen group blog first draft
Goffi <goffi@goffi.org>
parents:
459
diff
changeset
|
43 NS_PUBSUB_ITEM_CONFIG = NS_PUBSUB_EXP + "#item-config" |
307 | 44 |
1268
bb30bf3ae932
plugins XEP-0060, XEP-0277, groupblog: make use of RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents:
1243
diff
changeset
|
45 |
307 | 46 PLUGIN_INFO = { |
2145
33c8c4973743
core (plugins): added missing contants + use of new constants in PLUGIN_INFO
Goffi <goffi@goffi.org>
parents:
2144
diff
changeset
|
47 C.PI_NAME: "Group blogging through collections", |
33c8c4973743
core (plugins): added missing contants + use of new constants in PLUGIN_INFO
Goffi <goffi@goffi.org>
parents:
2144
diff
changeset
|
48 C.PI_IMPORT_NAME: "GROUPBLOG", |
33c8c4973743
core (plugins): added missing contants + use of new constants in PLUGIN_INFO
Goffi <goffi@goffi.org>
parents:
2144
diff
changeset
|
49 C.PI_TYPE: "MISC", |
33c8c4973743
core (plugins): added missing contants + use of new constants in PLUGIN_INFO
Goffi <goffi@goffi.org>
parents:
2144
diff
changeset
|
50 C.PI_PROTOCOLS: [], |
33c8c4973743
core (plugins): added missing contants + use of new constants in PLUGIN_INFO
Goffi <goffi@goffi.org>
parents:
2144
diff
changeset
|
51 C.PI_DEPENDENCIES: ["XEP-0277"], |
33c8c4973743
core (plugins): added missing contants + use of new constants in PLUGIN_INFO
Goffi <goffi@goffi.org>
parents:
2144
diff
changeset
|
52 C.PI_MAIN: "GroupBlog", |
33c8c4973743
core (plugins): added missing contants + use of new constants in PLUGIN_INFO
Goffi <goffi@goffi.org>
parents:
2144
diff
changeset
|
53 C.PI_HANDLER: "yes", |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
54 C.PI_DESCRIPTION: _("""Implementation of microblogging fine permissions"""), |
307 | 55 } |
56 | |
594
e629371a28d3
Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
588
diff
changeset
|
57 |
588
beaf6bec2fcd
Remove every old-style class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
587
diff
changeset
|
58 class GroupBlog(object): |
462
d9456d94cd12
plugin groupblog: next-gen group blog first draft
Goffi <goffi@goffi.org>
parents:
459
diff
changeset
|
59 """This class use a SàT PubSub Service to manage access on microblog""" |
307 | 60 |
61 def __init__(self, host): | |
993
301b342c697a
core: use of the new core.log module:
Goffi <goffi@goffi.org>
parents:
944
diff
changeset
|
62 log.info(_("Group blog plugin initialization")) |
307 | 63 self.host = host |
1662
9aa2a703e460
plugin group blog: group permissions are used if "group*" keys are found in mbdata (in data2entry and comments trigger)
Goffi <goffi@goffi.org>
parents:
1552
diff
changeset
|
64 self._p = self.host.plugins["XEP-0060"] |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
65 host.trigger.add("XEP-0277_item2data", self._item_2_data_trigger) |
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
66 host.trigger.add("XEP-0277_data2entry", self._data_2_entry_trigger) |
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
67 host.trigger.add("XEP-0277_comments", self._comments_trigger) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
68 |
1420
7c0acb966fd6
plugins groupblog, xep-0060: first pass of simplification
Goffi <goffi@goffi.org>
parents:
1419
diff
changeset
|
69 ## plugin management methods ## |
7c0acb966fd6
plugins groupblog, xep-0060: first pass of simplification
Goffi <goffi@goffi.org>
parents:
1419
diff
changeset
|
70 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
71 def get_handler(self, client): |
476
b9fd32b46306
plugin groupblog: added disco info + misc fixes
Goffi <goffi@goffi.org>
parents:
471
diff
changeset
|
72 return GroupBlog_handler() |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
73 |
465
78e67a59d51d
plugin groupblog: added getLastGroupBlogs method
Goffi <goffi@goffi.org>
parents:
462
diff
changeset
|
74 @defer.inlineCallbacks |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
75 def profile_connected(self, client): |
1492
6ec2741b7268
plugin groupblog: item access availability on serveur is checked on profile connection, and getFeatures is filled accordingly (with "available" key)
Goffi <goffi@goffi.org>
parents:
1485
diff
changeset
|
76 try: |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
77 yield self.host.check_features(client, (NS_PUBSUB_GROUPBLOG,)) |
1492
6ec2741b7268
plugin groupblog: item access availability on serveur is checked on profile connection, and getFeatures is filled accordingly (with "available" key)
Goffi <goffi@goffi.org>
parents:
1485
diff
changeset
|
78 except exceptions.FeatureNotFound: |
6ec2741b7268
plugin groupblog: item access availability on serveur is checked on profile connection, and getFeatures is filled accordingly (with "available" key)
Goffi <goffi@goffi.org>
parents:
1485
diff
changeset
|
79 client.server_groupblog_available = False |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
80 log.warning( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
81 _( |
3028 | 82 "Server is not able to manage item-access pubsub, we can't use group blog" |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
83 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
84 ) |
1485
9fcc16ef163a
plugin groupblog: groupblog compatible pubsub service is checked in profileConected + getFeatures implementation
Goffi <goffi@goffi.org>
parents:
1459
diff
changeset
|
85 else: |
1492
6ec2741b7268
plugin groupblog: item access availability on serveur is checked on profile connection, and getFeatures is filled accordingly (with "available" key)
Goffi <goffi@goffi.org>
parents:
1485
diff
changeset
|
86 client.server_groupblog_available = True |
3028 | 87 log.info(_("Server can manage group blogs")) |
1485
9fcc16ef163a
plugin groupblog: groupblog compatible pubsub service is checked in profileConected + getFeatures implementation
Goffi <goffi@goffi.org>
parents:
1459
diff
changeset
|
88 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
89 def features_get(self, profile): |
1485
9fcc16ef163a
plugin groupblog: groupblog compatible pubsub service is checked in profileConected + getFeatures implementation
Goffi <goffi@goffi.org>
parents:
1459
diff
changeset
|
90 try: |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
91 client = self.host.get_client(profile) |
1485
9fcc16ef163a
plugin groupblog: groupblog compatible pubsub service is checked in profileConected + getFeatures implementation
Goffi <goffi@goffi.org>
parents:
1459
diff
changeset
|
92 except exceptions.ProfileNotSetError: |
9fcc16ef163a
plugin groupblog: groupblog compatible pubsub service is checked in profileConected + getFeatures implementation
Goffi <goffi@goffi.org>
parents:
1459
diff
changeset
|
93 return {} |
9fcc16ef163a
plugin groupblog: groupblog compatible pubsub service is checked in profileConected + getFeatures implementation
Goffi <goffi@goffi.org>
parents:
1459
diff
changeset
|
94 try: |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
95 return {"available": C.bool_const(client.server_groupblog_available)} |
1485
9fcc16ef163a
plugin groupblog: groupblog compatible pubsub service is checked in profileConected + getFeatures implementation
Goffi <goffi@goffi.org>
parents:
1459
diff
changeset
|
96 except AttributeError: |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
97 if self.host.is_connected(profile): |
1485
9fcc16ef163a
plugin groupblog: groupblog compatible pubsub service is checked in profileConected + getFeatures implementation
Goffi <goffi@goffi.org>
parents:
1459
diff
changeset
|
98 log.debug("Profile is not connected, service is not checked yet") |
9fcc16ef163a
plugin groupblog: groupblog compatible pubsub service is checked in profileConected + getFeatures implementation
Goffi <goffi@goffi.org>
parents:
1459
diff
changeset
|
99 else: |
1673
95522b37bf5a
plugin group blog: minor log change
Goffi <goffi@goffi.org>
parents:
1672
diff
changeset
|
100 log.error("client.server_groupblog_available should be available !") |
1485
9fcc16ef163a
plugin groupblog: groupblog compatible pubsub service is checked in profileConected + getFeatures implementation
Goffi <goffi@goffi.org>
parents:
1459
diff
changeset
|
101 return {} |
9fcc16ef163a
plugin groupblog: groupblog compatible pubsub service is checked in profileConected + getFeatures implementation
Goffi <goffi@goffi.org>
parents:
1459
diff
changeset
|
102 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
103 def _item_2_data_trigger(self, item_elt, entry_elt, microblog_data): |
1671
1895846fc9cb
plugin XEP-0277, group blog: added item2data trigger + group permission are parsed when receiving a new item
Goffi <goffi@goffi.org>
parents:
1664
diff
changeset
|
104 """Parse item to find group permission elements""" |
1895846fc9cb
plugin XEP-0277, group blog: added item2data trigger + group permission are parsed when receiving a new item
Goffi <goffi@goffi.org>
parents:
1664
diff
changeset
|
105 config_form = data_form.findForm(item_elt, NS_PUBSUB_ITEM_CONFIG) |
1895846fc9cb
plugin XEP-0277, group blog: added item2data trigger + group permission are parsed when receiving a new item
Goffi <goffi@goffi.org>
parents:
1664
diff
changeset
|
106 if config_form is None: |
1895846fc9cb
plugin XEP-0277, group blog: added item2data trigger + group permission are parsed when receiving a new item
Goffi <goffi@goffi.org>
parents:
1664
diff
changeset
|
107 return |
4383
7c1d77efc752
plugin XEP-0277: Make MbData a Pydantic model:
Goffi <goffi@goffi.org>
parents:
4270
diff
changeset
|
108 # FIXME: Legacy code, need to be adapted to new MbData model. |
7c1d77efc752
plugin XEP-0277: Make MbData a Pydantic model:
Goffi <goffi@goffi.org>
parents:
4270
diff
changeset
|
109 log.warning( |
7c1d77efc752
plugin XEP-0277: Make MbData a Pydantic model:
Goffi <goffi@goffi.org>
parents:
4270
diff
changeset
|
110 "Item config is temporarily not supported, it needs to be moved to " |
7c1d77efc752
plugin XEP-0277: Make MbData a Pydantic model:
Goffi <goffi@goffi.org>
parents:
4270
diff
changeset
|
111 "adapted to new model" |
7c1d77efc752
plugin XEP-0277: Make MbData a Pydantic model:
Goffi <goffi@goffi.org>
parents:
4270
diff
changeset
|
112 ) |
7c1d77efc752
plugin XEP-0277: Make MbData a Pydantic model:
Goffi <goffi@goffi.org>
parents:
4270
diff
changeset
|
113 return |
1671
1895846fc9cb
plugin XEP-0277, group blog: added item2data trigger + group permission are parsed when receiving a new item
Goffi <goffi@goffi.org>
parents:
1664
diff
changeset
|
114 access_model = config_form.get(self._p.OPT_ACCESS_MODEL, self._p.ACCESS_OPEN) |
2201
40dd9eb2692c
plugin groupblog, XEP-0060: added ACCESS_PUBLISHER_ROSTER and switched to it in groupblog
Goffi <goffi@goffi.org>
parents:
2148
diff
changeset
|
115 if access_model == self._p.ACCESS_PUBLISHER_ROSTER: |
2807
0b7ce5daee9b
plugin XEP-0277: blog items data are now entirely serialised before going to bridge:
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
116 opt = self._p.OPT_ROSTER_GROUPS_ALLOWED |
4270
0d7bb4df2343
Reformatted code base using black.
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
117 microblog_data["groups"] = config_form.fields[opt].values |
1671
1895846fc9cb
plugin XEP-0277, group blog: added item2data trigger + group permission are parsed when receiving a new item
Goffi <goffi@goffi.org>
parents:
1664
diff
changeset
|
118 |
4383
7c1d77efc752
plugin XEP-0277: Make MbData a Pydantic model:
Goffi <goffi@goffi.org>
parents:
4270
diff
changeset
|
119 def _data_2_entry_trigger( |
7c1d77efc752
plugin XEP-0277: Make MbData a Pydantic model:
Goffi <goffi@goffi.org>
parents:
4270
diff
changeset
|
120 self, |
7c1d77efc752
plugin XEP-0277: Make MbData a Pydantic model:
Goffi <goffi@goffi.org>
parents:
4270
diff
changeset
|
121 client: SatXMPPClient, |
7c1d77efc752
plugin XEP-0277: Make MbData a Pydantic model:
Goffi <goffi@goffi.org>
parents:
4270
diff
changeset
|
122 mb_data: MbData, |
7c1d77efc752
plugin XEP-0277: Make MbData a Pydantic model:
Goffi <goffi@goffi.org>
parents:
4270
diff
changeset
|
123 entry_elt: domish.Element, |
7c1d77efc752
plugin XEP-0277: Make MbData a Pydantic model:
Goffi <goffi@goffi.org>
parents:
4270
diff
changeset
|
124 item_elt: domish.Element |
7c1d77efc752
plugin XEP-0277: Make MbData a Pydantic model:
Goffi <goffi@goffi.org>
parents:
4270
diff
changeset
|
125 ) -> None: |
1662
9aa2a703e460
plugin group blog: group permissions are used if "group*" keys are found in mbdata (in data2entry and comments trigger)
Goffi <goffi@goffi.org>
parents:
1552
diff
changeset
|
126 """Build fine access permission if needed |
9aa2a703e460
plugin group blog: group permissions are used if "group*" keys are found in mbdata (in data2entry and comments trigger)
Goffi <goffi@goffi.org>
parents:
1552
diff
changeset
|
127 |
9aa2a703e460
plugin group blog: group permissions are used if "group*" keys are found in mbdata (in data2entry and comments trigger)
Goffi <goffi@goffi.org>
parents:
1552
diff
changeset
|
128 This trigger check if "group*" key are present, |
9aa2a703e460
plugin group blog: group permissions are used if "group*" keys are found in mbdata (in data2entry and comments trigger)
Goffi <goffi@goffi.org>
parents:
1552
diff
changeset
|
129 and create a fine item config to restrict view to these groups |
9aa2a703e460
plugin group blog: group permissions are used if "group*" keys are found in mbdata (in data2entry and comments trigger)
Goffi <goffi@goffi.org>
parents:
1552
diff
changeset
|
130 """ |
4383
7c1d77efc752
plugin XEP-0277: Make MbData a Pydantic model:
Goffi <goffi@goffi.org>
parents:
4270
diff
changeset
|
131 # FIXME: Model_dump is temporarily used while converting MbData to Pydantic model. |
7c1d77efc752
plugin XEP-0277: Make MbData a Pydantic model:
Goffi <goffi@goffi.org>
parents:
4270
diff
changeset
|
132 groups = mb_data.model_dump().get("groups", []) |
1662
9aa2a703e460
plugin group blog: group permissions are used if "group*" keys are found in mbdata (in data2entry and comments trigger)
Goffi <goffi@goffi.org>
parents:
1552
diff
changeset
|
133 if not groups: |
9aa2a703e460
plugin group blog: group permissions are used if "group*" keys are found in mbdata (in data2entry and comments trigger)
Goffi <goffi@goffi.org>
parents:
1552
diff
changeset
|
134 return |
9aa2a703e460
plugin group blog: group permissions are used if "group*" keys are found in mbdata (in data2entry and comments trigger)
Goffi <goffi@goffi.org>
parents:
1552
diff
changeset
|
135 if not client.server_groupblog_available: |
3028 | 136 raise exceptions.CancelError("GroupBlog is not available") |
137 log.debug("This entry use group blog") | |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
138 form = data_form.Form("submit", formNamespace=NS_PUBSUB_ITEM_CONFIG) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
139 access = data_form.Field( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
140 None, self._p.OPT_ACCESS_MODEL, value=self._p.ACCESS_PUBLISHER_ROSTER |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
141 ) |
1662
9aa2a703e460
plugin group blog: group permissions are used if "group*" keys are found in mbdata (in data2entry and comments trigger)
Goffi <goffi@goffi.org>
parents:
1552
diff
changeset
|
142 allowed = data_form.Field(None, self._p.OPT_ROSTER_GROUPS_ALLOWED, values=groups) |
9aa2a703e460
plugin group blog: group permissions are used if "group*" keys are found in mbdata (in data2entry and comments trigger)
Goffi <goffi@goffi.org>
parents:
1552
diff
changeset
|
143 form.addField(access) |
9aa2a703e460
plugin group blog: group permissions are used if "group*" keys are found in mbdata (in data2entry and comments trigger)
Goffi <goffi@goffi.org>
parents:
1552
diff
changeset
|
144 form.addField(allowed) |
9aa2a703e460
plugin group blog: group permissions are used if "group*" keys are found in mbdata (in data2entry and comments trigger)
Goffi <goffi@goffi.org>
parents:
1552
diff
changeset
|
145 item_elt.addChild(form.toElement()) |
9aa2a703e460
plugin group blog: group permissions are used if "group*" keys are found in mbdata (in data2entry and comments trigger)
Goffi <goffi@goffi.org>
parents:
1552
diff
changeset
|
146 |
4037
524856bd7b19
massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
147 def _comments_trigger(self, client, mb_data, options): |
1662
9aa2a703e460
plugin group blog: group permissions are used if "group*" keys are found in mbdata (in data2entry and comments trigger)
Goffi <goffi@goffi.org>
parents:
1552
diff
changeset
|
148 """This method is called when a comments node is about to be created |
9aa2a703e460
plugin group blog: group permissions are used if "group*" keys are found in mbdata (in data2entry and comments trigger)
Goffi <goffi@goffi.org>
parents:
1552
diff
changeset
|
149 |
9aa2a703e460
plugin group blog: group permissions are used if "group*" keys are found in mbdata (in data2entry and comments trigger)
Goffi <goffi@goffi.org>
parents:
1552
diff
changeset
|
150 It changes the access mode to roster if needed, and give the authorized groups |
9aa2a703e460
plugin group blog: group permissions are used if "group*" keys are found in mbdata (in data2entry and comments trigger)
Goffi <goffi@goffi.org>
parents:
1552
diff
changeset
|
151 """ |
9aa2a703e460
plugin group blog: group permissions are used if "group*" keys are found in mbdata (in data2entry and comments trigger)
Goffi <goffi@goffi.org>
parents:
1552
diff
changeset
|
152 if "group" in mb_data: |
2201
40dd9eb2692c
plugin groupblog, XEP-0060: added ACCESS_PUBLISHER_ROSTER and switched to it in groupblog
Goffi <goffi@goffi.org>
parents:
2148
diff
changeset
|
153 options[self._p.OPT_ACCESS_MODEL] = self._p.ACCESS_PUBLISHER_ROSTER |
4270
0d7bb4df2343
Reformatted code base using black.
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
154 options[self._p.OPT_ROSTER_GROUPS_ALLOWED] = mb_data["groups"] |
0d7bb4df2343
Reformatted code base using black.
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
155 |
1268
bb30bf3ae932
plugins XEP-0060, XEP-0277, groupblog: make use of RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents:
1243
diff
changeset
|
156 |
3028 | 157 @implementer(iwokkel.IDisco) |
476
b9fd32b46306
plugin groupblog: added disco info + misc fixes
Goffi <goffi@goffi.org>
parents:
471
diff
changeset
|
158 class GroupBlog_handler(XMPPHandler): |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
159 |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
160 def getDiscoInfo(self, requestor, target, nodeIdentifier=""): |
476
b9fd32b46306
plugin groupblog: added disco info + misc fixes
Goffi <goffi@goffi.org>
parents:
471
diff
changeset
|
161 return [disco.DiscoFeature(NS_GROUPBLOG)] |
b9fd32b46306
plugin groupblog: added disco info + misc fixes
Goffi <goffi@goffi.org>
parents:
471
diff
changeset
|
162 |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2562
diff
changeset
|
163 def getDiscoItems(self, requestor, target, nodeIdentifier=""): |
476
b9fd32b46306
plugin groupblog: added disco info + misc fixes
Goffi <goffi@goffi.org>
parents:
471
diff
changeset
|
164 return [] |