Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions spec/unit/matrix-client.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1528,8 +1528,6 @@ describe("MatrixClient", function () {
{ startOpts: {}, hasThreadSupport: false },
{ startOpts: { threadSupport: true }, hasThreadSupport: true },
{ startOpts: { threadSupport: false }, hasThreadSupport: false },
{ startOpts: { experimentalThreadSupport: true }, hasThreadSupport: true },
{ startOpts: { experimentalThreadSupport: true, threadSupport: false }, hasThreadSupport: false },
])("enabled thread support for the SDK instance", async ({ startOpts, hasThreadSupport }) => {
await client.startClient(startOpts);
expect(client.supportsThreads()).toBe(hasThreadSupport);
Expand Down
48 changes: 1 addition & 47 deletions spec/unit/models/event.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -469,52 +469,6 @@ describe("MatrixEvent", () => {
default: false,
enabled: true,
} as IAnnotatedPushRule;
describe("setPushActions()", () => {
it("sets actions on event", () => {
const actions = { notify: false, tweaks: {} };
const event = new MatrixEvent({
type: "com.example.test",
content: {
isTest: true,
},
});
event.setPushActions(actions);

expect(event.getPushActions()).toBe(actions);
});

it("sets actions to undefined", () => {
const event = new MatrixEvent({
type: "com.example.test",
content: {
isTest: true,
},
});
event.setPushActions(null);

// undefined is set on state
expect(event.getPushDetails().actions).toBe(undefined);
// but pushActions getter returns null when falsy
expect(event.getPushActions()).toBe(null);
});

it("clears existing push rule", () => {
const prevActions = { notify: true, tweaks: { highlight: true } };
const actions = { notify: false, tweaks: {} };
const event = new MatrixEvent({
type: "com.example.test",
content: {
isTest: true,
},
});
event.setPushDetails(prevActions, pushRule);

event.setPushActions(actions);

// rule is not in event push cache
expect(event.getPushDetails()).toEqual({ actions });
});
});

describe("setPushDetails()", () => {
it("sets actions and rule on event", () => {
Expand Down Expand Up @@ -543,7 +497,7 @@ describe("MatrixEvent", () => {
});
event.setPushDetails(prevActions, pushRule);

event.setPushActions(actions);
event.setPushDetails(actions);

// rule is not in event push cache
expect(event.getPushDetails()).toEqual({ actions });
Expand Down
7 changes: 0 additions & 7 deletions src/@types/partials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import { ImageInfo } from "./media";

/**
* @deprecated use {@link ImageInfo} instead.
*/
export type IImageInfo = ImageInfo;

export enum Visibility {
Public = "public",
Private = "private",
Expand Down
4 changes: 2 additions & 2 deletions src/@types/uia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import { IAuthDict, IAuthData } from "../interactive-auth";
import { AuthDict, IAuthData } from "../interactive-auth";

/**
* Helper type to represent HTTP request body for a UIA enabled endpoint
*/
export type UIARequest<T> = T & {
auth?: IAuthDict;
auth?: AuthDict;
};

/**
Expand Down
75 changes: 13 additions & 62 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,7 @@ import {
UNSTABLE_MSC3088_PURPOSE,
UNSTABLE_MSC3089_TREE_SUBTYPE,
} from "./@types/event";
import {
GuestAccess,
HistoryVisibility,
IdServerUnbindResult,
IImageInfo,
JoinRule,
Preset,
Visibility,
} from "./@types/partials";
import { GuestAccess, HistoryVisibility, IdServerUnbindResult, JoinRule, Preset, Visibility } from "./@types/partials";
import { EventMapper, eventMapperFor, MapperOpts } from "./event-mapper";
import { randomString } from "./randomstring";
import { BackupManager, IKeyBackup, IKeyBackupCheck, IPreparedKeyBackupVersion, TrustInfo } from "./crypto/backup";
Expand Down Expand Up @@ -232,6 +224,7 @@ import { RegisterRequest, RegisterResponse } from "./@types/registration";
import { MatrixRTCSessionManager } from "./matrixrtc/MatrixRTCSessionManager";
import { getRelationsThreadFilter } from "./thread-utils";
import { KnownMembership, Membership } from "./@types/membership";
import { ImageInfo } from "./@types/media";

export type Store = IStore;

Expand Down Expand Up @@ -508,11 +501,6 @@ export interface IStartClientOpts {
*/
clientWellKnownPollPeriod?: number;

/**
* @deprecated use `threadSupport` instead
*/
experimentalThreadSupport?: boolean;

/**
* Will organises events in threaded conversations when
* a thread relation is encountered
Expand Down Expand Up @@ -1535,19 +1523,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
this.syncApi = new SyncApi(this, this.clientOpts, this.buildSyncApiOptions());
}

if (this.clientOpts.hasOwnProperty("experimentalThreadSupport")) {
this.logger.warn("`experimentalThreadSupport` has been deprecated, use `threadSupport` instead");
}

// If `threadSupport` is omitted and the deprecated `experimentalThreadSupport` has been passed
// We should fallback to that value for backwards compatibility purposes
if (
!this.clientOpts.hasOwnProperty("threadSupport") &&
this.clientOpts.hasOwnProperty("experimentalThreadSupport")
) {
this.clientOpts.threadSupport = this.clientOpts.experimentalThreadSupport;
}

this.syncApi.sync().catch((e) => this.logger.info("Sync startup aborted with an error:", e));

if (this.clientOpts.clientWellKnownPollPeriod !== undefined) {
Expand Down Expand Up @@ -4509,18 +4484,13 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
* @param roomId - the room to update power levels in
* @param userId - the ID of the user or users to update power levels of
* @param powerLevel - the numeric power level to update given users to
* @param event - deprecated and no longer used.
* @returns Promise which resolves: to an ISendEventResponse object
* @returns Rejects: with an error response.
*/
public async setPowerLevel(
roomId: string,
userId: string | string[],
powerLevel: number | undefined,
/**
* @deprecated no longer needed, unused.
*/
event?: MatrixEvent | null,
): Promise<ISendEventResponse> {
let content: IPowerLevelsContent | undefined;
if (this.clientRunning && this.isInitialSyncComplete()) {
Expand Down Expand Up @@ -5086,24 +5056,24 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
* @returns Promise which resolves: to a ISendEventResponse object
* @returns Rejects: with an error response.
*/
public sendImageMessage(roomId: string, url: string, info?: IImageInfo, text?: string): Promise<ISendEventResponse>;
public sendImageMessage(roomId: string, url: string, info?: ImageInfo, text?: string): Promise<ISendEventResponse>;
public sendImageMessage(
roomId: string,
threadId: string | null,
url: string,
info?: IImageInfo,
info?: ImageInfo,
text?: string,
): Promise<ISendEventResponse>;
public sendImageMessage(
roomId: string,
threadId: string | null,
url?: string | IImageInfo,
info?: IImageInfo | string,
url?: string | ImageInfo,
info?: ImageInfo | string,
text = "Image",
): Promise<ISendEventResponse> {
if (!threadId?.startsWith(EVENT_ID_PREFIX) && threadId !== null) {
text = (info as string) || "Image";
info = url as IImageInfo;
info = url as ImageInfo;
url = threadId as string;
threadId = null;
}
Expand All @@ -5123,26 +5093,26 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
public sendStickerMessage(
roomId: string,
url: string,
info?: IImageInfo,
info?: ImageInfo,
text?: string,
): Promise<ISendEventResponse>;
public sendStickerMessage(
roomId: string,
threadId: string | null,
url: string,
info?: IImageInfo,
info?: ImageInfo,
text?: string,
): Promise<ISendEventResponse>;
public sendStickerMessage(
roomId: string,
threadId: string | null,
url?: string | IImageInfo,
info?: IImageInfo | string,
url?: string | ImageInfo,
info?: ImageInfo | string,
text = "Sticker",
): Promise<ISendEventResponse> {
if (!threadId?.startsWith(EVENT_ID_PREFIX) && threadId !== null) {
text = (info as string) || "Sticker";
info = url as IImageInfo;
info = url as ImageInfo;
url = threadId as string;
threadId = null;
}
Expand Down Expand Up @@ -8529,17 +8499,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
return this.http.authedRequest(Method.Get, path);
}

/**
* @returns Promise which resolves: Object with room_id and servers.
* @returns Rejects: with an error response.
* @deprecated use `getRoomIdForAlias` instead
*/
// eslint-disable-next-line camelcase
public resolveRoomAlias(roomAlias: string): Promise<{ room_id: string; servers: string[] }> {
const path = utils.encodeUri("/directory/room/$alias", { $alias: roomAlias });
return this.http.request(Method.Get, path);
}

/**
* Get the visibility of a room in the current HS's room directory
* @returns Promise which resolves: TODO
Expand All @@ -8553,7 +8512,7 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
}

/**
* Set the visbility of a room in the current HS's room directory
* Set the visibility of a room in the current HS's room directory
* @param visibility - "public" to make the room visible
* in the public directory, or "private" to make
* it invisible.
Expand Down Expand Up @@ -9800,14 +9759,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
});
}

/**
* @deprecated use supportsThreads() instead
*/
public supportsExperimentalThreads(): boolean {
this.logger.warn(`supportsExperimentalThreads() is deprecated, use supportThreads() instead`);
return this.clientOpts?.experimentalThreadSupport || false;
}

/**
* A helper to determine thread support
* @returns a boolean to determine if threads are enabled
Expand Down
16 changes: 5 additions & 11 deletions src/interactive-auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,6 @@ export type AuthDict =
| { type: Exclude<string, AuthType>; [key: string]: any }
| {};

/**
* Backwards compatible export
* @deprecated in favour of AuthDict
*/
export type IAuthDict = AuthDict;

export class NoAuthFlowFoundError extends Error {
public name = "NoAuthFlowFoundError";

Expand All @@ -168,7 +162,7 @@ export class NoAuthFlowFoundError extends Error {
*
* The generic parameter `T` is the type of the response of the endpoint, once it is eventually successful.
*/
export type UIAuthCallback<T> = (makeRequest: (authData: IAuthDict | null) => Promise<UIAResponse<T>>) => Promise<T>;
export type UIAuthCallback<T> = (makeRequest: (authData: AuthDict | null) => Promise<UIAResponse<T>>) => Promise<T>;

interface IOpts<T> {
/**
Expand Down Expand Up @@ -340,7 +334,7 @@ export class InteractiveAuth<T> {
// another just to check what the status is
if (this.submitPromise) return;

let authDict: IAuthDict = {};
let authDict: AuthDict = {};
if (this.currentStage == EMAIL_STAGE_TYPE) {
// The email can be validated out-of-band, but we need to provide the
// creds so the HS can go & check it.
Expand Down Expand Up @@ -410,7 +404,7 @@ export class InteractiveAuth<T> {
* in the attemptAuth promise being rejected. This can be set to true
* for requests that just poll to see if auth has been completed elsewhere.
*/
public async submitAuthDict(authData: IAuthDict, background = false): Promise<void> {
public async submitAuthDict(authData: AuthDict, background = false): Promise<void> {
if (!this.attemptAuthDeferred) {
throw new Error("submitAuthDict() called before attemptAuth()");
}
Expand All @@ -431,7 +425,7 @@ export class InteractiveAuth<T> {
}

// use the sessionid from the last request, if one is present.
let auth: IAuthDict;
let auth: AuthDict;
if ((this.data as IAuthData)?.session) {
auth = {
session: (this.data as IAuthData).session,
Expand Down Expand Up @@ -515,7 +509,7 @@ export class InteractiveAuth<T> {
* This can be set to true for requests that just poll to see if auth has
* been completed elsewhere.
*/
private async doRequest(auth: IAuthDict | null, background = false): Promise<void> {
private async doRequest(auth: AuthDict | null, background = false): Promise<void> {
try {
const result = await this.requestCallback(auth, background);
this.attemptAuthDeferred!.resolve(result);
Expand Down
Loading