invite: remove callback and force impromptu rooms to use mediated
This commit is contained in:
parent
048f3d5fd3
commit
341c770b36
2 changed files with 29 additions and 17 deletions
|
@ -996,7 +996,7 @@ class CommandCore:
|
||||||
name=name, server_address=address, callback=dumb_callback)
|
name=name, server_address=address, callback=dumb_callback)
|
||||||
|
|
||||||
@command_args_parser.quoted(2, 1, [None])
|
@command_args_parser.quoted(2, 1, [None])
|
||||||
def invite(self, args):
|
async def invite(self, args):
|
||||||
"""/invite <to> <room> [reason]"""
|
"""/invite <to> <room> [reason]"""
|
||||||
|
|
||||||
if args is None:
|
if args is None:
|
||||||
|
@ -1013,8 +1013,9 @@ class CommandCore:
|
||||||
except InvalidJID:
|
except InvalidJID:
|
||||||
self.core.information('Invalid room JID specified to invite: %s' % args[1], 'Error')
|
self.core.information('Invalid room JID specified to invite: %s' % args[1], 'Error')
|
||||||
return None
|
return None
|
||||||
self.core.invite(to.full, room, reason=reason)
|
result = await self.core.invite(to.full, room, reason=reason)
|
||||||
self.core.information('Invited %s to %s' % (to.bare, room), 'Info')
|
if result:
|
||||||
|
self.core.information('Invited %s to %s' % (to.bare, room), 'Info')
|
||||||
|
|
||||||
@command_args_parser.quoted(1, 0)
|
@command_args_parser.quoted(1, 0)
|
||||||
def impromptu(self, args: str) -> None:
|
def impromptu(self, args: str) -> None:
|
||||||
|
|
|
@ -885,25 +885,36 @@ class Core:
|
||||||
self.tabs.current_tab.command_say(msg)
|
self.tabs.current_tab.command_say(msg)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def invite(self, jid: JID, room: JID, reason: Optional[str] = None) -> None:
|
async def invite(self, jid: JID, room: JID, reason: Optional[str] = None, force_mediated: bool = False) -> bool:
|
||||||
"""
|
"""
|
||||||
Checks if the sender supports XEP-0249, then send an invitation,
|
Checks if the sender supports XEP-0249, then send an invitation,
|
||||||
or a mediated one if it does not.
|
or a mediated one if it does not.
|
||||||
TODO: allow passwords
|
TODO: allow passwords
|
||||||
"""
|
"""
|
||||||
|
features = set()
|
||||||
|
|
||||||
def callback(iq):
|
# force mediated: act as if the other entity does not
|
||||||
if not iq:
|
# support direct invites
|
||||||
return
|
if not force_mediated:
|
||||||
if 'jabber:x:conference' in iq['disco_info'].get_features():
|
try:
|
||||||
self.xmpp.plugin['xep_0249'].send_invitation(
|
iq = await self.xmpp.plugin['xep_0030'].get_info(
|
||||||
jid, room, reason=reason)
|
jid=jid,
|
||||||
else: # fallback
|
timeout=5,
|
||||||
self.xmpp.plugin['xep_0045'].invite(
|
)
|
||||||
room, jid, reason=reason or '')
|
features = iq['disco_info'].get_features()
|
||||||
|
except (IqError, IqTimeout):
|
||||||
self.xmpp.plugin['xep_0030'].get_info(
|
pass
|
||||||
jid=jid, timeout=5, callback=callback)
|
supports_direct = 'jabber:x:conference' in features
|
||||||
|
if supports_direct:
|
||||||
|
invite = self.xmpp.plugin['xep_0249'].send_invitation
|
||||||
|
else: # fallback
|
||||||
|
invite = self.xmpp.plugin['xep_0045'].invite
|
||||||
|
invite(
|
||||||
|
jid=jid,
|
||||||
|
room=room,
|
||||||
|
reason=reason
|
||||||
|
)
|
||||||
|
return True
|
||||||
|
|
||||||
def _impromptu_room_form(self, room):
|
def _impromptu_room_form(self, room):
|
||||||
fields = [
|
fields = [
|
||||||
|
@ -990,7 +1001,7 @@ class Core:
|
||||||
self.information('Room %s created' % room, 'Info')
|
self.information('Room %s created' % room, 'Info')
|
||||||
|
|
||||||
for jid in jids:
|
for jid in jids:
|
||||||
self.invite(jid, room)
|
await self.invite(jid, room, force_mediated=True)
|
||||||
|
|
||||||
####################### Tab logic-related things ##############################
|
####################### Tab logic-related things ##############################
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue