### Example: Starting the app with Bootstrap Source: https://github.com/awesome-technologies/synapse-admin Shows how to mount the Bootstrap component as the root of the React application. ```tsx import { Bootstrap } from "./bootstrap"; createRoot(root).render(); ``` -------------------------------- ### Install and run from source with yarn Source: https://github.com/awesome-technologies/synapse-admin/blob/master/README.md Commands to clone the repository, install dependencies, and start the development server. Requires git, yarn, and nodejs. ```bash git clone https://github.com/Awesome-Technologies/synapse-admin.git ``` ```bash cd synapse-admin ``` ```bash yarn install ``` ```bash yarn start ``` -------------------------------- ### dateFormatter and dateParser usage example Source: https://github.com/awesome-technologies/synapse-admin Example calls showing dateFormatter output and dateParser return value. ```ts dateFormatter(1720000000000); // e.g. "2024-07-03T10:00" dateParser("2024-07-03T10:00"); // 1720000000000 (number) or null ``` -------------------------------- ### Usage examples for fetchJson and fetchJsonWithAuth Source: https://github.com/awesome-technologies/synapse-admin Shows unauthenticated GET and authenticated GET with automatic bearer token from localStorage. ```ts const { json } = await fetchJson(wellKnownUrl, { method: "GET" }); // Authenticated variant — the bearer token is read from localStorage automatically const { json: rooms } = await fetchJsonWithAuth( buildUrl(baseUrl, "/_synapse/admin/v1/rooms"), { method: "GET" } ); ``` -------------------------------- ### config.json example with restrictBaseUrl array Source: https://github.com/awesome-technologies/synapse-admin Example from the README showing the restrictBaseUrl option as an array of allowed homeserver URLs. When an array is used, the login page renders a select of the listed URLs. ```json { "restrictBaseUrl": ["https://your-first-matrix-server.example.com", "https://your-second-matrix-server.example.com"] } ``` -------------------------------- ### fetchJsonFromStoredBaseUrl usage example Source: https://github.com/awesome-technologies/synapse-admin Example usage of `fetchJsonFromStoredBaseUrl` to fetch the server version endpoint. ```ts const { json } = await fetchJsonFromStoredBaseUrl("/_synapse/admin/v1/server_version", { method: "GET" }); ``` -------------------------------- ### login usage examples Source: https://github.com/awesome-technologies/synapse-admin Two usage examples for the login method: password login and SSO callback login. The password login is called by react-admin's useLogin, while the SSO callback login is performed by LoginPage after redirect. ```typescript // Password login (as called by react-admin's useLogin) await authProvider.login({ base_url: "https://matrix.example.org", username: "admin", password: "s3cret" }); // SSO callback login (as performed by LoginPage after the redirect) await authProvider.login({ base_url: savedBaseUrl, username: null, password: null, loginToken: ssoToken }); ``` -------------------------------- ### getMediaUrl usage example Source: https://github.com/awesome-technologies/synapse-admin Example usage of `getMediaUrl` to create a link target for media download. ```ts const href = getMediaUrl(`${homeserver}/${src}`); // link target for media download ``` -------------------------------- ### getSupportedLoginFlows usage example Source: https://github.com/awesome-technologies/synapse-admin Example usage of `getSupportedLoginFlows` to check if SSO is supported by inspecting the flow types. ```ts const flows = await getSupportedLoginFlows(baseUrl); const supportsSSO = flows.some(f => f.type === "m.login.sso"); ``` -------------------------------- ### useGetIdentity example Source: https://github.com/awesome-technologies/synapse-admin Example usage of the getIdentity method through react-admin's useGetIdentity hook, showing the returned identity object. ```tsx const { data: identity, isLoading } = useGetIdentity(); // identity = { id: "@admin:localhost", fullName: "admin" } ``` -------------------------------- ### GET /_matrix/client/versions Source: https://github.com/awesome-technologies/synapse-admin Retrieve the supported Matrix specification versions. ```APIDOC ## [GET] /_matrix/client/versions ### Description Retrieve the supported Matrix specification versions. ### Method GET ### Endpoint /_matrix/client/versions ### Response #### Success Response (200) - **MatrixFeatures** (object) - The supported features. ``` -------------------------------- ### Example: catching requireStoredBaseUrl error Source: https://github.com/awesome-technologies/synapse-admin Shows how to catch the "Homeserver not set" error to redirect to login when session is not initialized. ```ts try { const url = requireStoredBaseUrl(); } catch (e: unknown) { if (e instanceof Error && e.message === "Homeserver not set") { // session not initialized — redirect to login } } ``` -------------------------------- ### GET /_matrix/client/r0/login Source: https://github.com/awesome-technologies/synapse-admin Retrieve the supported login flows. ```APIDOC ## [GET] /_matrix/client/r0/login ### Description Retrieve the supported login flows. ### Method GET ### Endpoint /_matrix/client/r0/login ### Response #### Success Response (200) - **flows** (array of MatrixLoginFlow) - The supported login flows. ``` -------------------------------- ### GET /_synapse/admin/v1/server_version Source: https://github.com/awesome-technologies/synapse-admin Retrieve the Synapse server version. ```APIDOC ## [GET] /_synapse/admin/v1/server_version ### Description Retrieve the Synapse server version. ### Method GET ### Endpoint /_synapse/admin/v1/server_version ### Response #### Success Response (200) - **server_version** (string) - The server version string. ``` -------------------------------- ### Example: useAppContext to check restrictBaseUrl Source: https://github.com/awesome-technologies/synapse-admin Shows how to consume useAppContext to determine if the homeserver URL field should be editable. The boolean allowAnyBaseUrl is true when restrictBaseUrl is neither a string nor an array. ```tsx const { restrictBaseUrl } = useAppContext(); const allowAnyBaseUrl = !(typeof restrictBaseUrl === "string" || Array.isArray(restrictBaseUrl)); ``` -------------------------------- ### Catch standard Error instances by message Source: https://github.com/awesome-technologies/synapse-admin Use `instanceof Error` and match the message string to handle specific errors from `requireStoredBaseUrl` and `getResourceConfig`. The first example checks for 'Homeserver not set' to redirect unauthenticated users to login; the second checks for 'Unknown resource' to handle resource typos. ```TypeScript import { requireStoredBaseUrl, requireStoredHomeServer } from "../synapse/synapse"; import { getResourceConfig } from "../synapse/dataProvider"; try { requireStoredBaseUrl(); } catch (e: unknown) { if (e instanceof Error && e.message === "Homeserver not set") { // session not initialized — send the user to the login page } } try { getResourceConfig("unknown_resource"); } catch (e: unknown) { if (e instanceof Error && e.message.startsWith("Unknown resource")) { // resource typo handled } } ``` -------------------------------- ### npm scripts in package.json Source: https://github.com/awesome-technologies/synapse-admin Lists the npm scripts defined in package.json for development, building, testing, and linting. Includes commands for starting the Vite dev server, building, generating coverage badges, linting, type checking, running unit tests, and end-to-end tests. ```bash vite serve ``` ```bash vite build ``` ```bash node ./scripts/generate-coverage-badge.mjs ``` ```bash eslint --ignore-path .gitignore --ext .ts,.tsx,.yml,.yaml . ``` ```bash yarn lint --fix ``` ```bash tsc --noEmit ``` ```bash vitest run ``` ```bash vitest run --coverage ``` ```bash vitest watch ``` ```bash playwright test ``` ```bash ./scripts/e2e/run.sh ``` -------------------------------- ### Example: Using UserList in a page Source: https://github.com/awesome-technologies/synapse-admin Shows how to import and render the UserList component in a custom page. ```tsx import { UserList } from "./resources/users"; export const UsersPage = () => ; ``` -------------------------------- ### CSV parsing and verification example Source: https://github.com/awesome-technologies/synapse-admin Example usage of parseCsv with the verifyImportCsv handler, as used by the file upload handler. It parses the CSV with header and skipEmptyLines options, then calls verifyImportCsv with the result and handlers. ```typescript parseCsv(file, { header: true, skipEmptyLines: true, complete: result => { if (result.errors) setError(result.errors.map(e => e.toString())); verifyImportCsv(result, { setValues, setStats, setError, translate }); }, }); ``` -------------------------------- ### GET /_matrix/media/r0/thumbnail// Source: https://github.com/awesome-technologies/synapse-admin Generate a thumbnail of a media file. Used as the avatar source. ```APIDOC ## [GET] /_matrix/media/r0/thumbnail// ### Description Generate a thumbnail of a media file. Used as the avatar source. ### Method GET ### Endpoint /_matrix/media/r0/thumbnail// ### Parameters #### Query Parameters - **width** (integer) - Required - Thumbnail width in pixels. - **height** (integer) - Required - Thumbnail height in pixels. - **method** (string) - Required - Thumbnail method (e.g., scale). ``` -------------------------------- ### login error handling Source: https://github.com/awesome-technologies/synapse-admin Example of handling login errors with a try/catch block, showing a notification with the error message or a default sign-in error. ```typescript try { await authProvider.login(auth); } catch (error) { notify( typeof error === "string" ? error : error?.message || "ra.auth.sign_in_error", { type: "warning" } ); } ``` -------------------------------- ### splitMxid usage example Source: https://github.com/awesome-technologies/synapse-admin Shows how to use splitMxid to extract the domain from a valid MXID and safely guard against invalid input. ```ts import { splitMxid } from "../synapse/synapse"; const parts = splitMxid("@alice:example.org"); // parts = { name: "alice", domain: "example.org" } // Invalid or non-string input -> undefined (safe to use as a guard) const domain = splitMxid(input?.trim())?.domain; if (domain) { // do discovery against `domain` } ``` -------------------------------- ### mxcUrlToHttp usage example Source: https://github.com/awesome-technologies/synapse-admin Example call to mxcUrlToHttp with an MXC URI, producing a thumbnail URL resolved against the stored base URL. ```ts const thumb = mxcUrlToHttp("mxc://srv.example/AbCdEfG"); // "https://hs.example.org/_matrix/media/r0/thumbnail/srv.example/AbCdEfG?width=24&height=24&method=scale" ``` -------------------------------- ### getServerVersion usage example Source: https://github.com/awesome-technologies/synapse-admin Calls getServerVersion and updates the server version display, catching errors to clear the version. ```typescript getServerVersion(baseUrl) .then(v => setServerVersion(`${translate("synapseadmin.auth.server_version")} ${v}`)) .catch(() => setServerVersion("")); ``` -------------------------------- ### GET /_synapse/admin/v1/users//media Source: https://github.com/awesome-technologies/synapse-admin Retrieves the media uploaded by a user. ```APIDOC ## GET /_synapse/admin/v1/users//media ### Description Retrieves the media uploaded by a user. ### Method GET ### Endpoint /_synapse/admin/v1/users//media ### Parameters #### Path Parameters - **id** (string) - Required - The user ID. ### Response #### Success Response (200) - **media** (array) - List of media objects. ``` -------------------------------- ### GET https:///.well-known/matrix/client Source: https://github.com/awesome-technologies/synapse-admin Perform well-known discovery to find the homeserver base URL. Falls back to https:// on any error. ```APIDOC ## [GET] https:///.well-known/matrix/client ### Description Perform well-known discovery to find the homeserver base URL. Falls back to https:// on any error. ### Method GET ### Endpoint https:///.well-known/matrix/client ### Response #### Success Response (200) - **m.homeserver.base_url** (string) - The base URL of the homeserver. ``` -------------------------------- ### GET /_synapse/admin/v1/rooms/ Source: https://github.com/awesome-technologies/synapse-admin Retrieves a single room by ID. ```APIDOC ## [GET] /_synapse/admin/v1/rooms/ ### Description Retrieves a single room by ID. ### Method GET ### Endpoint /_synapse/admin/v1/rooms/ ### Parameters #### Path Parameters - **id** (string) - Required - The room ID. ### Response #### Success Response (200) - **room** (object) - The room object with fields: `joined_members` mapped to `members`, `canonical_alias` to `alias`, `encryption` to `is_encrypted` (boolean). ``` -------------------------------- ### GET /_matrix/media/v1/download/ Source: https://github.com/awesome-technologies/synapse-admin Retrieve a media file for download. This endpoint is used as the link target for the ViewMediaButton. ```APIDOC ## [GET] /_matrix/media/v1/download/ ### Description Retrieve a media file for download. This endpoint is used as the link target for the ViewMediaButton. ### Method GET ### Endpoint /_matrix/media/v1/download/ ### Parameters #### Query Parameters - **allow_redirect** (string) - Optional - Whether to allow redirects. ``` -------------------------------- ### GET /_synapse/admin/v1/rooms Source: https://github.com/awesome-technologies/synapse-admin Retrieves a list of rooms. Supports pagination, sorting, and filtering. ```APIDOC ## [GET] /_synapse/admin/v1/rooms ### Description Retrieves a list of rooms. Supports pagination, sorting, and filtering. ### Method GET ### Endpoint /_synapse/admin/v1/rooms ### Parameters #### Query Parameters - **from** (string) - Optional - Pagination offset. - **limit** (integer) - Optional - Maximum number of rooms to return. - **order_by** (string) - Optional - Field to sort by. - **dir** (string) - Optional - Sort direction. - **user_id** (string) - Optional - Filter by user ID. - **search_term** (string) - Optional - Search term. - **name** (string) - Optional - Filter by name. - **destination** (string) - Optional - Filter by destination. - **guests** (boolean) - Optional - Filter by guest status. - **deactivated** (boolean) - Optional - Filter by deactivated status. - **locked** (boolean) - Optional - Filter by locked status. - **valid** (boolean) - Optional - Filter by validity. ### Response #### Success Response (200) - **rooms** (array) - List of room objects. - **total_rooms** (integer) - Total number of rooms. ``` -------------------------------- ### GET /_synapse/admin/v1/rooms//state Source: https://github.com/awesome-technologies/synapse-admin Retrieves the state of a room. ```APIDOC ## GET /_synapse/admin/v1/rooms//state ### Description Retrieves the state of a room. ### Method GET ### Endpoint /_synapse/admin/v1/rooms//state ### Parameters #### Path Parameters - **id** (string) - Required - The room ID. ### Response #### Success Response (200) - **state** (array) - List of state events. ``` -------------------------------- ### GET {base}/_matrix/client/r0/login/sso/redirect Source: https://github.com/awesome-technologies/synapse-admin Redirect the user to the SSO login page. After successful login, the page returns with a loginToken query parameter. ```APIDOC ## [GET] {base}/_matrix/client/r0/login/sso/redirect ### Description Redirect the user to the SSO login page. After successful login, the page returns with a loginToken query parameter. ### Method GET ### Endpoint {base}/_matrix/client/r0/login/sso/redirect ### Parameters #### Query Parameters - **redirectUrl** (string) - Required - The URL to redirect back to after login. ``` -------------------------------- ### Example: handling getCollectionResource errors Source: https://github.com/awesome-technologies/synapse-admin Shows how to catch errors from `getCollectionResource` and check for the "Unknown resource" message to handle typos or missing resources. ```ts try { const config = getCollectionResource("users"); } catch (e) { if (e instanceof Error && e.message.startsWith("Unknown resource")) { // handle typo/missing resource } } ``` -------------------------------- ### GET /_synapse/admin/v1/registration_tokens Source: https://github.com/awesome-technologies/synapse-admin Retrieves a list of registration tokens. Supports filtering by validity. ```APIDOC ## [GET] /_synapse/admin/v1/registration_tokens ### Description Retrieves a list of registration tokens. Supports filtering by validity. ### Method GET ### Endpoint /_synapse/admin/v1/registration_tokens ### Parameters #### Query Parameters - **from** (string) - Optional - Pagination offset. - **limit** (integer) - Optional - Maximum number of tokens to return. - **order_by** (string) - Optional - Field to sort by. - **dir** (string) - Optional - Sort direction. - **user_id** (string) - Optional - Filter by user ID. - **search_term** (string) - Optional - Search term. - **name** (string) - Optional - Filter by name. - **destination** (string) - Optional - Filter by destination. - **guests** (boolean) - Optional - Filter by guest status. - **deactivated** (boolean) - Optional - Filter by deactivated status. - **locked** (boolean) - Optional - Filter by locked status. - **valid** (boolean) - Optional - Filter by validity. ### Response #### Success Response (200) - **registration_tokens** (array) - List of registration token objects. - **total** (integer) - Total number of tokens. ``` -------------------------------- ### GET /_synapse/admin/v1/federation/destinations//rooms Source: https://github.com/awesome-technologies/synapse-admin Retrieves the rooms associated with a federation destination. ```APIDOC ## GET /_synapse/admin/v1/federation/destinations//rooms ### Description Retrieves the rooms associated with a federation destination. ### Method GET ### Endpoint /_synapse/admin/v1/federation/destinations//rooms ### Parameters #### Path Parameters - **id** (string) - Required - The destination ID. ### Response #### Success Response (200) - **rooms** (array) - List of room IDs. ``` -------------------------------- ### GET /_synapse/admin/v1/rooms//forward_extremities Source: https://github.com/awesome-technologies/synapse-admin Retrieves the forward extremities of a room. ```APIDOC ## GET /_synapse/admin/v1/rooms//forward_extremities ### Description Retrieves the forward extremities of a room. ### Method GET ### Endpoint /_synapse/admin/v1/rooms//forward_extremities ### Parameters #### Path Parameters - **id** (string) - Required - The room ID. ### Response #### Success Response (200) - **forward_extremities** (array) - List of event IDs. ``` -------------------------------- ### getWellKnownUrl usage example Source: https://github.com/awesome-technologies/synapse-admin Calls getWellKnownUrl with a domain and returns the base URL, e.g., 'https://matrix.example.org'. ```typescript const baseUrl = await getWellKnownUrl("example.org"); // e.g. "https://matrix.example.org" ``` -------------------------------- ### getSupportedFeatures usage example Source: https://github.com/awesome-technologies/synapse-admin Calls getSupportedFeatures and logs the joined versions list. ```typescript const features = await getSupportedFeatures(baseUrl); console.log(features.versions.join(", ")); ``` -------------------------------- ### GET /_matrix/client/r0/publicRooms Source: https://github.com/awesome-technologies/synapse-admin Retrieves a list of public rooms from the Matrix client API. ```APIDOC ## [GET] /_matrix/client/r0/publicRooms ### Description Retrieves a list of public rooms from the Matrix client API. ### Method GET ### Endpoint /_matrix/client/r0/publicRooms ### Parameters #### Query Parameters - **from** (string) - Optional - Pagination offset. - **limit** (integer) - Optional - Maximum number of rooms to return. - **order_by** (string) - Optional - Field to sort by. - **dir** (string) - Optional - Sort direction. - **user_id** (string) - Optional - Filter by user ID. - **search_term** (string) - Optional - Search term. - **name** (string) - Optional - Filter by name. - **destination** (string) - Optional - Filter by destination. - **guests** (boolean) - Optional - Filter by guest status. - **deactivated** (boolean) - Optional - Filter by deactivated status. - **locked** (boolean) - Optional - Filter by locked status. - **valid** (boolean) - Optional - Filter by validity. ### Response #### Success Response (200) - **chunk** (array) - List of public room objects. - **total_room_count_estimate** (integer) - Estimated total number of rooms. ``` -------------------------------- ### ServerNoticeButton component definition Source: https://github.com/awesome-technologies/synapse-admin Starts the ServerNoticeButton component. Requires a user record via useRecordContext (returns undefined otherwise). Submit creates a server notice via create("servernotices", { data: { id: record.id, ...values } }) which POSTs to /_synapse/admin/v1/send_server_notice with body { user_id, content: { msgtype: "m.text", body } }. ```ts export const ServerNoticeButton = () => { ``` -------------------------------- ### GET /_synapse/admin/v1/users//joined_rooms Source: https://github.com/awesome-technologies/synapse-admin Retrieves the list of rooms a user has joined. ```APIDOC ## GET /_synapse/admin/v1/users//joined_rooms ### Description Retrieves the list of rooms a user has joined. ### Method GET ### Endpoint /_synapse/admin/v1/users//joined_rooms ### Parameters #### Path Parameters - **id** (string) - Required - The user ID. ### Response #### Success Response (200) - **joined_rooms** (array) - List of room IDs. ``` -------------------------------- ### Example usage of RoomList Source: https://github.com/awesome-technologies/synapse-admin Shows how to import and render the RoomList component in a custom page. ```tsx import { RoomList } from "./resources/rooms"; export const RoomsPage = () => ; ``` -------------------------------- ### doUserImport usage example Source: https://github.com/awesome-technologies/synapse-admin Shows how to call doUserImport with a data provider, values, conflict mode 'stop', password mode true, userid mode 'ignore', dry run true, and handler callbacks. Logs the dry run flag and succeeded records count. ```typescript const results = await doUserImport(dataProvider, values, "stop", true, "ignore", true, { setProgress: p => setProgress(p), setError: msg => setError(msg), translate, }); console.log(results.wasDryRun, results.succeededRecords.length); // simulated run ``` -------------------------------- ### GET /_synapse/admin/v1/whois/ Source: https://github.com/awesome-technologies/synapse-admin Retrieves connection information for a user. The id is the user ID. ```APIDOC ## GET /_synapse/admin/v1/whois/ ### Description Retrieves connection information for a user. The id is the user ID. ### Method GET ### Endpoint /_synapse/admin/v1/whois/ ### Parameters #### Path Parameters - **id** (string) - Required - The user ID. ### Response #### Success Response (200) - **user_id** (string) - The user ID. - **devices** (object) - Device information. ``` -------------------------------- ### GET /_synapse/admin/v1/federation/destinations Source: https://github.com/awesome-technologies/synapse-admin Retrieves a list of federation destinations. Supports filtering by destination. ```APIDOC ## [GET] /_synapse/admin/v1/federation/destinations ### Description Retrieves a list of federation destinations. Supports filtering by destination. ### Method GET ### Endpoint /_synapse/admin/v1/federation/destinations ### Parameters #### Query Parameters - **from** (string) - Optional - Pagination offset. - **limit** (integer) - Optional - Maximum number of destinations to return. - **order_by** (string) - Optional - Field to sort by. - **dir** (string) - Optional - Sort direction. - **user_id** (string) - Optional - Filter by user ID. - **search_term** (string) - Optional - Search term. - **name** (string) - Optional - Filter by name. - **destination** (string) - Optional - Filter by destination. - **guests** (boolean) - Optional - Filter by guest status. - **deactivated** (boolean) - Optional - Filter by deactivated status. - **locked** (boolean) - Optional - Filter by locked status. - **valid** (boolean) - Optional - Filter by validity. ### Response #### Success Response (200) - **destinations** (array) - List of destination objects. - **total** (integer) - Total number of destinations. ``` -------------------------------- ### GET /_synapse/admin/v1/statistics/users/media Source: https://github.com/awesome-technologies/synapse-admin Retrieves user media statistics. Supports filtering by search term. ```APIDOC ## [GET] /_synapse/admin/v1/statistics/users/media ### Description Retrieves user media statistics. Supports filtering by search term. ### Method GET ### Endpoint /_synapse/admin/v1/statistics/users/media ### Parameters #### Query Parameters - **from** (string) - Optional - Pagination offset. - **limit** (integer) - Optional - Maximum number of users to return. - **order_by** (string) - Optional - Field to sort by. - **dir** (string) - Optional - Sort direction. - **user_id** (string) - Optional - Filter by user ID. - **search_term** (string) - Optional - Search term. - **name** (string) - Optional - Filter by name. - **destination** (string) - Optional - Filter by destination. - **guests** (boolean) - Optional - Filter by guest status. - **deactivated** (boolean) - Optional - Filter by deactivated status. - **locked** (boolean) - Optional - Filter by locked status. - **valid** (boolean) - Optional - Filter by validity. ### Response #### Success Response (200) - **users** (array) - List of user media statistics. - **total** (integer) - Total number of users. ``` -------------------------------- ### Run with Docker or docker-compose Source: https://github.com/awesome-technologies/synapse-admin/blob/master/README.md Run the Docker container from the public registry or use the provided docker-compose.yml. Note: on non-amd64 architectures, define a maximum RAM for node or the build will fail. ```bash docker run -p 8080:80 awesometechnologies/synapse-admin ``` ```bash docker-compose up -d ``` -------------------------------- ### UserEdit resource usage example Source: https://github.com/awesome-technologies/synapse-admin Shows how to register the UserEdit component with react-admin's Resource. Editing a user loads data via GET request to the Synapse admin API endpoint. ```tsx // Render the edit page for user "@alice:example.org" // loads GET /_synapse/admin/v2/users/@alice:example.org ``` -------------------------------- ### POST /_synapse/admin/v1/media/unquarantine// Source: https://github.com/awesome-technologies/synapse-admin Unquarantines a media item on a server. ```APIDOC ## POST /_synapse/admin/v1/media/unquarantine// ### Description Unquarantines a media item on a server. ### Method POST ### Endpoint /_synapse/admin/v1/media/unquarantine// ### Parameters #### Path Parameters - **server** (string) - Required - The server name. - **id** (string) - Required - The media ID. ### Response #### Success Response (200) - **status** (string) - Status of the operation. ``` -------------------------------- ### UserCreate resource usage example Source: https://github.com/awesome-technologies/synapse-admin Shows how to register the UserCreate component with react-admin's Resource. Creating a user via this form sends a PUT request to the Synapse admin API endpoint. ```tsx // creates via PUT /_synapse/admin/v2/users/@: ``` -------------------------------- ### UserList component (partial) Source: https://github.com/awesome-technologies/synapse-admin Starts the UserList component definition, which renders a react-admin with filters, sorting, toolbar, pagination, and a DataTable with bulk actions. The snippet is truncated in the source. ```ts export const UserList = (props: ListProps) => ( ``` -------------------------------- ### ServerNoticeBulkButton component definition Source: https://github.com/awesome-technologies/synapse-admin Starts the ServerNoticeBulkButton component. Uses useListContext().selectedIds and useMutation to call dataProvider.createMany("servernotices", { ids: selectedIds, data }). On success, unselects all users via useUnselectAll("users"). ```ts export const ServerNoticeBulkButton = () => { ``` -------------------------------- ### ServerNoticeButton and ServerNoticeBulkButton usage Source: https://github.com/awesome-technologies/synapse-admin Usage example as in the user edit toolbar and user bulk actions. Renders ServerNoticeButton only when the record is not deactivated, and always renders ServerNoticeBulkButton. ```tsx {!record?.deactivated && } ``` -------------------------------- ### POST /_synapse/admin/v1/media/quarantine// Source: https://github.com/awesome-technologies/synapse-admin Quarantines a media item on a server. ```APIDOC ## POST /_synapse/admin/v1/media/quarantine// ### Description Quarantines a media item on a server. ### Method POST ### Endpoint /_synapse/admin/v1/media/quarantine// ### Parameters #### Path Parameters - **server** (string) - Required - The server name. - **data.media_id** (string) - Required - The media ID. ### Response #### Success Response (200) - **status** (string) - Status of the operation. ``` -------------------------------- ### PUT /_synapse/admin/v2/users/@: Source: https://github.com/awesome-technologies/synapse-admin Creates a new user. The user ID is constructed from the data.id and home_server. ```APIDOC ## [PUT] /_synapse/admin/v2/users/@: ### Description Creates a new user. The user ID is constructed from the data.id and home_server. ### Method PUT ### Endpoint /_synapse/admin/v2/users/@: ### Parameters #### Path Parameters - **data.id** (string) - Required - The local part of the user ID. - **home_server** (string) - Required - The home server domain. #### Request Body - **data** (object) - Required - User data: id, displayname, password, user_type, admin, threepids, external_ids. ### Response #### Success Response (200) - **user** (object) - The created user object. ``` -------------------------------- ### Bootstrap context provider wrapping App Source: https://github.com/awesome-technologies/synapse-admin Wraps the App component in the AppContext.Provider with the loaded config as value. ```tsx ``` -------------------------------- ### Mount the app in src/index.tsx Source: https://github.com/awesome-technologies/synapse-admin Entry point that mounts the React app. Throws Error("Root element #root not found") when the #root element is missing from index.html. ```tsx const rootElement = document.getElementById("root"); if (!rootElement) { throw new Error("Root element #root not found"); } createRoot(rootElement).render( ); ``` -------------------------------- ### GET /_synapse/admin/v1/rooms//members Source: https://github.com/awesome-technologies/synapse-admin Retrieves the members of a room. ```APIDOC ## GET /_synapse/admin/v1/rooms//members ### Description Retrieves the members of a room. ### Method GET ### Endpoint /_synapse/admin/v1/rooms//members ### Parameters #### Path Parameters - **id** (string) - Required - The room ID. ### Response #### Success Response (200) - **members** (array) - List of member user IDs. ``` -------------------------------- ### GET /_synapse/admin/v1/users//pushers Source: https://github.com/awesome-technologies/synapse-admin Retrieves the pushers for a user. ```APIDOC ## GET /_synapse/admin/v1/users//pushers ### Description Retrieves the pushers for a user. ### Method GET ### Endpoint /_synapse/admin/v1/users//pushers ### Parameters #### Path Parameters - **id** (string) - Required - The user ID. ### Response #### Success Response (200) - **pushers** (array) - List of pushers. ``` -------------------------------- ### login Source: https://github.com/awesome-technologies/synapse-admin Authenticates a user against the Matrix homeserver using either password or SSO token. Stores authentication data on success and handles device revocation retry logic. ```APIDOC ## login ### Description Authenticates a user against the Matrix homeserver using either password or SSO token. Stores authentication data on success and handles device revocation retry logic. ### Method POST ### Endpoint `/{normalizedBaseUrl}/_matrix/client/r0/login` ### Parameters #### Request Body - `device_id` (string) - always included - `initial_device_display_name` (string) - always included, value: "Synapse Admin" - `type` (string) - "m.login.token" if loginToken is present, otherwise "m.login.password" - `token` (string) - required if type is "m.login.token" - `user` (string) - required if type is "m.login.password" - `password` (string) - required if type is "m.login.password" - `identifier` (object) - required if type is "m.login.password", contains `type: "m.id.user"` and `user` ### Response #### Success Response (200) - `home_server` (string) - stored on success - `user_id` (string) - stored on success - `access_token` (string) - stored on success - `device_id` (string) - stored on success ### Request Example ```ts // Password login (as called by react-admin's useLogin) await authProvider.login({ base_url: "https://matrix.example.org", username: "admin", password: "s3cret" }); // SSO callback login (as performed by LoginPage after the redirect) await authProvider.login({ base_url: savedBaseUrl, username: null, password: null, loginToken: ssoToken }); ``` ### Error Handling ```ts try { await authProvider.login(auth); } catch (error) { notify( typeof error === "string" ? error : error?.message || "ra.auth.sign_in_error", { type: "warning" } ); } ``` ``` -------------------------------- ### docker-compose.yml for synapse-admin Source: https://github.com/awesome-technologies/synapse-admin/blob/master/README.md Docker Compose configuration to build and run synapse-admin from the GitHub repository. The commented NODE_OPTIONS and BASE_PATH arguments are optional; uncomment and adjust as needed. ```yaml services: synapse-admin: container_name: synapse-admin hostname: synapse-admin build: context: https://github.com/Awesome-Technologies/synapse-admin.git args: - BUILDKIT_CONTEXT_KEEP_GIT_DIR=1 # - NODE_OPTIONS="--max_old_space_size=1024" # - BASE_PATH="/synapse-admin" ports: - "8080:80" restart: unless-stopped ``` -------------------------------- ### getWellKnownUrl Source: https://github.com/awesome-technologies/synapse-admin Fetches the well-known Matrix client configuration for a domain and returns the homeserver base URL. Falls back to the domain itself if the record is missing or the request fails. ```APIDOC ## getWellKnownUrl ### Description Fetches the well-known Matrix client configuration for a domain and returns the homeserver base URL. Falls back to the domain itself if the record is missing or the request fails. ### Method GET ### Endpoint `https://{domain}/.well-known/matrix/client` ### Parameters #### Path Parameters - **domain** (string) - Required - Domain part of an MXID ### Response #### Success Response (200) - **m.homeserver.base_url** (string) - The homeserver base URL from the parsed `MatrixClientWellKnown` payload ### Request Example ```ts const baseUrl = await getWellKnownUrl("example.org"); // e.g. "https://matrix.example.org" ``` ``` -------------------------------- ### requireStoredHomeServer throws if home_server missing Source: https://github.com/awesome-technologies/synapse-admin Returns the stored server name or throws Error("Homeserver not set") when home_server is absent. ```ts export const requireStoredHomeServer = (): string => { const homeServer = storage.getItem("home_server"); if (!homeServer) { throw new Error("Homeserver not set"); } return homeServer; }; ``` -------------------------------- ### POST /_synapse/admin/v1/send_server_notice Source: https://github.com/awesome-technologies/synapse-admin Sends a server notice to a user. The request body includes the user ID and message content. ```APIDOC ## POST /_synapse/admin/v1/send_server_notice ### Description Sends a server notice to a user. The request body includes the user ID and message content. ### Method POST ### Endpoint /_synapse/admin/v1/send_server_notice ### Parameters #### Request Body - **user_id** (string) - Required - The user ID. - **content** (object) - Required - The message content. - **msgtype** (string) - Required - The message type (e.g., "m.text"). - **body** (string) - Required - The message body. ### Response #### Success Response (200) - **event_id** (string) - The ID of the created event. ``` -------------------------------- ### GET /_synapse/admin/v1/event_reports Source: https://github.com/awesome-technologies/synapse-admin Retrieves a list of event reports. Supports pagination and filtering. ```APIDOC ## [GET] /_synapse/admin/v1/event_reports ### Description Retrieves a list of event reports. Supports pagination and filtering. ### Method GET ### Endpoint /_synapse/admin/v1/event_reports ### Parameters #### Query Parameters - **from** (string) - Optional - Pagination offset. - **limit** (integer) - Optional - Maximum number of reports to return. - **order_by** (string) - Optional - Field to sort by. - **dir** (string) - Optional - Sort direction. - **user_id** (string) - Optional - Filter by user ID. - **search_term** (string) - Optional - Search term. - **name** (string) - Optional - Filter by name. - **destination** (string) - Optional - Filter by destination. - **guests** (boolean) - Optional - Filter by guest status. - **deactivated** (boolean) - Optional - Filter by deactivated status. - **locked** (boolean) - Optional - Filter by locked status. - **valid** (boolean) - Optional - Filter by validity. ### Response #### Success Response (200) - **event_reports** (array) - List of event report objects. - **total** (integer) - Total number of reports. ``` -------------------------------- ### requireStoredBaseUrl throws if base_url missing Source: https://github.com/awesome-technologies/synapse-admin Returns the stored base_url or throws Error("Homeserver not set") when base_url is absent. ```ts export const requireStoredBaseUrl = (): string => { const baseUrl = getStoredBaseUrl(); if (!baseUrl) { throw new Error("Homeserver not set"); } return baseUrl; }; ``` -------------------------------- ### POST /_matrix/client/r0/login Source: https://github.com/awesome-technologies/synapse-admin Authenticate a user and obtain an access token. Supports password and token-based login. ```APIDOC ## [POST] /_matrix/client/r0/login ### Description Authenticate a user and obtain an access token. Supports password and token-based login. ### Method POST ### Endpoint /_matrix/client/r0/login ### Parameters #### Request Body - **device_id** (string) - Optional - The device ID to use. - **initial_device_display_name** (string) - Optional - Display name for the device. - **type** (string) - Required - Login type (e.g., m.login.password, m.login.token). - **user** (string) - Optional - Username for password login. - **password** (string) - Optional - Password for password login. - **identifier** (object) - Optional - User identifier object. - **token** (string) - Optional - Login token for token-based login. ### Response #### Success Response (200) - **home_server** (string) - The homeserver domain. - **user_id** (string) - The authenticated user ID. - **access_token** (string) - The access token. - **device_id** (string) - The device ID. ### Request Example ```json { "device_id": "", "initial_device_display_name": "Synapse Admin", "type": "m.login.password", "user": "", "password": "", "identifier": { "type": "m.id.user", "user": "" } } ``` or, when a `loginToken` is supplied: ```json { "device_id": "", "initial_device_display_name": "Synapse Admin", "type": "m.login.token", "token": "" } ``` ``` -------------------------------- ### GET /_synapse/admin/v2/users/ Source: https://github.com/awesome-technologies/synapse-admin Retrieves a single user by ID from the Synapse admin API. The ID is URL-encoded. ```APIDOC ## [GET] /_synapse/admin/v2/users/ ### Description Retrieves a single user by ID from the Synapse admin API. The ID is URL-encoded. ### Method GET ### Endpoint /_synapse/admin/v2/users/ ### Parameters #### Path Parameters - **id** (string) - Required - The user ID, URL-encoded. ### Response #### Success Response (200) - **user** (object) - The user object with fields: `avatar_url` mapped to `avatar_src`, `is_guest`/`admin`/`deactivated` as booleans, `creation_ts_ms` = `creation_ts * 1000`. ``` -------------------------------- ### POST /_synapse/admin/v1/media//delete Source: https://github.com/awesome-technologies/synapse-admin Bulk delete media files on the server. Accepts query parameters to filter which media to delete. ```APIDOC ## [POST] /_synapse/admin/v1/media//delete ### Description Bulk delete media files on the server. Accepts query parameters to filter which media to delete. ### Method POST ### Endpoint /_synapse/admin/v1/media//delete ### Parameters #### Query Parameters - **before_ts** (string) - Optional - Timestamp to delete media before. - **size_gt** (string) - Optional - Delete media larger than this size. - **keep_profiles** (string) - Optional - Whether to keep media associated with user profiles. ### Response #### Success Response (200) - **deleted_media** (array of strings) - List of deleted media IDs. - **total** (number) - Total number of deleted media items. ``` -------------------------------- ### GET /_synapse/admin/v2/users//devices Source: https://github.com/awesome-technologies/synapse-admin Retrieves the list of devices for a given user. This endpoint supports getManyReference with query parameters. ```APIDOC ## GET /_synapse/admin/v2/users//devices ### Description Retrieves the list of devices for a given user. This endpoint supports getManyReference with query parameters. ### Method GET ### Endpoint /_synapse/admin/v2/users//devices ### Parameters #### Path Parameters - **id** (string) - Required - The user ID. #### Query Parameters - **from** (string) - Optional - Pagination token. - **limit** (integer) - Optional - Maximum number of items to return. - **order_by** (string) - Optional - Field to order by. - **dir** (string) - Optional - Direction of ordering (asc/desc). ### Response #### Success Response (200) - **devices** (array) - List of devices. ``` -------------------------------- ### Bootstrap config URL construction Source: https://github.com/awesome-technologies/synapse-admin Constructs the URL for config.json relative to the Vite base path. Uses import.meta.env.BASE_URL and removes trailing slash. ```tsx const baseUrl = import.meta.env.BASE_URL; const configJSON = "config.json"; const configJSONUrl = baseUrl ? `${baseUrl.replace(/\/$/, "")}/${configJSON}` : configJSON; ``` -------------------------------- ### Restrict to a list of homeservers in config.json Source: https://github.com/awesome-technologies/synapse-admin/blob/master/README.md Restrict the homeserver to a list of allowed URLs by setting restrictBaseUrl as an array in config.json. ```json { "restrictBaseUrl": ["https://your-first-matrix-server.example.com", "https://your-second-matrix-server.example.com"] } ``` -------------------------------- ### Bootstrap component declaration Source: https://github.com/awesome-technologies/synapse-admin Declares the Bootstrap component that fetches config.json and manages loading/error states. ```tsx export const Bootstrap = () => { ```