From 3c77a8772aa4c72013a79aae1c5f240bd9344259 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Sun, 11 Jul 2021 20:54:51 -0600 Subject: [PATCH 1/9] Add minimal types for "notification settings" UI For https://github.com/vector-im/element-web/issues/17782 --- src/@types/PushRules.ts | 154 ++++++++++++++++++++++++++++++++++++++++ src/@types/threepids.ts | 28 ++++++++ src/client.ts | 17 +++-- 3 files changed, 192 insertions(+), 7 deletions(-) create mode 100644 src/@types/PushRules.ts create mode 100644 src/@types/threepids.ts diff --git a/src/@types/PushRules.ts b/src/@types/PushRules.ts new file mode 100644 index 00000000000..74b1b16b7c3 --- /dev/null +++ b/src/@types/PushRules.ts @@ -0,0 +1,154 @@ +/* +Copyright 2021 The Matrix.org Foundation C.I.C. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +export enum PushRuleActionName { + DontNotify = "dont_notify", + Notify = "notify", + Coalesce = "coalesce", +} + +export enum TweakName { + Highlight = "highlight", + Sound = "sound", +} + +export type Tweak = { + set_tweak: N; // eslint-disable-line camel-case + value: V; +} + +export type TweakHighlight = Tweak; +export type TweakSound = Tweak; + +export type Tweaks = TweakHighlight | TweakSound; + +export enum ConditionOperator { + ExactEquals = "==", + LessThan = "<", + GreaterThan = ">", + GreaterThanOrEqual = ">=", + LessThanOrEqual = "<=", +} + +export type PushRuleAction = Tweaks | PushRuleActionName; + +export type MemberCountCondition + + = `${Op}${N}` | (Op extends ConditionOperator.ExactEquals ? `${N}` : never); + +export type AnyMemberCountCondition = MemberCountCondition; + +export const DMMemberCountCondition: MemberCountCondition<2> = "2"; + +export function isDmMemberCountCondition(condition: AnyMemberCountCondition): boolean { + return condition === "==2" || condition === "2"; +} + +export enum ConditionKind { + EventMatch = "event_match", + ContainsDisplayName = "contains_display_name", + RoomMemberCount = "room_member_count", + SenderNotificationPermission = "sender_notification_permission", +} + +export enum PushRuleKind { + Override = "override", + ContentSpecific = "content", + RoomSpecific = "room", + SenderSpecific = "sender", + Underride = "underride", +} + +export type PushRuleSet = { + [k in PushRuleKind]?: IPushRule[]; +}; + +export interface IPushRule { + actions: PushRuleAction[]; + conditions?: PushRuleCondition[]; + default: boolean; + enabled: boolean; + pattern?: string; + rule_id: RuleId | string; // eslint-disable-line camel-case +} + +export interface IAnnotatedPushRule extends IPushRule { + kind: PushRuleKind; +} + +export interface IPushRuleCondition { + [k: string]: any; // for custom conditions, there can be other fields here + kind: N; +} + +export interface IEventMatchCondition extends IPushRuleCondition { + key: string; + pattern: string; +} + +export interface IContainsDisplayNameCondition extends IPushRuleCondition { + // no additional fields +} + +export interface IRoomMemberCountCondition extends IPushRuleCondition { + is: AnyMemberCountCondition; +} + +export interface ISenderNotificationPermissionCondition + extends IPushRuleCondition { + key: string; +} + +export type PushRuleCondition = IPushRuleCondition + | IEventMatchCondition + | IContainsDisplayNameCondition + | IRoomMemberCountCondition + | ISenderNotificationPermissionCondition; + +export interface IPushRules { + global: PushRuleSet; + device?: PushRuleSet; +} + +export enum RuleId { + Master = ".m.rule.master", + ContainsDisplayName = ".m.rule.contains_display_name", + ContainsUserName = ".m.rule.contains_user_name", + AtRoomNotification = ".m.rule.roomnotif", + DM = ".m.rule.room_one_to_one", + EncryptedDM = ".m.rule.encrypted_room_one_to_one", + Message = ".m.rule.message", + EncryptedMessage = ".m.rule.encrypted", + InviteToSelf = ".m.rule.invite_for_me", + MemberEvent = ".m.rule.member_event", + IncomingCall = ".m.rule.call", + SuppressNotices = ".m.rule.suppress_notices", + Tombstone = ".m.rule.tombstone", +} + +export interface IPusher { + app_display_name: string; // eslint-disable-line camel-case + app_id: string; // eslint-disable-line camel-case + data: { + format?: string; // TODO: Types + url?: string; // TODO: Required if kind==http + }, + device_display_name: string; // eslint-disable-line camel-case + kind: string; // TODO: Types + lang: string; + profile_tag?: string; // eslint-disable-line camel-case + pushkey: string; +} diff --git a/src/@types/threepids.ts b/src/@types/threepids.ts new file mode 100644 index 00000000000..38791701082 --- /dev/null +++ b/src/@types/threepids.ts @@ -0,0 +1,28 @@ +/* +Copyright 2021 The Matrix.org Foundation C.I.C. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +export enum ThreepidMedium { + Email = "email", + Phone = "msisdn", +} + +// TODO: Are these types universal, or specific to just /account/3pid? +export interface IThirdPartyIdentifier { + added_at: number; // eslint-disable-line camel-case + address: string; + medium: ThreepidMedium; + validated_at: number; // eslint-disable-line camel-case +} diff --git a/src/client.ts b/src/client.ts index e5424224c3d..930e4834751 100644 --- a/src/client.ts +++ b/src/client.ts @@ -117,6 +117,8 @@ import { WebStorageSessionStore } from "./store/session/webstorage"; import { BackupManager, IKeyBackupCheck, IPreparedKeyBackupVersion, TrustInfo } from "./crypto/backup"; import { DEFAULT_TREE_POWER_LEVELS_TEMPLATE, MSC3089TreeSpace } from "./models/MSC3089TreeSpace"; import { ISignatures } from "./@types/signed"; +import { IPusher, IPushRules } from "./@types/PushRules"; +import { IThirdPartyIdentifier } from "./@types/threepids"; export type Store = StubStore | MemoryStore | LocalIndexedDBStoreBackend | RemoteIndexedDBStoreBackend; export type SessionStore = WebStorageSessionStore; @@ -3636,7 +3638,7 @@ export class MatrixClient extends EventEmitter { * @return {Promise} Resolves: TODO * @return {module:http-api.MatrixError} Rejects: with an error response. */ - public async sendReadReceipt(event: MatrixEvent, opts: { hidden?: boolean }, callback?: Callback): Promise { + public async sendReadReceipt(event: MatrixEvent, opts?: { hidden?: boolean }, callback?: Callback): Promise { if (typeof (opts) === 'function') { callback = opts as any as Callback; // legacy opts = {}; @@ -6759,10 +6761,10 @@ export class MatrixClient extends EventEmitter { /** * @param {module:client.callback} callback Optional. - * @return {Promise} Resolves: TODO + * @return {Promise} Resolves to a list of the user's threepids. * @return {module:http-api.MatrixError} Rejects: with an error response. */ - public getThreePids(callback?: Callback): Promise { // TODO: Types + public getThreePids(callback?: Callback): Promise<{ threepids: IThirdPartyIdentifier[] }> { const path = "/account/3pid"; return this.http.authedRequest( callback, "GET", path, undefined, undefined, @@ -6989,7 +6991,7 @@ export class MatrixClient extends EventEmitter { * @return {Promise} Resolves: Array of objects representing pushers * @return {module:http-api.MatrixError} Rejects: with an error response. */ - public getPushers(callback?: Callback): Promise { // TODO: Types + public getPushers(callback?: Callback): Promise<{ pushers: IPusher[] }> { // TODO: Types const path = "/pushers"; return this.http.authedRequest( callback, "GET", path, undefined, undefined, @@ -7004,7 +7006,7 @@ export class MatrixClient extends EventEmitter { * @return {Promise} Resolves: Empty json object on success * @return {module:http-api.MatrixError} Rejects: with an error response. */ - public setPusher(pusher: any, callback?: Callback): Promise { // TODO: Types + public setPusher(pusher: any, callback?: Callback): Promise<{}> { const path = "/pushers/set"; return this.http.authedRequest( callback, "POST", path, null, pusher, @@ -7012,11 +7014,12 @@ export class MatrixClient extends EventEmitter { } /** + * Get the push rules for the account from the server. * @param {module:client.callback} callback Optional. - * @return {Promise} Resolves: TODO + * @return {Promise} Resolves to the push rules. * @return {module:http-api.MatrixError} Rejects: with an error response. */ - public getPushRules(callback?: Callback): Promise { // TODO: Types + public getPushRules(callback?: Callback): Promise { return this.http.authedRequest(callback, "GET", "/pushrules/").then(rules => { return PushProcessor.rewriteDefaultRules(rules); }); From fb7184e6fb74e6c897e5a94d94d86ffee25a1e1b Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Sun, 11 Jul 2021 20:56:52 -0600 Subject: [PATCH 2/9] Reorganize types a bit --- src/@types/PushRules.ts | 57 +++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/src/@types/PushRules.ts b/src/@types/PushRules.ts index 74b1b16b7c3..f379a0a989e 100644 --- a/src/@types/PushRules.ts +++ b/src/@types/PushRules.ts @@ -64,31 +64,6 @@ export enum ConditionKind { SenderNotificationPermission = "sender_notification_permission", } -export enum PushRuleKind { - Override = "override", - ContentSpecific = "content", - RoomSpecific = "room", - SenderSpecific = "sender", - Underride = "underride", -} - -export type PushRuleSet = { - [k in PushRuleKind]?: IPushRule[]; -}; - -export interface IPushRule { - actions: PushRuleAction[]; - conditions?: PushRuleCondition[]; - default: boolean; - enabled: boolean; - pattern?: string; - rule_id: RuleId | string; // eslint-disable-line camel-case -} - -export interface IAnnotatedPushRule extends IPushRule { - kind: PushRuleKind; -} - export interface IPushRuleCondition { [k: string]: any; // for custom conditions, there can be other fields here kind: N; @@ -118,9 +93,13 @@ export type PushRuleCondition = IPushRuleCondition | IRoomMemberCountCondition | ISenderNotificationPermissionCondition; -export interface IPushRules { - global: PushRuleSet; - device?: PushRuleSet; + +export enum PushRuleKind { + Override = "override", + ContentSpecific = "content", + RoomSpecific = "room", + SenderSpecific = "sender", + Underride = "underride", } export enum RuleId { @@ -139,6 +118,28 @@ export enum RuleId { Tombstone = ".m.rule.tombstone", } +export type PushRuleSet = { + [k in PushRuleKind]?: IPushRule[]; +}; + +export interface IPushRule { + actions: PushRuleAction[]; + conditions?: PushRuleCondition[]; + default: boolean; + enabled: boolean; + pattern?: string; + rule_id: RuleId | string; // eslint-disable-line camel-case +} + +export interface IAnnotatedPushRule extends IPushRule { + kind: PushRuleKind; +} + +export interface IPushRules { + global: PushRuleSet; + device?: PushRuleSet; +} + export interface IPusher { app_display_name: string; // eslint-disable-line camel-case app_id: string; // eslint-disable-line camel-case From 11e25ea9a260db3d9e01dfc24e37cb48fd2038d5 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Sun, 11 Jul 2021 21:02:33 -0600 Subject: [PATCH 3/9] Appease linter --- src/@types/PushRules.ts | 24 ++++++++++++++---------- src/@types/requests.ts | 2 +- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/@types/PushRules.ts b/src/@types/PushRules.ts index f379a0a989e..4a3017b9973 100644 --- a/src/@types/PushRules.ts +++ b/src/@types/PushRules.ts @@ -14,6 +14,9 @@ See the License for the specific language governing permissions and limitations under the License. */ +// allow camelcase as these are things that go onto the wire +/* eslint-disable camelcase */ + export enum PushRuleActionName { DontNotify = "dont_notify", Notify = "notify", @@ -26,9 +29,9 @@ export enum TweakName { } export type Tweak = { - set_tweak: N; // eslint-disable-line camel-case + set_tweak: N; value: V; -} +}; export type TweakHighlight = Tweak; export type TweakSound = Tweak; @@ -49,7 +52,7 @@ export type MemberCountCondition = `${Op}${N}` | (Op extends ConditionOperator.ExactEquals ? `${N}` : never); -export type AnyMemberCountCondition = MemberCountCondition; +export type AnyMemberCountCondition = MemberCountCondition; export const DMMemberCountCondition: MemberCountCondition<2> = "2"; @@ -93,7 +96,6 @@ export type PushRuleCondition = IPushRuleCondition | IRoomMemberCountCondition | ISenderNotificationPermissionCondition; - export enum PushRuleKind { Override = "override", ContentSpecific = "content", @@ -128,7 +130,7 @@ export interface IPushRule { default: boolean; enabled: boolean; pattern?: string; - rule_id: RuleId | string; // eslint-disable-line camel-case + rule_id: RuleId | string; } export interface IAnnotatedPushRule extends IPushRule { @@ -141,15 +143,17 @@ export interface IPushRules { } export interface IPusher { - app_display_name: string; // eslint-disable-line camel-case - app_id: string; // eslint-disable-line camel-case + app_display_name: string; + app_id: string; data: { format?: string; // TODO: Types url?: string; // TODO: Required if kind==http - }, - device_display_name: string; // eslint-disable-line camel-case + }; + device_display_name: string; kind: string; // TODO: Types lang: string; - profile_tag?: string; // eslint-disable-line camel-case + profile_tag?: string; pushkey: string; } + +/* eslint-enable camelcase */ diff --git a/src/@types/requests.ts b/src/@types/requests.ts index eaf6828310a..551a0027f17 100644 --- a/src/@types/requests.ts +++ b/src/@types/requests.ts @@ -17,7 +17,7 @@ limitations under the License. import { Callback } from "../client"; import { Preset, Visibility } from "./partials"; -// allow camelcase as these are things go onto the wire +// allow camelcase as these are things that go onto the wire /* eslint-disable camelcase */ export interface IJoinRoomOpts { From 5f2ed4450e66b9cdebeeab7647a613b07d8de17c Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Sun, 11 Jul 2021 21:04:10 -0600 Subject: [PATCH 4/9] -- --- src/@types/threepids.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/@types/threepids.ts b/src/@types/threepids.ts index 38791701082..2b1a03378ff 100644 --- a/src/@types/threepids.ts +++ b/src/@types/threepids.ts @@ -21,8 +21,8 @@ export enum ThreepidMedium { // TODO: Are these types universal, or specific to just /account/3pid? export interface IThirdPartyIdentifier { - added_at: number; // eslint-disable-line camel-case + added_at: number; // eslint-disable-line camelcase address: string; medium: ThreepidMedium; - validated_at: number; // eslint-disable-line camel-case + validated_at: number; // eslint-disable-line camelcase } From d5c3cb1b7fa2e8c22d7a2a5ca3c23e63b02d9e91 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Mon, 12 Jul 2021 21:50:27 -0600 Subject: [PATCH 5/9] More minimal types for pushers & push rules --- src/@types/PushRules.ts | 5 +++++ src/client.ts | 39 +++++++++++++++++++++++++-------------- 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/src/@types/PushRules.ts b/src/@types/PushRules.ts index 4a3017b9973..a4eda1b4885 100644 --- a/src/@types/PushRules.ts +++ b/src/@types/PushRules.ts @@ -148,6 +148,7 @@ export interface IPusher { data: { format?: string; // TODO: Types url?: string; // TODO: Required if kind==http + brand?: string; // TODO: For email notifications only? }; device_display_name: string; kind: string; // TODO: Types @@ -156,4 +157,8 @@ export interface IPusher { pushkey: string; } +export interface IPusherRequest extends IPusher { + append?: boolean; +} + /* eslint-enable camelcase */ diff --git a/src/client.ts b/src/client.ts index 930e4834751..27e7fcff74c 100644 --- a/src/client.ts +++ b/src/client.ts @@ -117,7 +117,7 @@ import { WebStorageSessionStore } from "./store/session/webstorage"; import { BackupManager, IKeyBackupCheck, IPreparedKeyBackupVersion, TrustInfo } from "./crypto/backup"; import { DEFAULT_TREE_POWER_LEVELS_TEMPLATE, MSC3089TreeSpace } from "./models/MSC3089TreeSpace"; import { ISignatures } from "./@types/signed"; -import { IPusher, IPushRules } from "./@types/PushRules"; +import { IPusher, IPusherRequest, IPushRules, PushRuleAction, PushRuleKind, RuleId } from "./@types/PushRules"; import { IThirdPartyIdentifier } from "./@types/threepids"; export type Store = StubStore | MemoryStore | LocalIndexedDBStoreBackend | RemoteIndexedDBStoreBackend; @@ -4991,20 +4991,20 @@ export class MatrixClient extends EventEmitter { if (!mute) { // Remove the rule only if it is a muting rule if (hasDontNotifyRule) { - deferred = this.deletePushRule(scope, "room", roomPushRule.rule_id); + deferred = this.deletePushRule(scope, PushRuleKind.RoomSpecific, roomPushRule.rule_id); } } else { if (!roomPushRule) { - deferred = this.addPushRule(scope, "room", roomId, { + deferred = this.addPushRule(scope, PushRuleKind.RoomSpecific, roomId, { actions: ["dont_notify"], }); } else if (!hasDontNotifyRule) { // Remove the existing one before setting the mute push rule // This is a workaround to SYN-590 (Push rule update fails) deferred = utils.defer(); - this.deletePushRule(scope, "room", roomPushRule.rule_id) + this.deletePushRule(scope, PushRuleKind.RoomSpecific, roomPushRule.rule_id) .then(() => { - this.addPushRule(scope, "room", roomId, { + this.addPushRule(scope, PushRuleKind.RoomSpecific, roomId, { actions: ["dont_notify"], }).then(() => { deferred.resolve(); @@ -7001,12 +7001,12 @@ export class MatrixClient extends EventEmitter { /** * Adds a new pusher or updates an existing pusher * - * @param {Object} pusher Object representing a pusher + * @param {IPusherRequest} pusher Object representing a pusher * @param {module:client.callback} callback Optional. * @return {Promise} Resolves: Empty json object on success * @return {module:http-api.MatrixError} Rejects: with an error response. */ - public setPusher(pusher: any, callback?: Callback): Promise<{}> { + public setPusher(pusher: IPusherRequest, callback?: Callback): Promise<{}> { const path = "/pushers/set"; return this.http.authedRequest( callback, "POST", path, null, pusher, @@ -7034,7 +7034,13 @@ export class MatrixClient extends EventEmitter { * @return {Promise} Resolves: TODO * @return {module:http-api.MatrixError} Rejects: with an error response. */ - public addPushRule(scope: string, kind: string, ruleId: string, body: any, callback?: Callback): Promise { // TODO: Types + public addPushRule( + scope: string, + kind: PushRuleKind, + ruleId: RuleId | string, + body: any, + callback?: Callback, + ): Promise { // TODO: Types // NB. Scope not uri encoded because devices need the '/' const path = utils.encodeUri("/pushrules/" + scope + "/$kind/$ruleId", { $kind: kind, @@ -7053,7 +7059,12 @@ export class MatrixClient extends EventEmitter { * @return {Promise} Resolves: TODO * @return {module:http-api.MatrixError} Rejects: with an error response. */ - public deletePushRule(scope: string, kind: string, ruleId: string, callback?: Callback): Promise { // TODO: Types + public deletePushRule( + scope: string, + kind: PushRuleKind, + ruleId: RuleId | string, + callback?: Callback, + ): Promise { // TODO: Types // NB. Scope not uri encoded because devices need the '/' const path = utils.encodeUri("/pushrules/" + scope + "/$kind/$ruleId", { $kind: kind, @@ -7074,8 +7085,8 @@ export class MatrixClient extends EventEmitter { */ public setPushRuleEnabled( scope: string, - kind: string, - ruleId: string, + kind: PushRuleKind, + ruleId: RuleId | string, enabled: boolean, callback?: Callback, ): Promise { // TODO: Types @@ -7100,9 +7111,9 @@ export class MatrixClient extends EventEmitter { */ public setPushRuleActions( scope: string, - kind: string, - ruleId: string, - actions: string[], + kind: PushRuleKind, + ruleId: RuleId | string, + actions: PushRuleAction[], callback?: Callback, ): Promise { // TODO: Types const path = utils.encodeUri("/pushrules/" + scope + "/$kind/$ruleId/actions", { From 16fe5a91d5caeedb74e6b746f665931a62c22685 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Fri, 16 Jul 2021 16:27:50 -0600 Subject: [PATCH 6/9] Consolidate types --- src/@types/threepids.ts | 8 ++++---- src/client.ts | 24 +----------------------- 2 files changed, 5 insertions(+), 27 deletions(-) diff --git a/src/@types/threepids.ts b/src/@types/threepids.ts index 2b1a03378ff..65158d2e363 100644 --- a/src/@types/threepids.ts +++ b/src/@types/threepids.ts @@ -20,9 +20,9 @@ export enum ThreepidMedium { } // TODO: Are these types universal, or specific to just /account/3pid? -export interface IThirdPartyIdentifier { - added_at: number; // eslint-disable-line camelcase - address: string; +export interface IThreepid { medium: ThreepidMedium; - validated_at: number; // eslint-disable-line camelcase + address: string; + validated_at: number; + added_at: number; } diff --git a/src/client.ts b/src/client.ts index 387d28965f3..3d6bfce837e 100644 --- a/src/client.ts +++ b/src/client.ts @@ -145,7 +145,7 @@ import { import { ISynapseAdminDeactivateResponse, ISynapseAdminWhoisResponse } from "./@types/synapse"; import { ISpaceSummaryEvent, ISpaceSummaryRoom } from "./@types/spaces"; import { IPusher, IPusherRequest, IPushRules, PushRuleAction, PushRuleKind, RuleId } from "./@types/PushRules"; -import { IThirdPartyIdentifier } from "./@types/threepids"; +import { IThreepid } from "./@types/threepids"; export type Store = IStore; export type SessionStore = WebStorageSessionStore; @@ -597,13 +597,6 @@ interface IUserDirectoryResponse { limited: boolean; } -interface IThreepid { - medium: "email" | "msisdn"; - address: string; - validated_at: number; - added_at: number; -} - interface IMyDevice { device_id: string; display_name?: string; @@ -611,21 +604,6 @@ interface IMyDevice { last_seen_ts?: number; } -interface IPusher { - pushkey: string; - kind: string; - app_id: string; - app_display_name: string; - device_display_name: string; - profile_tag?: string; - lang: string; - data: { - url?: string; - format?: string; - brand?: string; // undocumented - }; -} - interface IDownloadKeyResult { failures: { [serverName: string]: object }; device_keys: { From 589c66bb128d29ac347a19e366086414538b2b2e Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Fri, 16 Jul 2021 16:30:06 -0600 Subject: [PATCH 7/9] Re-appease linter --- src/@types/threepids.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/@types/threepids.ts b/src/@types/threepids.ts index 65158d2e363..1740dec7a94 100644 --- a/src/@types/threepids.ts +++ b/src/@types/threepids.ts @@ -23,6 +23,6 @@ export enum ThreepidMedium { export interface IThreepid { medium: ThreepidMedium; address: string; - validated_at: number; - added_at: number; + validated_at: number; // eslint-disable-line camelcase + added_at: number; // eslint-disable-line camelcase } From fc8cd39d1aac31d280b8614f9660ae4261b8c41a Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Fri, 16 Jul 2021 16:32:49 -0600 Subject: [PATCH 8/9] Optionalize opts --- src/client.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client.ts b/src/client.ts index 3d6bfce837e..e4756c896eb 100644 --- a/src/client.ts +++ b/src/client.ts @@ -3863,7 +3863,7 @@ export class MatrixClient extends EventEmitter { * @return {Promise} Resolves: to an empty object * @return {module:http-api.MatrixError} Rejects: with an error response. */ - public async sendReadReceipt(event: MatrixEvent, opts: { hidden?: boolean }, callback?: Callback): Promise<{}> { + public async sendReadReceipt(event: MatrixEvent, opts?: { hidden?: boolean }, callback?: Callback): Promise<{}> { if (typeof (opts) === 'function') { callback = opts as any as Callback; // legacy opts = {}; From 7f7c3cbea50f48739a6d42a880c3bd0fbf093b8c Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Fri, 16 Jul 2021 23:48:41 -0600 Subject: [PATCH 9/9] Fix exclusion types --- src/client.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client.ts b/src/client.ts index e4756c896eb..08e6e5dd208 100644 --- a/src/client.ts +++ b/src/client.ts @@ -7219,7 +7219,7 @@ export class MatrixClient extends EventEmitter { public addPushRule( scope: string, kind: PushRuleKind, - ruleId: RuleId | string, + ruleId: Exclude, body: any, callback?: Callback, ): Promise { // TODO: Types @@ -7242,7 +7242,7 @@ export class MatrixClient extends EventEmitter { public deletePushRule( scope: string, kind: PushRuleKind, - ruleId: RuleId | string, + ruleId: Exclude, callback?: Callback, ): Promise { // TODO: Types // NB. Scope not uri encoded because devices need the '/'