Mercurial > libervia-backend
diff libervia/backend/plugins/plugin_misc_groupblog.py @ 4383:7c1d77efc752
plugin XEP-0277: Make MbData a Pydantic model:
- MbData is now a Pydantic based model.
- Bridge method has been updated to use `service` and `node` from MbData instead of using
separate fields.
- Added `In-Reply-To` to MbData.
- Adapted code using XEP-0277 to work with the changes.
rel 462
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 03 Aug 2025 23:35:21 +0200 |
parents | 0d7bb4df2343 |
children |
line wrap: on
line diff
--- a/libervia/backend/plugins/plugin_misc_groupblog.py Fri Jul 04 12:33:42 2025 +0200 +++ b/libervia/backend/plugins/plugin_misc_groupblog.py Sun Aug 03 23:35:21 2025 +0200 @@ -17,9 +17,12 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +from twisted.words.xish import domish +from libervia.backend.core.core_types import SatXMPPClient from libervia.backend.core.i18n import _ from libervia.backend.core.constants import Const as C from libervia.backend.core.log import getLogger +from libervia.backend.plugins.plugin_xep_0277 import MbData log = getLogger(__name__) from twisted.internet import defer @@ -102,18 +105,31 @@ config_form = data_form.findForm(item_elt, NS_PUBSUB_ITEM_CONFIG) if config_form is None: return + # FIXME: Legacy code, need to be adapted to new MbData model. + log.warning( + "Item config is temporarily not supported, it needs to be moved to " + "adapted to new model" + ) + return access_model = config_form.get(self._p.OPT_ACCESS_MODEL, self._p.ACCESS_OPEN) if access_model == self._p.ACCESS_PUBLISHER_ROSTER: opt = self._p.OPT_ROSTER_GROUPS_ALLOWED microblog_data["groups"] = config_form.fields[opt].values - def _data_2_entry_trigger(self, client, mb_data, entry_elt, item_elt): + def _data_2_entry_trigger( + self, + client: SatXMPPClient, + mb_data: MbData, + entry_elt: domish.Element, + item_elt: domish.Element + ) -> None: """Build fine access permission if needed This trigger check if "group*" key are present, and create a fine item config to restrict view to these groups """ - groups = mb_data.get("groups", []) + # FIXME: Model_dump is temporarily used while converting MbData to Pydantic model. + groups = mb_data.model_dump().get("groups", []) if not groups: return if not client.server_groupblog_available: