1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-08-06 06:02:40 +03:00

Commit the DB transaction at the end of the cleanup task

This commit is contained in:
Quentin Gliech
2023-03-03 17:21:39 +01:00
parent a79b4060d4
commit c5e1e2ec62

View File

@@ -14,7 +14,7 @@
//! Database-related tasks //! Database-related tasks
use mas_storage::{oauth2::OAuth2AccessTokenRepository, RepositoryAccess, SystemClock}; use mas_storage::{oauth2::OAuth2AccessTokenRepository, Repository, RepositoryAccess, SystemClock};
use mas_storage_pg::PgRepository; use mas_storage_pg::PgRepository;
use sqlx::{Pool, Postgres}; use sqlx::{Pool, Postgres};
use tracing::{debug, error, info}; use tracing::{debug, error, info};
@@ -34,8 +34,9 @@ impl std::fmt::Debug for CleanupExpired {
impl Task for CleanupExpired { impl Task for CleanupExpired {
async fn run(&self) { async fn run(&self) {
let res = async move { let res = async move {
let mut repo = PgRepository::from_pool(&self.0).await?; let mut repo = PgRepository::from_pool(&self.0).await?.boxed();
let res = repo.oauth2_access_token().cleanup_expired(&self.1).await; let res = repo.oauth2_access_token().cleanup_expired(&self.1).await;
repo.save().await?;
res res
} }
.await; .await;