matrix-react-sdk
Version:
SDK for matrix.org using React
63 lines (62 loc) • 2.78 kB
TypeScript
import { MatrixClient, Room, RoomType, ICreateRoomOpts, HistoryVisibility, JoinRule, Preset } from "matrix-js-sdk/src/matrix";
export interface IOpts {
dmUserId?: string;
createOpts?: ICreateRoomOpts;
spinner?: boolean;
guestAccess?: boolean;
encryption?: boolean;
inlineErrors?: boolean;
andView?: boolean;
avatar?: File | string;
roomType?: RoomType | string;
historyVisibility?: HistoryVisibility;
parentSpace?: Room;
suggested?: boolean;
joinRule?: JoinRule;
}
/**
* Create a new room, and switch to it.
*
* @param client The Matrix Client instance to create the room with
* @param {object=} opts parameters for creating the room
* @param {string=} opts.dmUserId If specified, make this a DM room for this user and invite them
* @param {object=} opts.createOpts set of options to pass to createRoom call.
* @param {bool=} opts.spinner True to show a modal spinner while the room is created.
* Default: True
* @param {bool=} opts.guestAccess Whether to enable guest access.
* Default: True
* @param {bool=} opts.encryption Whether to enable encryption.
* Default: False
* @param {bool=} opts.inlineErrors True to raise errors off the promise instead of resolving to null.
* Default: False
* @param {bool=} opts.andView True to dispatch an action to view the room once it has been created.
*
* @returns {Promise} which resolves to the room id, or null if the
* action was aborted or failed.
*/
export default function createRoom(client: MatrixClient, opts: IOpts): Promise<string | null>;
export declare function canEncryptToAllUsers(client: MatrixClient, userIds: string[]): Promise<boolean>;
export declare function ensureVirtualRoomExists(client: MatrixClient, userId: string, nativeRoomId: string): Promise<string | null>;
export declare function ensureDMExists(client: MatrixClient, userId: string): Promise<string | null>;
interface AllowedEncryptionSetting {
/**
* True when the user is allowed to choose whether encryption is enabled
*/
allowChange: boolean;
/**
* Set when user is not allowed to choose encryption setting
* True when encryption is forced to enabled
*/
forcedValue?: boolean;
}
/**
* Check if server configuration supports the user changing encryption for a room
* First check if server features force enable encryption for the given room type
* If not, check if server .well-known forces encryption to disabled
* If either are forced, then do not allow the user to change room's encryption
* @param client
* @param chatPreset chat type
* @returns Promise<boolean>
*/
export declare function checkUserIsAllowedToChangeEncryption(client: MatrixClient, chatPreset: Preset): Promise<AllowedEncryptionSetting>;
export {};