comparison sat/plugins/plugin_xep_0277.py @ 3861:37a1193d90db

plugin XEP-0277: add a trigger to `send` method: rel 370
author Goffi <goffi@goffi.org>
date Wed, 20 Jul 2022 17:19:53 +0200
parents e9c380ef41c8
children 6c5f0fbc519b
comparison
equal deleted inserted replaced
3860:e417c478b488 3861:37a1193d90db
959 None is equivalend as using default value 959 None is equivalend as using default value
960 @return: ID of the published item 960 @return: ID of the published item
961 """ 961 """
962 # TODO: check that all data keys are used, this would avoid sending publicly a private message 962 # TODO: check that all data keys are used, this would avoid sending publicly a private message
963 # by accident (e.g. if group plugin is not loaded, and "group*" key are not used) 963 # by accident (e.g. if group plugin is not loaded, and "group*" key are not used)
964 if service is None:
965 service = client.jid.userhostJID()
964 if node is None: 966 if node is None:
965 node = NS_MICROBLOG 967 node = NS_MICROBLOG
966 968
967 item_id = data.get("id") 969 item_id = data.get("id")
968 if item_id is None: 970 if item_id is None:
974 try: 976 try:
975 await self._manageComments(client, data, service, node, item_id, access=None) 977 await self._manageComments(client, data, service, node, item_id, access=None)
976 except error.StanzaError: 978 except error.StanzaError:
977 log.warning("Can't create comments node for item {}".format(item_id)) 979 log.warning("Can't create comments node for item {}".format(item_id))
978 item = await self.data2entry(client, data, item_id, service, node) 980 item = await self.data2entry(client, data, item_id, service, node)
981
982 if not await self.host.trigger.asyncPoint(
983 "XEP-0277_send", client, service, node, item, data
984 ):
985 return None
986
979 await self._p.publish(client, service, node, [item]) 987 await self._p.publish(client, service, node, [item])
980 return item_id 988 return item_id
981 989
982 def _mbRepeat( 990 def _mbRepeat(
983 self, 991 self,