Skip to content

Commit 8ac2770

Browse files
committed
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.
1 parent d807975 commit 8ac2770

File tree

3 files changed

+8
-23
lines changed

3 files changed

+8
-23
lines changed

crates/handlers/src/graphql/mutations/user.rs

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,6 @@ impl LockUserPayload {
144144
struct UnlockUserInput {
145145
/// The ID of the user to unlock
146146
user_id: ID,
147-
148-
/// Reactivate the user if it had been deactivated
149-
reactivate: Option<bool>,
150147
}
151148

152149
/// The status of the `unlockUser` mutation.
@@ -566,7 +563,7 @@ impl UserMutations {
566563
Ok(LockUserPayload::Locked(user))
567564
}
568565

569-
/// Unlock a user. This is only available to administrators.
566+
/// Unlock and reactivate a user. This is only available to administrators.
570567
async fn unlock_user(
571568
&self,
572569
ctx: &Context<'_>,
@@ -588,18 +585,12 @@ impl UserMutations {
588585
return Ok(UnlockUserPayload::NotFound);
589586
};
590587

591-
let user = if input.reactivate.unwrap_or(false) {
592-
// Call the homeserver synchronously to reactivate the user
593-
let mxid = matrix.mxid(&user.username);
594-
matrix.reactivate_user(&mxid).await?;
595-
596-
// Now reactivate the user in our database
597-
repo.user().reactivate(user).await?
598-
} else {
599-
user
600-
};
588+
// Call the homeserver synchronously to reactivate the user
589+
let mxid = matrix.mxid(&user.username);
590+
matrix.reactivate_user(&mxid).await?;
601591

602-
// Now unlock the user in our database
592+
// Now reactivate & unlock the user in our database
593+
let user = repo.user().reactivate(user).await?;
603594
let user = repo.user().unlock(user).await?;
604595

605596
repo.save().await?;

frontend/schema.graphql

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,7 @@ type Mutation {
886886
"""
887887
lockUser(input: LockUserInput!): LockUserPayload!
888888
"""
889-
Unlock a user. This is only available to administrators.
889+
Unlock and reactivate a user. This is only available to administrators.
890890
"""
891891
unlockUser(input: UnlockUserInput!): UnlockUserPayload!
892892
"""
@@ -1842,10 +1842,6 @@ input UnlockUserInput {
18421842
The ID of the user to unlock
18431843
"""
18441844
userId: ID!
1845-
"""
1846-
Reactivate the user if it had been deactivated
1847-
"""
1848-
reactivate: Boolean
18491845
}
18501846

18511847
"""

frontend/src/gql/graphql.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ export type Mutation = {
604604
setPrimaryEmail: SetPrimaryEmailPayload;
605605
/** Start a new email authentication flow */
606606
startEmailAuthentication: StartEmailAuthenticationPayload;
607-
/** Unlock a user. This is only available to administrators. */
607+
/** Unlock and reactivate a user. This is only available to administrators. */
608608
unlockUser: UnlockUserPayload;
609609
};
610610

@@ -1347,8 +1347,6 @@ export type StartEmailAuthenticationStatus =
13471347

13481348
/** The input for the `unlockUser` mutation. */
13491349
export type UnlockUserInput = {
1350-
/** Reactivate the user if it had been deactivated */
1351-
reactivate?: InputMaybe<Scalars['Boolean']['input']>;
13521350
/** The ID of the user to unlock */
13531351
userId: Scalars['ID']['input'];
13541352
};

0 commit comments

Comments
 (0)