1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-07-31 15:24:23 +03:00

Remove various deprecated methods & re-exports (#4125)

This commit is contained in:
Michael Telatynski
2024-03-25 12:21:11 +00:00
committed by GitHub
parent 63d4195453
commit 85a55c79cd
11 changed files with 26 additions and 173 deletions

View File

@ -1528,8 +1528,6 @@ describe("MatrixClient", function () {
{ startOpts: {}, hasThreadSupport: false }, { startOpts: {}, hasThreadSupport: false },
{ startOpts: { threadSupport: true }, hasThreadSupport: true }, { startOpts: { threadSupport: true }, hasThreadSupport: true },
{ startOpts: { threadSupport: false }, hasThreadSupport: false }, { 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 }) => { ])("enabled thread support for the SDK instance", async ({ startOpts, hasThreadSupport }) => {
await client.startClient(startOpts); await client.startClient(startOpts);
expect(client.supportsThreads()).toBe(hasThreadSupport); expect(client.supportsThreads()).toBe(hasThreadSupport);

View File

@ -503,52 +503,6 @@ describe("MatrixEvent", () => {
default: false, default: false,
enabled: true, enabled: true,
} as IAnnotatedPushRule; } 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()", () => { describe("setPushDetails()", () => {
it("sets actions and rule on event", () => { it("sets actions and rule on event", () => {
@ -577,7 +531,7 @@ describe("MatrixEvent", () => {
}); });
event.setPushDetails(prevActions, pushRule); event.setPushDetails(prevActions, pushRule);
event.setPushActions(actions); event.setPushDetails(actions);
// rule is not in event push cache // rule is not in event push cache
expect(event.getPushDetails()).toEqual({ actions }); expect(event.getPushDetails()).toEqual({ actions });

View File

@ -14,13 +14,6 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import { ImageInfo } from "./media";
/**
* @deprecated use {@link ImageInfo} instead.
*/
export type IImageInfo = ImageInfo;
export enum Visibility { export enum Visibility {
Public = "public", Public = "public",
Private = "private", Private = "private",

View File

@ -14,13 +14,13 @@ See the License for the specific language governing permissions and
limitations under the License. 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 * Helper type to represent HTTP request body for a UIA enabled endpoint
*/ */
export type UIARequest<T> = T & { export type UIARequest<T> = T & {
auth?: IAuthDict; auth?: AuthDict;
}; };
/** /**

View File

@ -149,15 +149,7 @@ import {
UNSTABLE_MSC3088_PURPOSE, UNSTABLE_MSC3088_PURPOSE,
UNSTABLE_MSC3089_TREE_SUBTYPE, UNSTABLE_MSC3089_TREE_SUBTYPE,
} from "./@types/event"; } from "./@types/event";
import { import { GuestAccess, HistoryVisibility, IdServerUnbindResult, JoinRule, Preset, Visibility } from "./@types/partials";
GuestAccess,
HistoryVisibility,
IdServerUnbindResult,
IImageInfo,
JoinRule,
Preset,
Visibility,
} from "./@types/partials";
import { EventMapper, eventMapperFor, MapperOpts } from "./event-mapper"; import { EventMapper, eventMapperFor, MapperOpts } from "./event-mapper";
import { randomString } from "./randomstring"; import { randomString } from "./randomstring";
import { BackupManager, IKeyBackup, IKeyBackupCheck, IPreparedKeyBackupVersion, TrustInfo } from "./crypto/backup"; import { BackupManager, IKeyBackup, IKeyBackupCheck, IPreparedKeyBackupVersion, TrustInfo } from "./crypto/backup";
@ -231,6 +223,7 @@ import { RegisterRequest, RegisterResponse } from "./@types/registration";
import { MatrixRTCSessionManager } from "./matrixrtc/MatrixRTCSessionManager"; import { MatrixRTCSessionManager } from "./matrixrtc/MatrixRTCSessionManager";
import { getRelationsThreadFilter } from "./thread-utils"; import { getRelationsThreadFilter } from "./thread-utils";
import { KnownMembership, Membership } from "./@types/membership"; import { KnownMembership, Membership } from "./@types/membership";
import { ImageInfo } from "./@types/media";
export type Store = IStore; export type Store = IStore;
@ -509,11 +502,6 @@ export interface IStartClientOpts {
*/ */
clientWellKnownPollPeriod?: number; clientWellKnownPollPeriod?: number;
/**
* @deprecated use `threadSupport` instead
*/
experimentalThreadSupport?: boolean;
/** /**
* Will organises events in threaded conversations when * Will organises events in threaded conversations when
* a thread relation is encountered * a thread relation is encountered
@ -1536,19 +1524,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
this.syncApi = new SyncApi(this, this.clientOpts, this.buildSyncApiOptions()); 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)); this.syncApi.sync().catch((e) => this.logger.info("Sync startup aborted with an error:", e));
if (this.clientOpts.clientWellKnownPollPeriod !== undefined) { if (this.clientOpts.clientWellKnownPollPeriod !== undefined) {
@ -4506,7 +4481,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
* @param roomId - the room to update power levels in * @param roomId - the room to update power levels in
* @param userId - the ID of the user or users to update power levels of * @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 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 Promise which resolves: to an ISendEventResponse object
* @returns Rejects: with an error response. * @returns Rejects: with an error response.
*/ */
@ -4514,10 +4488,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
roomId: string, roomId: string,
userId: string | string[], userId: string | string[],
powerLevel: number | undefined, powerLevel: number | undefined,
/**
* @deprecated no longer needed, unused.
*/
event?: MatrixEvent | null,
): Promise<ISendEventResponse> { ): Promise<ISendEventResponse> {
let content: IPowerLevelsContent | undefined; let content: IPowerLevelsContent | undefined;
if (this.clientRunning && this.isInitialSyncComplete()) { if (this.clientRunning && this.isInitialSyncComplete()) {
@ -5083,24 +5053,24 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
* @returns Promise which resolves: to a ISendEventResponse object * @returns Promise which resolves: to a ISendEventResponse object
* @returns Rejects: with an error response. * @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( public sendImageMessage(
roomId: string, roomId: string,
threadId: string | null, threadId: string | null,
url: string, url: string,
info?: IImageInfo, info?: ImageInfo,
text?: string, text?: string,
): Promise<ISendEventResponse>; ): Promise<ISendEventResponse>;
public sendImageMessage( public sendImageMessage(
roomId: string, roomId: string,
threadId: string | null, threadId: string | null,
url?: string | IImageInfo, url?: string | ImageInfo,
info?: IImageInfo | string, info?: ImageInfo | string,
text = "Image", text = "Image",
): Promise<ISendEventResponse> { ): Promise<ISendEventResponse> {
if (!threadId?.startsWith(EVENT_ID_PREFIX) && threadId !== null) { if (!threadId?.startsWith(EVENT_ID_PREFIX) && threadId !== null) {
text = (info as string) || "Image"; text = (info as string) || "Image";
info = url as IImageInfo; info = url as ImageInfo;
url = threadId as string; url = threadId as string;
threadId = null; threadId = null;
} }
@ -5120,26 +5090,26 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
public sendStickerMessage( public sendStickerMessage(
roomId: string, roomId: string,
url: string, url: string,
info?: IImageInfo, info?: ImageInfo,
text?: string, text?: string,
): Promise<ISendEventResponse>; ): Promise<ISendEventResponse>;
public sendStickerMessage( public sendStickerMessage(
roomId: string, roomId: string,
threadId: string | null, threadId: string | null,
url: string, url: string,
info?: IImageInfo, info?: ImageInfo,
text?: string, text?: string,
): Promise<ISendEventResponse>; ): Promise<ISendEventResponse>;
public sendStickerMessage( public sendStickerMessage(
roomId: string, roomId: string,
threadId: string | null, threadId: string | null,
url?: string | IImageInfo, url?: string | ImageInfo,
info?: IImageInfo | string, info?: ImageInfo | string,
text = "Sticker", text = "Sticker",
): Promise<ISendEventResponse> { ): Promise<ISendEventResponse> {
if (!threadId?.startsWith(EVENT_ID_PREFIX) && threadId !== null) { if (!threadId?.startsWith(EVENT_ID_PREFIX) && threadId !== null) {
text = (info as string) || "Sticker"; text = (info as string) || "Sticker";
info = url as IImageInfo; info = url as ImageInfo;
url = threadId as string; url = threadId as string;
threadId = null; threadId = null;
} }
@ -8526,17 +8496,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
return this.http.authedRequest(Method.Get, path); 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 * Get the visibility of a room in the current HS's room directory
* @returns Promise which resolves: TODO * @returns Promise which resolves: TODO
@ -8550,7 +8509,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 * @param visibility - "public" to make the room visible
* in the public directory, or "private" to make * in the public directory, or "private" to make
* it invisible. * it invisible.
@ -9797,14 +9756,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 * A helper to determine thread support
* @returns a boolean to determine if threads are enabled * @returns a boolean to determine if threads are enabled

View File

@ -140,12 +140,6 @@ export type AuthDict =
| { type: Exclude<string, AuthType>; [key: string]: any } | { type: Exclude<string, AuthType>; [key: string]: any }
| {}; | {};
/**
* Backwards compatible export
* @deprecated in favour of AuthDict
*/
export type IAuthDict = AuthDict;
export class NoAuthFlowFoundError extends Error { export class NoAuthFlowFoundError extends Error {
public name = "NoAuthFlowFoundError"; public name = "NoAuthFlowFoundError";
@ -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. * 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> { interface IOpts<T> {
/** /**
@ -340,7 +334,7 @@ export class InteractiveAuth<T> {
// another just to check what the status is // another just to check what the status is
if (this.submitPromise) return; if (this.submitPromise) return;
let authDict: IAuthDict = {}; let authDict: AuthDict = {};
if (this.currentStage == EMAIL_STAGE_TYPE) { if (this.currentStage == EMAIL_STAGE_TYPE) {
// The email can be validated out-of-band, but we need to provide the // The email can be validated out-of-band, but we need to provide the
// creds so the HS can go & check it. // creds so the HS can go & check it.
@ -410,7 +404,7 @@ export class InteractiveAuth<T> {
* in the attemptAuth promise being rejected. This can be set to true * 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. * 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) { if (!this.attemptAuthDeferred) {
throw new Error("submitAuthDict() called before attemptAuth()"); throw new Error("submitAuthDict() called before attemptAuth()");
} }
@ -431,7 +425,7 @@ export class InteractiveAuth<T> {
} }
// use the sessionid from the last request, if one is present. // use the sessionid from the last request, if one is present.
let auth: IAuthDict; let auth: AuthDict;
if ((this.data as IAuthData)?.session) { if ((this.data as IAuthData)?.session) {
auth = { auth = {
session: (this.data as IAuthData).session, session: (this.data as IAuthData).session,
@ -515,7 +509,7 @@ export class InteractiveAuth<T> {
* This can be set to true for requests that just poll to see if auth has * This can be set to true for requests that just poll to see if auth has
* been completed elsewhere. * been completed elsewhere.
*/ */
private async doRequest(auth: IAuthDict | null, background = false): Promise<void> { private async doRequest(auth: AuthDict | null, background = false): Promise<void> {
try { try {
const result = await this.requestCallback(auth, background); const result = await this.requestCallback(auth, background);
this.attemptAuthDeferred!.resolve(result); this.attemptAuthDeferred!.resolve(result);

View File

@ -1172,10 +1172,6 @@ export class MatrixEvent extends TypedEventEmitter<MatrixEventEmittedEvents, Mat
return this.visibility; return this.visibility;
} }
/**
* @deprecated In favor of the overload that includes a Room argument
*/
public makeRedacted(redactionEvent: MatrixEvent): void;
/** /**
* Update the content of an event in the same way it would be by the server * Update the content of an event in the same way it would be by the server
* if it were redacted before it was sent to us * if it were redacted before it was sent to us
@ -1183,8 +1179,7 @@ export class MatrixEvent extends TypedEventEmitter<MatrixEventEmittedEvents, Mat
* @param redactionEvent - event causing the redaction * @param redactionEvent - event causing the redaction
* @param room - the room in which the event exists * @param room - the room in which the event exists
*/ */
public makeRedacted(redactionEvent: MatrixEvent, room: Room): void; public makeRedacted(redactionEvent: MatrixEvent, room: Room): void {
public makeRedacted(redactionEvent: MatrixEvent, room?: Room): void {
// quick sanity-check // quick sanity-check
if (!redactionEvent.event) { if (!redactionEvent.event) {
throw new Error("invalid redactionEvent in makeRedacted"); throw new Error("invalid redactionEvent in makeRedacted");
@ -1230,7 +1225,7 @@ export class MatrixEvent extends TypedEventEmitter<MatrixEventEmittedEvents, Mat
// If the redacted event was in a thread (but not thread root), move it // If the redacted event was in a thread (but not thread root), move it
// to the main timeline. This will change if MSC3389 is merged. // to the main timeline. This will change if MSC3389 is merged.
if (room && !this.isThreadRoot && this.threadRootId && this.threadRootId !== this.getId()) { if (!this.isThreadRoot && this.threadRootId && this.threadRootId !== this.getId()) {
this.moveAllRelatedToMainTimeline(room); this.moveAllRelatedToMainTimeline(room);
redactionEvent.moveToMainTimeline(room); redactionEvent.moveToMainTimeline(room);
} }
@ -1367,19 +1362,6 @@ export class MatrixEvent extends TypedEventEmitter<MatrixEventEmittedEvents, Mat
return this.pushDetails; return this.pushDetails;
} }
/**
* Set the push actions for this event.
* Clears rule from push details if present
* @deprecated use `setPushDetails`
*
* @param pushActions - push actions
*/
public setPushActions(pushActions: IActionsObject | null): void {
this.pushDetails = {
actions: pushActions || undefined,
};
}
/** /**
* Set the push details for this event. * Set the push details for this event.
* *
@ -1580,14 +1562,6 @@ export class MatrixEvent extends TypedEventEmitter<MatrixEventEmittedEvents, Mat
} }
} }
/**
* Checks if this event is associated with another event. See `getAssociatedId`.
* @deprecated use hasAssociation instead.
*/
public hasAssocation(): boolean {
return !!this.getAssociatedId();
}
/** /**
* Checks if this event is associated with another event. See `getAssociatedId`. * Checks if this event is associated with another event. See `getAssociatedId`.
*/ */

View File

@ -3078,7 +3078,7 @@ export class Room extends ReadReceipt<RoomEmittedEvents, RoomEventHandlerMap> {
[[], [], []], [[], [], []],
); );
} else { } else {
// When `experimentalThreadSupport` is disabled treat all events as timelineEvents // When `threadSupport` is disabled treat all events as timelineEvents
return [events as MatrixEvent[], [] as MatrixEvent[], [] as MatrixEvent[]]; return [events as MatrixEvent[], [] as MatrixEvent[], [] as MatrixEvent[]];
} }
} }

View File

@ -47,11 +47,6 @@ export type ThreadEventHandlerMap = {
[ThreadEvent.Delete]: (thread: Thread) => void; [ThreadEvent.Delete]: (thread: Thread) => void;
} & EventTimelineSetHandlerMap; } & EventTimelineSetHandlerMap;
/**
* @deprecated please use ThreadEventHandlerMap instead
*/
export type EventHandlerMap = ThreadEventHandlerMap;
interface IThreadOpts { interface IThreadOpts {
room: Room; room: Room;
client: MatrixClient; client: MatrixClient;

View File

@ -20,12 +20,6 @@ import { OidcMetadata, SigninResponse } from "oidc-client-ts";
import { logger } from "../logger"; import { logger } from "../logger";
import { OidcError } from "./error"; import { OidcError } from "./error";
/**
* re-export for backwards compatibility
* @deprecated use OidcError
*/
export { OidcError as OidcDiscoveryError };
export type ValidatedIssuerConfig = { export type ValidatedIssuerConfig = {
authorizationEndpoint: string; authorizationEndpoint: string;
tokenEndpoint: string; tokenEndpoint: string;

View File

@ -29,7 +29,7 @@ import {
import { logger } from "../logger"; import { logger } from "../logger";
import { calculateRetryBackoff, IHttpOpts, MatrixHttpApi, Method } from "../http-api"; import { calculateRetryBackoff, IHttpOpts, MatrixHttpApi, Method } from "../http-api";
import { logDuration, QueryDict, sleep } from "../utils"; import { logDuration, QueryDict, sleep } from "../utils";
import { IAuthDict, UIAuthCallback } from "../interactive-auth"; import { AuthDict, UIAuthCallback } from "../interactive-auth";
import { UIAResponse } from "../@types/uia"; import { UIAResponse } from "../@types/uia";
import { ToDeviceMessageId } from "../@types/event"; import { ToDeviceMessageId } from "../@types/event";
@ -169,7 +169,7 @@ export class OutgoingRequestProcessor {
} }
const parsedBody = JSON.parse(body); const parsedBody = JSON.parse(body);
const makeRequest = async (auth: IAuthDict | null): Promise<UIAResponse<T>> => { const makeRequest = async (auth: AuthDict | null): Promise<UIAResponse<T>> => {
const newBody: Record<string, any> = { const newBody: Record<string, any> = {
...parsedBody, ...parsedBody,
}; };