Merge branch 'develop' of github.com:matrix-org/matrix-js-sdk into t3chguy/fix/17282
This commit is contained in:
@@ -12,6 +12,7 @@ import {
|
||||
} from "../../src/@types/event";
|
||||
import { MEGOLM_ALGORITHM } from "../../src/crypto/olmlib";
|
||||
import { MatrixEvent } from "../../src/models/event";
|
||||
import { Preset } from "../../src/@types/partials";
|
||||
|
||||
jest.useFakeTimers();
|
||||
|
||||
@@ -190,7 +191,7 @@ describe("MatrixClient", function() {
|
||||
const fn = jest.fn().mockImplementation((opts) => {
|
||||
expect(opts).toMatchObject({
|
||||
name: roomName,
|
||||
preset: "private_chat",
|
||||
preset: Preset.PrivateChat,
|
||||
power_level_content_override: {
|
||||
...DEFAULT_TREE_POWER_LEVELS_TEMPLATE,
|
||||
users: {
|
||||
|
||||
@@ -26,3 +26,14 @@ export interface IImageInfo {
|
||||
w?: number;
|
||||
h?: number;
|
||||
}
|
||||
|
||||
export enum Visibility {
|
||||
Public = "public",
|
||||
Private = "private",
|
||||
}
|
||||
|
||||
export enum Preset {
|
||||
PrivateChat = "private_chat",
|
||||
TrustedPrivateChat = "trusted_private_chat",
|
||||
PublicChat = "public_chat",
|
||||
}
|
||||
|
||||
+31
-13
@@ -15,6 +15,10 @@ limitations under the License.
|
||||
*/
|
||||
|
||||
import { Callback } from "../client";
|
||||
import { Preset, Visibility } from "./partials";
|
||||
|
||||
// allow camelcase as these are things go onto the wire
|
||||
/* eslint-disable camelcase */
|
||||
|
||||
export interface IJoinRoomOpts {
|
||||
/**
|
||||
@@ -40,12 +44,12 @@ export interface IRedactOpts {
|
||||
}
|
||||
|
||||
export interface ISendEventResponse {
|
||||
event_id: string; // eslint-disable-line camelcase
|
||||
event_id: string;
|
||||
}
|
||||
|
||||
export interface IPresenceOpts {
|
||||
presence: "online" | "offline" | "unavailable";
|
||||
status_msg?: string; // eslint-disable-line camelcase
|
||||
status_msg?: string;
|
||||
}
|
||||
|
||||
export interface IPaginateOpts {
|
||||
@@ -68,21 +72,33 @@ export interface IEventSearchOpts {
|
||||
term: string;
|
||||
}
|
||||
|
||||
// allow camelcase as these are things go onto the wire
|
||||
/* eslint-disable camelcase */
|
||||
export interface IInvite3PID {
|
||||
id_server: string;
|
||||
id_access_token?: string; // this gets injected by the js-sdk
|
||||
medium: string;
|
||||
address: string;
|
||||
}
|
||||
|
||||
export interface ICreateRoomStateEvent {
|
||||
type: string;
|
||||
state_key?: string; // defaults to an empty string
|
||||
content: object;
|
||||
}
|
||||
|
||||
export interface ICreateRoomOpts {
|
||||
room_alias_name?: string;
|
||||
visibility?: "public" | "private";
|
||||
visibility?: Visibility;
|
||||
name?: string;
|
||||
topic?: string;
|
||||
preset?: string;
|
||||
power_level_content_override?: any;
|
||||
creation_content?: any;
|
||||
initial_state?: {type: string, state_key: string, content: any}[];
|
||||
// TODO: Types (next line)
|
||||
invite_3pid?: any[];
|
||||
preset?: Preset;
|
||||
power_level_content_override?: object;
|
||||
creation_content?: object;
|
||||
initial_state?: ICreateRoomStateEvent[];
|
||||
invite?: string[];
|
||||
invite_3pid?: IInvite3PID[];
|
||||
is_direct?: boolean;
|
||||
room_version?: string;
|
||||
}
|
||||
/* eslint-enable camelcase */
|
||||
|
||||
export interface IRoomDirectoryOptions {
|
||||
server?: string;
|
||||
@@ -90,7 +106,7 @@ export interface IRoomDirectoryOptions {
|
||||
since?: string;
|
||||
|
||||
// TODO: Proper types
|
||||
filter?: any & {generic_search_term: string}; // eslint-disable-line camelcase
|
||||
filter?: any & {generic_search_term: string};
|
||||
}
|
||||
|
||||
export interface IUploadOpts {
|
||||
@@ -102,3 +118,5 @@ export interface IUploadOpts {
|
||||
callback?: Callback;
|
||||
progressHandler?: (state: {loaded: number, total: number}) => void;
|
||||
}
|
||||
|
||||
/* eslint-enable camelcase */
|
||||
|
||||
+11
-5
@@ -107,7 +107,7 @@ import {
|
||||
UNSTABLE_MSC3088_PURPOSE,
|
||||
UNSTABLE_MSC3089_TREE_SUBTYPE,
|
||||
} from "./@types/event";
|
||||
import { IImageInfo } from "./@types/partials";
|
||||
import { IImageInfo, Preset } from "./@types/partials";
|
||||
import { EventMapper, eventMapperFor, MapperOpts } from "./event-mapper";
|
||||
import url from "url";
|
||||
import { randomString } from "./randomstring";
|
||||
@@ -5585,15 +5585,21 @@ export class MatrixClient extends EventEmitter {
|
||||
/**
|
||||
* Query the server to see if it is forcing encryption to be enabled for
|
||||
* a given room preset, based on the /versions response.
|
||||
* @param {string} presetName The name of the preset to check.
|
||||
* @param {Preset} presetName The name of the preset to check.
|
||||
* @returns {Promise<boolean>} true if the server is forcing encryption
|
||||
* for the preset.
|
||||
*/
|
||||
public async doesServerForceEncryptionForPreset(presetName: string): Promise<boolean> {
|
||||
public async doesServerForceEncryptionForPreset(presetName: Preset): Promise<boolean> {
|
||||
const response = await this.getVersions();
|
||||
if (!response) return false;
|
||||
const unstableFeatures = response["unstable_features"];
|
||||
return unstableFeatures && !!unstableFeatures[`io.element.e2ee_forced.${presetName}`];
|
||||
|
||||
// The preset name in the versions response will be without the _chat suffix.
|
||||
const versionsPresetName = presetName.includes("_chat")
|
||||
? presetName.substring(0, presetName.indexOf("_chat"))
|
||||
: presetName;
|
||||
|
||||
return unstableFeatures && !!unstableFeatures[`io.element.e2ee_forced.${versionsPresetName}`];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -7729,7 +7735,7 @@ export class MatrixClient extends EventEmitter {
|
||||
public async unstableCreateFileTree(name: string): Promise<MSC3089TreeSpace> {
|
||||
const { room_id: roomId } = await this.createRoom({
|
||||
name: name,
|
||||
preset: "private_chat",
|
||||
preset: Preset.PrivateChat,
|
||||
power_level_content_override: {
|
||||
...DEFAULT_TREE_POWER_LEVELS_TEMPLATE,
|
||||
users: {
|
||||
|
||||
Reference in New Issue
Block a user