Mercurial > libervia-backend
changeset 3508:9d9fb871a75c
plugin list: `delete` implementation:
`delete` is similar to XEP-0060's retractItem, but node is set to default ticket one if
not specified.
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 22 Apr 2021 18:19:52 +0200 |
parents | 375449da79f6 |
children | b977c74f9c85 |
files | sat/plugins/plugin_misc_lists.py |
diffstat | 1 files changed, 35 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/sat/plugins/plugin_misc_lists.py Thu Apr 22 18:18:09 2021 +0200 +++ b/sat/plugins/plugin_misc_lists.py Thu Apr 22 18:19:52 2021 +0200 @@ -249,6 +249,14 @@ async_=True, ) host.bridge.addMethod( + "listDeleteItem", + ".plugin", + in_sign="sssbs", + out_sign="", + method=self._delete, + async_=True, + ) + host.bridge.addMethod( "listSchemaGet", ".plugin", in_sign="sss", @@ -340,7 +348,7 @@ - 'updated' is set everytime @param extra(dict, None): same as for [XEP-0060.sendItem] with additional keys: - update(bool): if True, get previous item data to merge with current one - if True, item_id must be None + if True, item_id must be set other arguments are same as for [self._s.sendDataFormItem] @return (unicode): id of the created item """ @@ -376,6 +384,32 @@ client, service, node, values, schema, item_id, extra, deserialise, form_ns ) + def _delete( + self, service_s, nodeIdentifier, itemIdentifier, notify, profile_key + ): + client = self.host.getClient(profile_key) + return defer.ensureDeferred(self.delete( + client, + jid.JID(service_s) if service_s else None, + nodeIdentifier, + itemIdentifier, + notify + )) + + async def delete( + self, + client: SatXMPPEntity, + service: Optional[jid.JID], + node: Optional[str], + itemIdentifier: str, + notify: Optional[bool] = None + ) -> None: + if not node: + node = self.namespace + return await self._p.retractItems( + service, node, (itemIdentifier,), notify, client.profile + ) + def _listsList(self, service, node, profile): service = jid.JID(service) if service else None node = node or None