diff --git a/src/components/UserAccountData.tsx b/src/components/UserAccountData.tsx index f167239..01dd0db 100644 --- a/src/components/UserAccountData.tsx +++ b/src/components/UserAccountData.tsx @@ -40,7 +40,7 @@ const UserAccountData = () => { <> {translate("resources.users.account_data.title")} - + }> diff --git a/src/components/UserRateLimits.tsx b/src/components/UserRateLimits.tsx index ac1fe7d..6e32a16 100644 --- a/src/components/UserRateLimits.tsx +++ b/src/components/UserRateLimits.tsx @@ -33,7 +33,6 @@ const RateLimitRow = ({ }} > { } }; - const UserData = ({ formData }) => { const form = useFormContext(); @@ -197,17 +196,17 @@ const LoginPage = () => { const domain = splitMxid(formData.username)?.domain; if (domain) { const url = await getWellKnownUrl(domain); - if (allowAnyBaseUrl || (allowMultipleBaseUrls && restrictBaseUrl.includes(url))) { - form.setValue("base_url", url, { - shouldValidate: true, - shouldDirty: true, - }); + if (allowAnyBaseUrl || (allowMultipleBaseUrls && restrictBaseUrl.includes(url))) { + form.setValue("base_url", url, { + shouldValidate: true, + shouldDirty: true, + }); checkServerInfo(url); } } }; - const handleBaseUrlBlurOrChange = (event) => { + const handleBaseUrlBlurOrChange = event => { // Get the value either from the event (onChange) or from formData (onBlur) const value = event?.target?.value || formData.base_url; @@ -318,16 +317,17 @@ const LoginPage = () => { choices={baseUrlChoices} /> )} - {!allowMultipleBaseUrls && ( + {!allowMultipleBaseUrls && ( + )} {serverVersion} diff --git a/src/resources/users.tsx b/src/resources/users.tsx index 4c73583..198f43e 100644 --- a/src/resources/users.tsx +++ b/src/resources/users.tsx @@ -115,7 +115,8 @@ const userFilters = [ , , , - , + // waiting for https://github.com/element-hq/synapse/issues/18016 + // , ]; const UserPreventSelfDelete: React.FC<{ @@ -208,7 +209,6 @@ export const UserList = (props: ListProps) => ( - diff --git a/src/synapse/dataProvider.ts b/src/synapse/dataProvider.ts index 8b0deee..bb6c0f9 100644 --- a/src/synapse/dataProvider.ts +++ b/src/synapse/dataProvider.ts @@ -348,6 +348,10 @@ export interface SynapseDataProvider extends DataProvider { getAccountData: (id: Identifier) => Promise; checkUsernameAvailability: (username: string) => Promise; makeRoomAdmin: (room_id: string, user_id: string) => Promise<{ success: boolean; error?: string; errcode?: string }>; + suspendUser: ( + id: Identifier, + suspendValue: boolean + ) => Promise<{ success: boolean; error?: string; errcode?: string }>; getServerRunningProcess: (etkeAdminUrl: string) => Promise; getServerStatus: (etkeAdminUrl: string) => Promise; getServerNotifications: (etkeAdminUrl: string) => Promise; @@ -782,6 +786,7 @@ const baseDataProvider: SynapseDataProvider = { const res = resourceMap[resource]; const endpoint_url = homeserver + res.path; + const { json } = await jsonClient(`${endpoint_url}/${encodeURIComponent(params.id)}`, { method: "PUT", body: JSON.stringify(params.data, filterNullValues), @@ -1026,6 +1031,22 @@ const baseDataProvider: SynapseDataProvider = { throw error; } }, + suspendUser: async (id: Identifier, suspendValue: boolean) => { + const base_url = localStorage.getItem("base_url"); + const endpoint_url = `${base_url}/_synapse/admin/v1/suspend/${encodeURIComponent(returnMXID(id))}`; + try { + const { json } = await jsonClient(endpoint_url, { + method: "PUT", + body: JSON.stringify({ suspend: suspendValue }), + }); + return { success: true }; + } catch (error) { + if (error instanceof HttpError) { + return { success: false, error: error.body.error, errcode: error.body.errcode }; + } + throw error; + } + }, getServerRunningProcess: async (etkeAdminUrl: string, burstCache = false): Promise => { const locked_at = ""; const command = ""; @@ -1427,12 +1448,18 @@ const dataProvider = withLifecycleCallbacks(baseDataProvider, [ const avatarFile = params.data.avatar_file?.rawFile; const avatarErase = params.data.avatar_erase; const rates = params.data.rates; + const suspended = params.data.suspended; if (rates) { await dataProvider.setRateLimits(params.id, rates); delete params.data.rates; } + if (suspended !== undefined) { + await (dataProvider as SynapseDataProvider).suspendUser(params.id, suspended); + delete params.data.suspended; + } + if (avatarErase) { params.data.avatar_url = ""; return params;