comparison sat/plugins/plugin_misc_lists.py @ 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 be6d91572633
children 5f65f4e9f8cb
comparison
equal deleted inserted replaced
3507:375449da79f6 3508:9d9fb871a75c
244 "listSet", 244 "listSet",
245 ".plugin", 245 ".plugin",
246 in_sign="ssa{sas}ssss", 246 in_sign="ssa{sas}ssss",
247 out_sign="s", 247 out_sign="s",
248 method=self._set, 248 method=self._set,
249 async_=True,
250 )
251 host.bridge.addMethod(
252 "listDeleteItem",
253 ".plugin",
254 in_sign="sssbs",
255 out_sign="",
256 method=self._delete,
249 async_=True, 257 async_=True,
250 ) 258 )
251 host.bridge.addMethod( 259 host.bridge.addMethod(
252 "listSchemaGet", 260 "listSchemaGet",
253 ".plugin", 261 ".plugin",
338 'created' and 'updated' will be forced to current time: 346 'created' and 'updated' will be forced to current time:
339 - 'created' is set if item_id is None, i.e. if it's a new ticket 347 - 'created' is set if item_id is None, i.e. if it's a new ticket
340 - 'updated' is set everytime 348 - 'updated' is set everytime
341 @param extra(dict, None): same as for [XEP-0060.sendItem] with additional keys: 349 @param extra(dict, None): same as for [XEP-0060.sendItem] with additional keys:
342 - update(bool): if True, get previous item data to merge with current one 350 - update(bool): if True, get previous item data to merge with current one
343 if True, item_id must be None 351 if True, item_id must be set
344 other arguments are same as for [self._s.sendDataFormItem] 352 other arguments are same as for [self._s.sendDataFormItem]
345 @return (unicode): id of the created item 353 @return (unicode): id of the created item
346 """ 354 """
347 if not node: 355 if not node:
348 node = self.namespace 356 node = self.namespace
372 node=comments_node, 380 node=comments_node,
373 ) 381 )
374 382
375 return await self._s.set( 383 return await self._s.set(
376 client, service, node, values, schema, item_id, extra, deserialise, form_ns 384 client, service, node, values, schema, item_id, extra, deserialise, form_ns
385 )
386
387 def _delete(
388 self, service_s, nodeIdentifier, itemIdentifier, notify, profile_key
389 ):
390 client = self.host.getClient(profile_key)
391 return defer.ensureDeferred(self.delete(
392 client,
393 jid.JID(service_s) if service_s else None,
394 nodeIdentifier,
395 itemIdentifier,
396 notify
397 ))
398
399 async def delete(
400 self,
401 client: SatXMPPEntity,
402 service: Optional[jid.JID],
403 node: Optional[str],
404 itemIdentifier: str,
405 notify: Optional[bool] = None
406 ) -> None:
407 if not node:
408 node = self.namespace
409 return await self._p.retractItems(
410 service, node, (itemIdentifier,), notify, client.profile
377 ) 411 )
378 412
379 def _listsList(self, service, node, profile): 413 def _listsList(self, service, node, profile):
380 service = jid.JID(service) if service else None 414 service = jid.JID(service) if service else None
381 node = node or None 415 node = node or None