changeset 1373:2938d1b65bd5

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.
author Goffi <goffi@goffi.org>
date Sun, 29 Nov 2020 17:08:36 +0100
parents 19eb8b6c02d4
children 25104d31479f
files libervia/pages/_browser/invitation.py
diffstat 1 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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']