diff options
author | Maxime “pep” Buquet <pep@bouah.net> | 2018-07-01 01:40:52 +0100 |
---|---|---|
committer | Maxime “pep” Buquet <pep@bouah.net> | 2018-12-16 16:57:48 +0000 |
commit | cf50ef2cf38a0366bcba7e45c254dc03e4fe981f (patch) | |
tree | 811ad40b78c5fb0fda493554834884ef6cf1a5d4 | |
parent | dc2808cdcc08624d323e9103e4fa4a7036f41a4c (diff) | |
download | poezio-cf50ef2cf38a0366bcba7e45c254dc03e4fe981f.tar.gz poezio-cf50ef2cf38a0366bcba7e45c254dc03e4fe981f.tar.bz2 poezio-cf50ef2cf38a0366bcba7e45c254dc03e4fe981f.tar.xz poezio-cf50ef2cf38a0366bcba7e45c254dc03e4fe981f.zip |
Use identites from server for muc service
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
-rw-r--r-- | poezio/core/core.py | 50 | ||||
-rw-r--r-- | poezio/core/handlers.py | 5 |
2 files changed, 37 insertions, 18 deletions
diff --git a/poezio/core/core.py b/poezio/core/core.py index fc311ea3..edec3b0c 100644 --- a/poezio/core/core.py +++ b/poezio/core/core.py @@ -877,27 +877,41 @@ class Core: contacts to join in. """ - # 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') - if not default_muc: - self.information( - "Error finding a MUC service to join. If your server does not " - "provide one, set 'default_muc_service' manually to a MUC " - "service that allows room creation.", - 'Error' - ) - return + 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', muc_from_identity) + if not default_muc: + self.information( + "Error finding a MUC service to join. If your server does not " + "provide one, set 'default_muc_service' manually to a MUC " + "service that allows room creation.", + 'Error' + ) + return + + nick = self.own_nick + room = uuid.uuid4().hex + '@' + default_muc - nick = self.own_nick - room = uuid.uuid4().hex + '@' + default_muc + self.open_new_room(room, nick).join() + self.information('Room %s created' % room, 'Info') - self.open_new_room(room, nick).join() - self.information('Room %s created' % room, 'Info') + for jid in jids: + self.invite(jid, room) - 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): """ diff --git a/poezio/core/handlers.py b/poezio/core/handlers.py index 0e655d68..b87e7307 100644 --- a/poezio/core/handlers.py +++ b/poezio/core/handlers.py @@ -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 |