From 318fa4f670016274a4a9a89e4aad031050c995e3 Mon Sep 17 00:00:00 2001 From: alemi Date: Mon, 27 May 2024 07:31:34 +0200 Subject: [PATCH] fix: refresh session only if necessary --- src/routes/activitypub/auth.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/routes/activitypub/auth.rs b/src/routes/activitypub/auth.rs index 46081cfb..76dd5a8c 100644 --- a/src/routes/activitypub/auth.rs +++ b/src/routes/activitypub/auth.rs @@ -81,6 +81,10 @@ pub async fn refresh( .await? .ok_or_else(UpubError::unauthorized)?; + if prev.expires > chrono::Utc::now() { + return Ok(Json(AuthSuccess { token: prev.secret, user: prev.actor, expires: prev.expires })); + } + let token = token(); let expires = chrono::Utc::now() + std::time::Duration::from_secs(3600 * 6); let user = prev.actor;