# HG changeset patch # User Goffi # Date 1606666116 -3600 # Node ID 2938d1b65bd5c3ddf563e40c677ed89a9ff34487 # Parent 19eb8b6c02d4dc4894a5d02e2e437f9ef4666401 browser (invitation): allow invitation of unknown JID: If something like a JID is entered in invitation field and it is unknown (i.e. not in roster), pressing "enter" will send an invitation to it. diff -r 19eb8b6c02d4 -r 2938d1b65bd5 libervia/pages/_browser/invitation.py --- a/libervia/pages/_browser/invitation.py Fri Nov 27 12:25:53 2020 +0100 +++ b/libervia/pages/_browser/invitation.py Sun Nov 29 17:08:36 2020 +0100 @@ -3,8 +3,12 @@ from template import Template from dialog import notification from cache import cache +# we use JS RegExp because Python're is really long to import in Brython +from javascript import RegExp bridge = Bridge() +# FIXME: this is a naive JID regex, a more accurate should be used instead +jid_re = RegExp.new(r"^\w+@\w+\.\w+") class InvitationManager: @@ -146,6 +150,10 @@ if self._active_new_item is not None: entity_jid = self._active_new_item.dataset.entityJid self.invite_by_jid(entity_jid) + else: + if jid_re.exec(evt.target.value): + self.invite_by_jid(evt.target.value) + evt.target.value = "" def on_contact_focus(self, evt): search_dialog = document['invitation_contact_search']