Mercurial > libervia-backend
comparison sat/plugins/plugin_xep_0353.py @ 3661:cbb988a6f507
merge bookmark `@`
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 08 Sep 2021 11:20:37 +0200 |
parents | 6e34307319c0 |
children | 524856bd7b19 |
comparison
equal
deleted
inserted
replaced
3639:05db744f194f | 3661:cbb988a6f507 |
---|---|
17 # along with this program. If not, see <http://www.gnu.org/licenses/>. | 17 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
18 | 18 |
19 from zope.interface import implementer | 19 from zope.interface import implementer |
20 from twisted.internet import defer | 20 from twisted.internet import defer |
21 from twisted.internet import reactor | 21 from twisted.internet import reactor |
22 from twisted.words.protocols.jabber import xmlstream, jid | 22 from twisted.words.protocols.jabber import xmlstream, jid, error |
23 from twisted.words.xish import domish | 23 from twisted.words.xish import domish |
24 from wokkel import disco, iwokkel | 24 from wokkel import disco, iwokkel |
25 from sat.core.i18n import _, D_ | 25 from sat.core.i18n import _, D_ |
26 from sat.core.constants import Const as C | 26 from sat.core.constants import Const as C |
27 from sat.core import exceptions | 27 from sat.core import exceptions |
36 | 36 |
37 PLUGIN_INFO = { | 37 PLUGIN_INFO = { |
38 C.PI_NAME: "Jingle Message Initiation", | 38 C.PI_NAME: "Jingle Message Initiation", |
39 C.PI_IMPORT_NAME: "XEP-0353", | 39 C.PI_IMPORT_NAME: "XEP-0353", |
40 C.PI_TYPE: "XEP", | 40 C.PI_TYPE: "XEP", |
41 C.PI_MODES: C.PLUG_MODE_CLIENT, | 41 C.PI_MODES: [C.PLUG_MODE_CLIENT], |
42 C.PI_PROTOCOLS: ["XEP-0353"], | 42 C.PI_PROTOCOLS: ["XEP-0353"], |
43 C.PI_DEPENDENCIES: ["XEP-0166"], | 43 C.PI_DEPENDENCIES: ["XEP-0166"], |
44 C.PI_MAIN: "XEP_0353", | 44 C.PI_MAIN: "XEP_0353", |
45 C.PI_HANDLER: "yes", | 45 C.PI_HANDLER: "yes", |
46 C.PI_DESCRIPTION: _("""Implementation of Jingle Message Initiation"""), | 46 C.PI_DESCRIPTION: _("""Implementation of Jingle Message Initiation"""), |
83 # FIXME: check that at least one resource of the peer_jid can handle the feature | 83 # FIXME: check that at least one resource of the peer_jid can handle the feature |
84 peer_jid = session['peer_jid'] | 84 peer_jid = session['peer_jid'] |
85 if peer_jid.resource: | 85 if peer_jid.resource: |
86 return True | 86 return True |
87 | 87 |
88 infos = await self.host.memory.disco.getInfos(client, peer_jid) | 88 try: |
89 categories = {c for c, __ in infos.identities} | 89 infos = await self.host.memory.disco.getInfos(client, peer_jid) |
90 except error.StanzaError as e: | |
91 if e.condition == "service-unavailable": | |
92 categories = {} | |
93 else: | |
94 raise e | |
95 else: | |
96 categories = {c for c, __ in infos.identities} | |
90 if "component" in categories: | 97 if "component" in categories: |
91 # we don't use message initiation with components | 98 # we don't use message initiation with components |
92 return True | 99 return True |
93 | 100 |
94 if peer_jid.userhostJID() not in client.roster: | 101 if peer_jid.userhostJID() not in client.roster: |