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.
This commit is contained in:
Andrew Ferrazzutti
2025-07-16 13:49:00 -04:00
parent 49540693ab
commit 8bacf44c68
3 changed files with 8 additions and 23 deletions

View File

@@ -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<bool>,
}
/// 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?;

View File

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

View File

@@ -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<Scalars['Boolean']['input']>;
/** The ID of the user to unlock */
userId: Scalars['ID']['input'];
};