Rename the cleanup revoked access tokens job

"cleanup-expired-tokens" was not accurate, and since the plan is to have
different jobs for the different kind of tokens, we renamed this job to
use a more accurate description
This commit is contained in:
Quentin Gliech
2026-01-09 12:11:41 +01:00
parent ad1910c22e
commit 73e838ff08
3 changed files with 15 additions and 11 deletions

View File

@@ -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

View File

@@ -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;

View File

@@ -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::<mas_storage::queue::CleanupExpiredTokensJob>()
.register_handler::<mas_storage::queue::CleanupRevokedOAuthAccessTokensJob>()
.register_handler::<mas_storage::queue::DeactivateUserJob>()
.register_handler::<mas_storage::queue::DeleteDeviceJob>()
.register_handler::<mas_storage::queue::ProvisionDeviceJob>()
@@ -143,10 +144,12 @@ pub async fn init(
.register_handler::<mas_storage::queue::ExpireInactiveOAuthSessionsJob>()
.register_handler::<mas_storage::queue::ExpireInactiveUserSessionsJob>()
.register_handler::<mas_storage::queue::PruneStalePolicyDataJob>()
.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",