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");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with 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.
|
/// The avatar URL of the user, if any.
|
||||||
avatar_url: Option<String>,
|
avatar_url: Option<String>,
|
||||||
|
|
||||||
|
/// Whether the user is deactivated on the homeserver.
|
||||||
|
deactivated: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MatrixUser {
|
impl MatrixUser {
|
||||||
@@ -40,6 +43,7 @@ impl MatrixUser {
|
|||||||
mxid,
|
mxid,
|
||||||
display_name: info.displayname,
|
display_name: info.displayname,
|
||||||
avatar_url: info.avatar_url,
|
avatar_url: info.avatar_url,
|
||||||
|
deactivated: info.deactivated,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -217,6 +217,7 @@ impl HomeserverConnection for SynapseConnection {
|
|||||||
Ok(MatrixUser {
|
Ok(MatrixUser {
|
||||||
displayname: body.display_name,
|
displayname: body.display_name,
|
||||||
avatar_url: body.avatar_url,
|
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 struct MatrixUser {
|
||||||
pub displayname: Option<String>,
|
pub displayname: Option<String>,
|
||||||
pub avatar_url: Option<String>,
|
pub avatar_url: Option<String>,
|
||||||
|
pub deactivated: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ struct MockUser {
|
|||||||
devices: HashSet<String>,
|
devices: HashSet<String>,
|
||||||
emails: Option<Vec<String>>,
|
emails: Option<Vec<String>>,
|
||||||
cross_signing_reset_allowed: bool,
|
cross_signing_reset_allowed: bool,
|
||||||
|
deactivated: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A mock implementation of a [`HomeserverConnection`], which never fails and
|
/// A mock implementation of a [`HomeserverConnection`], which never fails and
|
||||||
@@ -69,6 +70,7 @@ impl crate::HomeserverConnection for HomeserverConnection {
|
|||||||
Ok(MatrixUser {
|
Ok(MatrixUser {
|
||||||
displayname: user.displayname.clone(),
|
displayname: user.displayname.clone(),
|
||||||
avatar_url: user.avatar_url.clone(),
|
avatar_url: user.avatar_url.clone(),
|
||||||
|
deactivated: user.deactivated,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,6 +84,7 @@ impl crate::HomeserverConnection for HomeserverConnection {
|
|||||||
devices: HashSet::new(),
|
devices: HashSet::new(),
|
||||||
emails: None,
|
emails: None,
|
||||||
cross_signing_reset_allowed: false,
|
cross_signing_reset_allowed: false,
|
||||||
|
deactivated: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
anyhow::ensure!(
|
anyhow::ensure!(
|
||||||
@@ -140,6 +143,7 @@ impl crate::HomeserverConnection for HomeserverConnection {
|
|||||||
let user = users.get_mut(mxid).context("User not found")?;
|
let user = users.get_mut(mxid).context("User not found")?;
|
||||||
user.devices.clear();
|
user.devices.clear();
|
||||||
user.emails = None;
|
user.emails = None;
|
||||||
|
user.deactivated = true;
|
||||||
if erase {
|
if erase {
|
||||||
user.avatar_url = None;
|
user.avatar_url = None;
|
||||||
user.displayname = None;
|
user.displayname = None;
|
||||||
@@ -148,7 +152,11 @@ impl crate::HomeserverConnection for HomeserverConnection {
|
|||||||
Ok(())
|
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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -698,6 +698,10 @@ type MatrixUser {
|
|||||||
The avatar URL of the user, if any.
|
The avatar URL of the user, if any.
|
||||||
"""
|
"""
|
||||||
avatarUrl: String
|
avatarUrl: String
|
||||||
|
"""
|
||||||
|
Whether the user is deactivated on the homeserver.
|
||||||
|
"""
|
||||||
|
deactivated: Boolean!
|
||||||
}
|
}
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -449,6 +449,8 @@ export type MatrixUser = {
|
|||||||
__typename?: 'MatrixUser';
|
__typename?: 'MatrixUser';
|
||||||
/** The avatar URL of the user, if any. */
|
/** The avatar URL of the user, if any. */
|
||||||
avatarUrl?: Maybe<Scalars['String']['output']>;
|
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. */
|
/** The display name of the user, if any. */
|
||||||
displayName?: Maybe<Scalars['String']['output']>;
|
displayName?: Maybe<Scalars['String']['output']>;
|
||||||
/** The Matrix ID of the user. */
|
/** The Matrix ID of the user. */
|
||||||
|
|||||||
@@ -1120,6 +1120,17 @@ export default {
|
|||||||
},
|
},
|
||||||
"args": []
|
"args": []
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "deactivated",
|
||||||
|
"type": {
|
||||||
|
"kind": "NON_NULL",
|
||||||
|
"ofType": {
|
||||||
|
"kind": "SCALAR",
|
||||||
|
"name": "Any"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"args": []
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "displayName",
|
"name": "displayName",
|
||||||
"type": {
|
"type": {
|
||||||
|
|||||||
Reference in New Issue
Block a user