Support getting entities by exact name/title match

This commit is contained in:
Lonami Exo
2018-02-19 21:05:39 +01:00
parent c31635cc34
commit 4050d1ca00
2 changed files with 19 additions and 8 deletions
+8 -2
View File
@@ -438,13 +438,19 @@ class Session:
(phone,))
else:
username, _ = utils.parse_username(key)
c.execute('select id, hash from entities where username=?',
(username,))
if username:
c.execute('select id, hash from entities where username=?',
(username,))
if isinstance(key, int):
c.execute('select id, hash from entities where id=?', (key,))
result = c.fetchone()
if not result and isinstance(key, str):
# Try exact match by name if phone/username failed
c.execute('select id, hash from entities where name=?', (key,))
result = c.fetchone()
c.close()
if result:
i, h = result # unpack resulting tuple