plugin list: delete implementation:

`delete` is similar to XEP-0060's retractItem, but node is set to default ticket one if
not specified.
This commit is contained in:
Goffi 2021-04-22 18:19:52 +02:00
commit c96670e5f3

View file

@ -248,6 +248,14 @@ class PubsubLists:
method=self._set,
async_=True,
)
host.bridge.addMethod(
"listDeleteItem",
".plugin",
in_sign="sssbs",
out_sign="",
method=self._delete,
async_=True,
)
host.bridge.addMethod(
"listSchemaGet",
".plugin",
@ -340,7 +348,7 @@ class PubsubLists:
- '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 @@ class PubsubLists:
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