Mercurial > libervia-backend
changeset 3517:8508fab9bcc2
plugin XEP-0353: don't use Jingle Message Initiation for components:
Jingle Message Initiation is currently not useful for components, and the message workflow
is different in Libervia between clients and components (as a result, `messageReceived`
trigger is never called, and the session proposal is never answered).
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 01 May 2021 18:30:01 +0200 |
parents | e47aa1fb7b24 |
children | b258dce27d6d |
files | sat/plugins/plugin_xep_0353.py |
diffstat | 1 files changed, 9 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/sat/plugins/plugin_xep_0353.py Sat May 01 18:25:42 2021 +0200 +++ b/sat/plugins/plugin_xep_0353.py Sat May 01 18:30:01 2021 +0200 @@ -38,7 +38,7 @@ C.PI_NAME: "Jingle Message Initiation", C.PI_IMPORT_NAME: "XEP-0353", C.PI_TYPE: "XEP", - C.PI_MODES: C.PLUG_MODE_BOTH, + C.PI_MODES: C.PLUG_MODE_CLIENT, C.PI_PROTOCOLS: ["XEP-0353"], C.PI_DEPENDENCIES: ["XEP-0166"], C.PI_MAIN: "XEP_0353", @@ -47,7 +47,7 @@ } -class XEP_0353(object): +class XEP_0353: def __init__(self, host): log.info(_("plugin {name} initialization").format(name=PLUGIN_INFO[C.PI_NAME])) @@ -80,10 +80,17 @@ return mess_data async def _onInitiateTrigger(self, client, session, contents): + # FIXME: check that at least one resource of the peer_jid can handle the feature peer_jid = session['peer_jid'] if peer_jid.resource: return True + infos = await self.host.memory.disco.getInfos(client, peer_jid) + categories = {c for c, __ in infos.identities} + if "component" in categories: + # we don't use message initiation with components + return True + if peer_jid.userhostJID() not in client.roster: # if the contact is not in our roster, we need to send a directed presence # according to XEP-0353 ยง3.1