From 8bacf44c68d75e30ed403e61979ab8781d14e468 Mon Sep 17 00:00:00 2001 From: Andrew Ferrazzutti Date: Wed, 16 Jul 2025 13:49:00 -0400 Subject: [PATCH] Revert GraphQL's unlock to also reactivate Unlike the CLI and admin API, leave the behaviour of the GraphQL's unlock handler unchanged from before, so as to not break internal tooling that depends on it. Also update its documentation description to make note of the fact that it reactivates in addition to unlocks. --- crates/handlers/src/graphql/mutations/user.rs | 21 ++++++------------- frontend/schema.graphql | 6 +----- frontend/src/gql/graphql.ts | 4 +--- 3 files changed, 8 insertions(+), 23 deletions(-) diff --git a/crates/handlers/src/graphql/mutations/user.rs b/crates/handlers/src/graphql/mutations/user.rs index 80be76b24..26352db81 100644 --- a/crates/handlers/src/graphql/mutations/user.rs +++ b/crates/handlers/src/graphql/mutations/user.rs @@ -144,9 +144,6 @@ impl LockUserPayload { struct UnlockUserInput { /// The ID of the user to unlock user_id: ID, - - /// Reactivate the user if it had been deactivated - reactivate: Option, } /// The status of the `unlockUser` mutation. @@ -566,7 +563,7 @@ impl UserMutations { Ok(LockUserPayload::Locked(user)) } - /// Unlock a user. This is only available to administrators. + /// Unlock and reactivate a user. This is only available to administrators. async fn unlock_user( &self, ctx: &Context<'_>, @@ -588,18 +585,12 @@ impl UserMutations { return Ok(UnlockUserPayload::NotFound); }; - let user = if input.reactivate.unwrap_or(false) { - // Call the homeserver synchronously to reactivate the user - let mxid = matrix.mxid(&user.username); - matrix.reactivate_user(&mxid).await?; + // Call the homeserver synchronously to reactivate the user + let mxid = matrix.mxid(&user.username); + matrix.reactivate_user(&mxid).await?; - // Now reactivate the user in our database - repo.user().reactivate(user).await? - } else { - user - }; - - // Now unlock the user in our database + // Now reactivate & unlock the user in our database + let user = repo.user().reactivate(user).await?; let user = repo.user().unlock(user).await?; repo.save().await?; diff --git a/frontend/schema.graphql b/frontend/schema.graphql index 993a554a3..99da32010 100644 --- a/frontend/schema.graphql +++ b/frontend/schema.graphql @@ -886,7 +886,7 @@ type Mutation { """ lockUser(input: LockUserInput!): LockUserPayload! """ - Unlock a user. This is only available to administrators. + Unlock and reactivate a user. This is only available to administrators. """ unlockUser(input: UnlockUserInput!): UnlockUserPayload! """ @@ -1842,10 +1842,6 @@ input UnlockUserInput { The ID of the user to unlock """ userId: ID! - """ - Reactivate the user if it had been deactivated - """ - reactivate: Boolean } """ diff --git a/frontend/src/gql/graphql.ts b/frontend/src/gql/graphql.ts index b07b89cf5..b6f357170 100644 --- a/frontend/src/gql/graphql.ts +++ b/frontend/src/gql/graphql.ts @@ -604,7 +604,7 @@ export type Mutation = { setPrimaryEmail: SetPrimaryEmailPayload; /** Start a new email authentication flow */ startEmailAuthentication: StartEmailAuthenticationPayload; - /** Unlock a user. This is only available to administrators. */ + /** Unlock and reactivate a user. This is only available to administrators. */ unlockUser: UnlockUserPayload; }; @@ -1347,8 +1347,6 @@ export type StartEmailAuthenticationStatus = /** The input for the `unlockUser` mutation. */ export type UnlockUserInput = { - /** Reactivate the user if it had been deactivated */ - reactivate?: InputMaybe; /** The ID of the user to unlock */ userId: Scalars['ID']['input']; };