plugin XEP-0470: add create_attachments_node method:
this method create the attachments node if it doesn't already exists, and use same access model as target item, and an `open` publish model. rel 372
This commit is contained in:
parent
2389f235f1
commit
cfbbe66358
1 changed files with 18 additions and 3 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in a new issue