return unique token for new qr codes

as by reviving qr codes,
there may be more than one token for a chat,
ensure, the most recent token and only one token is returned
by the sql-command for looking up tokens
(used for generating new codes)
This commit is contained in:
B. Petersen
2021-06-23 17:44:39 +02:00
committed by bjoern
parent 6202f85a6f
commit 7b9e54be56

View File

@@ -69,7 +69,7 @@ pub async fn lookup(
context context
.sql .sql
.query_get_value( .query_get_value(
"SELECT token FROM tokens WHERE namespc=? AND foreign_id=?;", "SELECT token FROM tokens WHERE namespc=? AND foreign_id=? ORDER BY timestamp DESC LIMIT 1;",
paramsv![namespace, chat_id], paramsv![namespace, chat_id],
) )
.await? .await?
@@ -79,7 +79,7 @@ pub async fn lookup(
context context
.sql .sql
.query_get_value( .query_get_value(
"SELECT token FROM tokens WHERE namespc=? AND foreign_id=0;", "SELECT token FROM tokens WHERE namespc=? AND foreign_id=0 ORDER BY timestamp DESC LIMIT 1;",
paramsv![namespace], paramsv![namespace],
) )
.await? .await?