You've already forked authentication-service
mirror of
https://github.com/matrix-org/matrix-authentication-service.git
synced 2025-11-20 12:02:22 +03:00
Show whether the user is deactivated on the homeserver in the GraphQL API
Fix #2375
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// Copyright 2023 The Matrix.org Foundation C.I.C.
|
||||
// Copyright 2023, 2024 The Matrix.org Foundation C.I.C.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
@@ -25,6 +25,9 @@ pub struct MatrixUser {
|
||||
|
||||
/// The avatar URL of the user, if any.
|
||||
avatar_url: Option<String>,
|
||||
|
||||
/// Whether the user is deactivated on the homeserver.
|
||||
deactivated: bool,
|
||||
}
|
||||
|
||||
impl MatrixUser {
|
||||
@@ -40,6 +43,7 @@ impl MatrixUser {
|
||||
mxid,
|
||||
display_name: info.displayname,
|
||||
avatar_url: info.avatar_url,
|
||||
deactivated: info.deactivated,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,6 +217,7 @@ impl HomeserverConnection for SynapseConnection {
|
||||
Ok(MatrixUser {
|
||||
displayname: body.display_name,
|
||||
avatar_url: body.avatar_url,
|
||||
deactivated: body.deactivated.unwrap_or(false),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ pub type BoxHomeserverConnection<Error = anyhow::Error> =
|
||||
pub struct MatrixUser {
|
||||
pub displayname: Option<String>,
|
||||
pub avatar_url: Option<String>,
|
||||
pub deactivated: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
|
||||
@@ -27,6 +27,7 @@ struct MockUser {
|
||||
devices: HashSet<String>,
|
||||
emails: Option<Vec<String>>,
|
||||
cross_signing_reset_allowed: bool,
|
||||
deactivated: bool,
|
||||
}
|
||||
|
||||
/// A mock implementation of a [`HomeserverConnection`], which never fails and
|
||||
@@ -69,6 +70,7 @@ impl crate::HomeserverConnection for HomeserverConnection {
|
||||
Ok(MatrixUser {
|
||||
displayname: user.displayname.clone(),
|
||||
avatar_url: user.avatar_url.clone(),
|
||||
deactivated: user.deactivated,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -82,6 +84,7 @@ impl crate::HomeserverConnection for HomeserverConnection {
|
||||
devices: HashSet::new(),
|
||||
emails: None,
|
||||
cross_signing_reset_allowed: false,
|
||||
deactivated: false,
|
||||
});
|
||||
|
||||
anyhow::ensure!(
|
||||
@@ -140,6 +143,7 @@ impl crate::HomeserverConnection for HomeserverConnection {
|
||||
let user = users.get_mut(mxid).context("User not found")?;
|
||||
user.devices.clear();
|
||||
user.emails = None;
|
||||
user.deactivated = true;
|
||||
if erase {
|
||||
user.avatar_url = None;
|
||||
user.displayname = None;
|
||||
@@ -148,7 +152,11 @@ impl crate::HomeserverConnection for HomeserverConnection {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn reactivate_user(&self, _mxid: &str) -> Result<(), Self::Error> {
|
||||
async fn reactivate_user(&self, mxid: &str) -> Result<(), Self::Error> {
|
||||
let mut users = self.users.write().await;
|
||||
let user = users.get_mut(mxid).context("User not found")?;
|
||||
user.deactivated = false;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -698,6 +698,10 @@ type MatrixUser {
|
||||
The avatar URL of the user, if any.
|
||||
"""
|
||||
avatarUrl: String
|
||||
"""
|
||||
Whether the user is deactivated on the homeserver.
|
||||
"""
|
||||
deactivated: Boolean!
|
||||
}
|
||||
|
||||
"""
|
||||
|
||||
@@ -449,6 +449,8 @@ export type MatrixUser = {
|
||||
__typename?: 'MatrixUser';
|
||||
/** The avatar URL of the user, if any. */
|
||||
avatarUrl?: Maybe<Scalars['String']['output']>;
|
||||
/** Whether the user is deactivated on the homeserver. */
|
||||
deactivated: Scalars['Boolean']['output'];
|
||||
/** The display name of the user, if any. */
|
||||
displayName?: Maybe<Scalars['String']['output']>;
|
||||
/** The Matrix ID of the user. */
|
||||
|
||||
@@ -1120,6 +1120,17 @@ export default {
|
||||
},
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "deactivated",
|
||||
"type": {
|
||||
"kind": "NON_NULL",
|
||||
"ofType": {
|
||||
"kind": "SCALAR",
|
||||
"name": "Any"
|
||||
}
|
||||
},
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "displayName",
|
||||
"type": {
|
||||
|
||||
Reference in New Issue
Block a user