|
| 1 | +// SPDX-FileCopyrightText: 2025 Gnuxie <[email protected]> |
| 2 | +// |
| 3 | +// SPDX-License-Identifier: Apache-2.0 |
| 4 | + |
| 5 | +import { Type } from '@sinclair/typebox'; |
| 6 | +import { |
| 7 | + EDStatic, |
| 8 | + StringRoomAliasSchema, |
| 9 | + StringRoomIDSchema, |
| 10 | + StringUserIDSchema, |
| 11 | +} from 'matrix-protection-suite'; |
| 12 | + |
| 13 | +export type RoomDetailsResponse = EDStatic<typeof RoomDetailsResponse>; |
| 14 | +export const RoomDetailsResponse = Type.Object({ |
| 15 | + room_id: Type.Union( |
| 16 | + [StringRoomIDSchema], |
| 17 | + Type.String({ description: 'The ID of the room.' }) |
| 18 | + ), |
| 19 | + name: Type.Optional( |
| 20 | + Type.Union([Type.String(), Type.Null()], { |
| 21 | + description: 'The name of the room.', |
| 22 | + }) |
| 23 | + ), |
| 24 | + topic: Type.Optional( |
| 25 | + Type.Union([Type.String(), Type.Null()], { |
| 26 | + description: 'The topic of the room.', |
| 27 | + }) |
| 28 | + ), |
| 29 | + avatar: Type.Optional( |
| 30 | + Type.Union([Type.String(), Type.Null()], { |
| 31 | + description: 'The mxc URI to the avatar of the room.', |
| 32 | + }) |
| 33 | + ), |
| 34 | + canonical_alias: Type.Optional( |
| 35 | + Type.Union([StringRoomAliasSchema, Type.String(), Type.Null()], { |
| 36 | + description: 'The canonical (main) alias address of the room.', |
| 37 | + }) |
| 38 | + ), |
| 39 | + joined_members: Type.Number({ |
| 40 | + description: 'How many users are currently in the room.', |
| 41 | + }), |
| 42 | + joined_local_members: Type.Number({ |
| 43 | + description: 'How many local users are currently in the room.', |
| 44 | + }), |
| 45 | + joined_local_devices: Type.Number({ |
| 46 | + description: 'How many local devices are currently in the room.', |
| 47 | + }), |
| 48 | + version: Type.String({ description: 'The version of the room as a string.' }), |
| 49 | + creator: Type.Union([StringUserIDSchema], { |
| 50 | + description: 'The user_id of the room creator.', |
| 51 | + }), |
| 52 | + encryption: Type.Union([Type.String(), Type.Null()], { |
| 53 | + description: |
| 54 | + 'Algorithm of end-to-end encryption of messages. Null if encryption is not active.', |
| 55 | + }), |
| 56 | + federatable: Type.Boolean({ |
| 57 | + description: 'Whether users on other servers can join this room.', |
| 58 | + }), |
| 59 | + public: Type.Boolean({ |
| 60 | + description: 'Whether the room is visible in the room directory.', |
| 61 | + }), |
| 62 | + join_rules: Type.Union( |
| 63 | + [ |
| 64 | + Type.Literal('public'), |
| 65 | + Type.Literal('knock'), |
| 66 | + Type.Literal('invite'), |
| 67 | + Type.Literal('private'), |
| 68 | + ], |
| 69 | + { |
| 70 | + description: |
| 71 | + 'The type of rules used for users wishing to join this room.', |
| 72 | + } |
| 73 | + ), |
| 74 | + guest_access: Type.Union( |
| 75 | + [Type.Literal('can_join'), Type.Literal('forbidden'), Type.Null()], |
| 76 | + { description: 'Whether guests can join the room.' } |
| 77 | + ), |
| 78 | + history_visibility: Type.Union( |
| 79 | + [ |
| 80 | + Type.Literal('invited'), |
| 81 | + Type.Literal('joined'), |
| 82 | + Type.Literal('shared'), |
| 83 | + Type.Literal('world_readable'), |
| 84 | + ], |
| 85 | + { description: 'Who can see the room history.' } |
| 86 | + ), |
| 87 | + state_events: Type.Number({ |
| 88 | + description: |
| 89 | + 'Total number of state events in the room. Represents the complexity of the room.', |
| 90 | + }), |
| 91 | + room_type: Type.Union([Type.String(), Type.Null()], { |
| 92 | + description: |
| 93 | + "The type of the room from the room's creation event, e.g., 'm.space'. Null if not defined.", |
| 94 | + }), |
| 95 | + forgotten: Type.Boolean({ |
| 96 | + description: 'Whether all local users have forgotten the room.', |
| 97 | + }), |
| 98 | +}); |
0 commit comments