mirror of
https://github.com/chatmail/core.git
synced 2026-05-03 05:16:28 +03:00
allow token::save() to handle existing tokens
This commit is contained in:
11
src/token.rs
11
src/token.rs
@@ -31,8 +31,12 @@ impl Default for Namespace {
|
|||||||
/// Creates a new token and saves it into the database.
|
/// Creates a new token and saves it into the database.
|
||||||
///
|
///
|
||||||
/// Returns created token.
|
/// Returns created token.
|
||||||
pub async fn save(context: &Context, namespace: Namespace, foreign_id: Option<ChatId>) -> String {
|
pub async fn save(
|
||||||
let token = dc_create_id();
|
context: &Context,
|
||||||
|
namespace: Namespace,
|
||||||
|
foreign_id: Option<ChatId>,
|
||||||
|
token: String,
|
||||||
|
) -> String {
|
||||||
match foreign_id {
|
match foreign_id {
|
||||||
Some(foreign_id) => context
|
Some(foreign_id) => context
|
||||||
.sql
|
.sql
|
||||||
@@ -93,7 +97,8 @@ pub async fn lookup_or_new(
|
|||||||
return token;
|
return token;
|
||||||
}
|
}
|
||||||
|
|
||||||
save(context, namespace, foreign_id).await
|
let token = dc_create_id();
|
||||||
|
save(context, namespace, foreign_id, token).await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn exists(context: &Context, namespace: Namespace, token: &str) -> bool {
|
pub async fn exists(context: &Context, namespace: Namespace, token: &str) -> bool {
|
||||||
|
|||||||
Reference in New Issue
Block a user