diff --git a/sat/plugins/plugin_xep_0470.py b/sat/plugins/plugin_xep_0470.py index 9f48d9a8..e11f960f 100644 --- a/sat/plugins/plugin_xep_0470.py +++ b/sat/plugins/plugin_xep_0470.py @@ -164,16 +164,31 @@ class PubsubAttachments: data: dict ) -> bool: """trigger to create attachment node on each publication""" + await self.create_attachments_node(client, service, node, item["id"]) + return True + + async def create_attachments_node( + self, + client: SatXMPPEntity, + service: jid.JID, + node: str, + item_id: str + ): + """Create node for attachements if necessary""" node_config = await self._p.getConfiguration(client, service, node) - attachment_node = self.getAttachmentNodeName(service, node, item["id"]) + try: + # FIXME: check if this is the best publish_model option + node_config.fields["pubsub#publish_model"].value = "open" + except KeyError: + log.warning("pubsub#publish_model field is missing") + attachment_node = self.getAttachmentNodeName(service, node, item_id) # we use the same options as target node try: await self._p.createIfNewNode( client, service, attachment_node, options=dict(node_config) ) except Exception as e: - log.warning(f"Can't create attachment node {attachment_node}: {e}]") - return True + log.warning(f"Can't create attachment node {attachment_node}: {e}") def items2attachmentData( self,