Use identites from server for muc service

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
Maxime “pep” Buquet 2018-07-01 01:40:52 +01:00
parent dc2808cdcc
commit cf50ef2cf3
2 changed files with 39 additions and 20 deletions

View file

@ -877,10 +877,18 @@ class Core:
contacts to join in.
"""
def callback(results):
muc_from_identity = ''
for info in results:
for identity in info['disco_info']['identities']:
if identity[0] == 'conference' and identity[1] == 'text':
muc_from_identity = info['from'].bare
# Use config.default_muc_service as muc component if available,
# otherwise find muc component by disco#items-ing the user domain. If
# not, give up
default_muc = config.get('default_muc_service')
# otherwise find muc component by disco#items-ing the user domain.
# If not, give up
default_muc = config.get('default_muc_service', muc_from_identity)
if not default_muc:
self.information(
"Error finding a MUC service to join. If your server does not "
@ -899,6 +907,12 @@ class Core:
for jid in jids:
self.invite(jid, room)
asyncio.ensure_future(
self.xmpp['xep_0030'].get_info_from_domain(
callback=callback,
)
)
def get_error_message(self, stanza, deprecated: bool = False):
"""
Takes a stanza of the form <message type='error'><error/></message>

View file

@ -97,6 +97,11 @@ class HandlerCore:
self.core.xmpp.plugin['xep_0030'].get_info(
jid=self.core.xmpp.boundjid.domain, callback=callback)
def find_identities(self, _):
asyncio.ensure_future(
self.core.xmpp['xep_0030'].get_info_from_domain(),
)
def on_carbon_received(self, message):
"""
Carbon <received/> received