Skip to content
This repository was archived by the owner on Sep 10, 2024. It is now read-only.

Commit 6c0effd

Browse files
committed
Show whether the user is deactivated on the homeserver in the GraphQL API
Fix #2375
1 parent e9a57a4 commit 6c0effd

File tree

7 files changed

+33
-2
lines changed

7 files changed

+33
-2
lines changed

crates/handlers/src/graphql/model/matrix.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2023 The Matrix.org Foundation C.I.C.
1+
// Copyright 2023, 2024 The Matrix.org Foundation C.I.C.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -25,6 +25,9 @@ pub struct MatrixUser {
2525

2626
/// The avatar URL of the user, if any.
2727
avatar_url: Option<String>,
28+
29+
/// Whether the user is deactivated on the homeserver.
30+
deactivated: bool,
2831
}
2932

3033
impl MatrixUser {
@@ -40,6 +43,7 @@ impl MatrixUser {
4043
mxid,
4144
display_name: info.displayname,
4245
avatar_url: info.avatar_url,
46+
deactivated: info.deactivated,
4347
})
4448
}
4549
}

crates/matrix-synapse/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ impl HomeserverConnection for SynapseConnection {
217217
Ok(MatrixUser {
218218
displayname: body.display_name,
219219
avatar_url: body.avatar_url,
220+
deactivated: body.deactivated.unwrap_or(false),
220221
})
221222
}
222223

crates/matrix/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ pub type BoxHomeserverConnection<Error = anyhow::Error> =
2626
pub struct MatrixUser {
2727
pub displayname: Option<String>,
2828
pub avatar_url: Option<String>,
29+
pub deactivated: bool,
2930
}
3031

3132
#[derive(Debug, Default)]

crates/matrix/src/mock.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ struct MockUser {
2727
devices: HashSet<String>,
2828
emails: Option<Vec<String>>,
2929
cross_signing_reset_allowed: bool,
30+
deactivated: bool,
3031
}
3132

3233
/// A mock implementation of a [`HomeserverConnection`], which never fails and
@@ -69,6 +70,7 @@ impl crate::HomeserverConnection for HomeserverConnection {
6970
Ok(MatrixUser {
7071
displayname: user.displayname.clone(),
7172
avatar_url: user.avatar_url.clone(),
73+
deactivated: user.deactivated,
7274
})
7375
}
7476

@@ -82,6 +84,7 @@ impl crate::HomeserverConnection for HomeserverConnection {
8284
devices: HashSet::new(),
8385
emails: None,
8486
cross_signing_reset_allowed: false,
87+
deactivated: false,
8588
});
8689

8790
anyhow::ensure!(
@@ -140,6 +143,7 @@ impl crate::HomeserverConnection for HomeserverConnection {
140143
let user = users.get_mut(mxid).context("User not found")?;
141144
user.devices.clear();
142145
user.emails = None;
146+
user.deactivated = true;
143147
if erase {
144148
user.avatar_url = None;
145149
user.displayname = None;
@@ -148,7 +152,11 @@ impl crate::HomeserverConnection for HomeserverConnection {
148152
Ok(())
149153
}
150154

151-
async fn reactivate_user(&self, _mxid: &str) -> Result<(), Self::Error> {
155+
async fn reactivate_user(&self, mxid: &str) -> Result<(), Self::Error> {
156+
let mut users = self.users.write().await;
157+
let user = users.get_mut(mxid).context("User not found")?;
158+
user.deactivated = false;
159+
152160
Ok(())
153161
}
154162

frontend/schema.graphql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,10 @@ type MatrixUser {
698698
The avatar URL of the user, if any.
699699
"""
700700
avatarUrl: String
701+
"""
702+
Whether the user is deactivated on the homeserver.
703+
"""
704+
deactivated: Boolean!
701705
}
702706

703707
"""

frontend/src/gql/graphql.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,8 @@ export type MatrixUser = {
449449
__typename?: 'MatrixUser';
450450
/** The avatar URL of the user, if any. */
451451
avatarUrl?: Maybe<Scalars['String']['output']>;
452+
/** Whether the user is deactivated on the homeserver. */
453+
deactivated: Scalars['Boolean']['output'];
452454
/** The display name of the user, if any. */
453455
displayName?: Maybe<Scalars['String']['output']>;
454456
/** The Matrix ID of the user. */

frontend/src/gql/schema.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,6 +1120,17 @@ export default {
11201120
},
11211121
"args": []
11221122
},
1123+
{
1124+
"name": "deactivated",
1125+
"type": {
1126+
"kind": "NON_NULL",
1127+
"ofType": {
1128+
"kind": "SCALAR",
1129+
"name": "Any"
1130+
}
1131+
},
1132+
"args": []
1133+
},
11231134
{
11241135
"name": "displayName",
11251136
"type": {

0 commit comments

Comments
 (0)