1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2025-06-21 08:55:16 +00:00

Start to configure Firebase access token

This commit is contained in:
2021-04-11 19:14:59 +02:00
parent c8c03d11e4
commit 6eb153eefa
3 changed files with 44 additions and 0 deletions

View File

@ -101,6 +101,9 @@ pub fn refresh_access_token(token: &UserAccessToken) -> Res {
/// Destroy a given user login tokens
pub fn destroy_login_tokens(access_tokens: &UserAccessToken) -> Res {
// TODO : un-register from independent push notifications service
// (continue to destroy token even in case of failure)
DeleteQuery::new(USER_ACCESS_TOKENS_TABLE)
.cond_u64("id", access_tokens.id)
.exec()?;
@ -129,6 +132,7 @@ pub fn clean_up_old_access_tokens() -> Res {
pub fn destroy_all_user_tokens(id: &UserID) -> ResultBoxError {
user_ws_controller::disconnect_user_from_all_sockets(id)?;
// TODO : call destroy_login_tokens for each call to do proper cleanup
database::DeleteQuery::new(USER_ACCESS_TOKENS_TABLE)
.cond_user_id("user_id", id)
.exec()
@ -306,6 +310,16 @@ pub fn set_notifications_settings(new_settings: NewNotificationsSettings) -> Res
.exec()
}
/// Set new push notification token
pub fn set_push_notification_token(client: &UserAccessToken, new_token: PushNotificationToken) -> Res {
// TODO : in case of independent push service, remove previous client
database::UpdateInfo::new(USER_ACCESS_TOKENS_TABLE)
.cond_u64("id", client.id)
.set_opt_str("push_notifications_token", new_token.to_db())
.exec()
}
/// Export an account's data
pub fn export(user_id: &UserID) -> ResultBoxError<AccountExport> {
let mut data = AccountExport {