diff --git a/crates/storage/src/queue/tasks.rs b/crates/storage/src/queue/tasks.rs index 3558314cf..4f05b47d9 100644 --- a/crates/storage/src/queue/tasks.rs +++ b/crates/storage/src/queue/tasks.rs @@ -1,3 +1,4 @@ +// Copyright 2025, 2026 Element Creations Ltd. // Copyright 2024, 2025 New Vector Ltd. // // SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial @@ -317,12 +318,12 @@ impl InsertableJob for SendAccountRecoveryEmailsJob { const QUEUE_NAME: &'static str = "send-account-recovery-email"; } -/// Cleanup expired tokens +/// Cleanup revoked OAuth 2.0 access tokens #[derive(Serialize, Deserialize, Debug, Clone, Default)] -pub struct CleanupExpiredTokensJob; +pub struct CleanupRevokedOAuthAccessTokensJob; -impl InsertableJob for CleanupExpiredTokensJob { - const QUEUE_NAME: &'static str = "cleanup-expired-tokens"; +impl InsertableJob for CleanupRevokedOAuthAccessTokensJob { + const QUEUE_NAME: &'static str = "cleanup-revoked-oauth-access-tokens"; } /// Scheduled job to expire inactive sessions diff --git a/crates/tasks/src/database.rs b/crates/tasks/src/database.rs index bb1efbf14..2a8fbf624 100644 --- a/crates/tasks/src/database.rs +++ b/crates/tasks/src/database.rs @@ -10,7 +10,7 @@ use std::time::Duration; use async_trait::async_trait; -use mas_storage::queue::{CleanupExpiredTokensJob, PruneStalePolicyDataJob}; +use mas_storage::queue::{CleanupRevokedOAuthAccessTokensJob, PruneStalePolicyDataJob}; use tracing::{debug, info}; use crate::{ @@ -21,8 +21,8 @@ use crate::{ const BATCH_SIZE: usize = 1000; #[async_trait] -impl RunnableJob for CleanupExpiredTokensJob { - #[tracing::instrument(name = "job.cleanup_expired_tokens", skip_all)] +impl RunnableJob for CleanupRevokedOAuthAccessTokensJob { + #[tracing::instrument(name = "job.cleanup_revoked_oauth_access_tokens", skip_all)] async fn run(&self, state: &State, context: JobContext) -> Result<(), JobError> { // Cleanup tokens that were revoked more than an hour ago let until = state.clock.now() - chrono::Duration::hours(1); @@ -45,7 +45,7 @@ impl RunnableJob for CleanupExpiredTokensJob { since = last_revoked_at; total += count; - // Check how many we deleted. If we deleted exactly BATCH_COUNT, + // Check how many we deleted. If we deleted exactly BATCH_SIZE, // there might be more to delete if count != BATCH_SIZE { break; diff --git a/crates/tasks/src/lib.rs b/crates/tasks/src/lib.rs index a480a8d50..f274cc765 100644 --- a/crates/tasks/src/lib.rs +++ b/crates/tasks/src/lib.rs @@ -1,3 +1,4 @@ +// Copyright 2025, 2026 Element Creations Ltd. // Copyright 2024, 2025 New Vector Ltd. // Copyright 2021-2024 The Matrix.org Foundation C.I.C. // @@ -128,7 +129,7 @@ pub async fn init( let mut worker = QueueWorker::new(state, cancellation_token).await?; worker - .register_handler::() + .register_handler::() .register_handler::() .register_handler::() .register_handler::() @@ -143,10 +144,12 @@ pub async fn init( .register_handler::() .register_handler::() .register_handler::() + .register_deprecated_queue("cleanup-expired-tokens") .add_schedule( - "cleanup-expired-tokens", + "cleanup-revoked-oauth-access-tokens", + // Run this job every hour "0 0 * * * *".parse()?, - mas_storage::queue::CleanupExpiredTokensJob, + mas_storage::queue::CleanupRevokedOAuthAccessTokensJob, ) .add_schedule( "expire-inactive-sessions",