@@ -144,6 +144,8 @@ import {
144
144
} from "./@types/search" ;
145
145
import { ISynapseAdminDeactivateResponse , ISynapseAdminWhoisResponse } from "./@types/synapse" ;
146
146
import { ISpaceSummaryEvent , ISpaceSummaryRoom } from "./@types/spaces" ;
147
+ import { IPusher , IPusherRequest , IPushRules , PushRuleAction , PushRuleKind , RuleId } from "./@types/PushRules" ;
148
+ import { IThreepid } from "./@types/threepids" ;
147
149
148
150
export type Store = IStore ;
149
151
export type SessionStore = WebStorageSessionStore ;
@@ -595,35 +597,13 @@ interface IUserDirectoryResponse {
595
597
limited : boolean ;
596
598
}
597
599
598
- interface IThreepid {
599
- medium : "email" | "msisdn" ;
600
- address : string ;
601
- validated_at : number ;
602
- added_at : number ;
603
- }
604
-
605
600
interface IMyDevice {
606
601
device_id : string ;
607
602
display_name ?: string ;
608
603
last_seen_ip ?: string ;
609
604
last_seen_ts ?: number ;
610
605
}
611
606
612
- interface IPusher {
613
- pushkey : string ;
614
- kind : string ;
615
- app_id : string ;
616
- app_display_name : string ;
617
- device_display_name : string ;
618
- profile_tag ?: string ;
619
- lang : string ;
620
- data : {
621
- url ?: string ;
622
- format ?: string ;
623
- brand ?: string ; // undocumented
624
- } ;
625
- }
626
-
627
607
interface IDownloadKeyResult {
628
608
failures : { [ serverName : string ] : object } ;
629
609
device_keys : {
@@ -3883,7 +3863,7 @@ export class MatrixClient extends EventEmitter {
3883
3863
* @return {Promise } Resolves: to an empty object
3884
3864
* @return {module:http-api.MatrixError } Rejects: with an error response.
3885
3865
*/
3886
- public async sendReadReceipt ( event : MatrixEvent , opts : { hidden ?: boolean } , callback ?: Callback ) : Promise < { } > {
3866
+ public async sendReadReceipt ( event : MatrixEvent , opts ? : { hidden ?: boolean } , callback ?: Callback ) : Promise < { } > {
3887
3867
if ( typeof ( opts ) === 'function' ) {
3888
3868
callback = opts as any as Callback ; // legacy
3889
3869
opts = { } ;
@@ -5220,20 +5200,20 @@ export class MatrixClient extends EventEmitter {
5220
5200
if ( ! mute ) {
5221
5201
// Remove the rule only if it is a muting rule
5222
5202
if ( hasDontNotifyRule ) {
5223
- deferred = this . deletePushRule ( scope , "room" , roomPushRule . rule_id ) ;
5203
+ deferred = this . deletePushRule ( scope , PushRuleKind . RoomSpecific , roomPushRule . rule_id ) ;
5224
5204
}
5225
5205
} else {
5226
5206
if ( ! roomPushRule ) {
5227
- deferred = this . addPushRule ( scope , "room" , roomId , {
5207
+ deferred = this . addPushRule ( scope , PushRuleKind . RoomSpecific , roomId , {
5228
5208
actions : [ "dont_notify" ] ,
5229
5209
} ) ;
5230
5210
} else if ( ! hasDontNotifyRule ) {
5231
5211
// Remove the existing one before setting the mute push rule
5232
5212
// This is a workaround to SYN-590 (Push rule update fails)
5233
5213
deferred = utils . defer ( ) ;
5234
- this . deletePushRule ( scope , "room" , roomPushRule . rule_id )
5214
+ this . deletePushRule ( scope , PushRuleKind . RoomSpecific , roomPushRule . rule_id )
5235
5215
. then ( ( ) => {
5236
- this . addPushRule ( scope , "room" , roomId , {
5216
+ this . addPushRule ( scope , PushRuleKind . RoomSpecific , roomId , {
5237
5217
actions : [ "dont_notify" ] ,
5238
5218
} ) . then ( ( ) => {
5239
5219
deferred . resolve ( ) ;
@@ -6974,7 +6954,7 @@ export class MatrixClient extends EventEmitter {
6974
6954
6975
6955
/**
6976
6956
* @param {module:client.callback } callback Optional.
6977
- * @return {Promise } Resolves: TODO
6957
+ * @return {Promise } Resolves to a list of the user's threepids.
6978
6958
* @return {module:http-api.MatrixError } Rejects: with an error response.
6979
6959
*/
6980
6960
public getThreePids ( callback ?: Callback ) : Promise < { threepids : IThreepid [ ] } > {
@@ -7205,22 +7185,23 @@ export class MatrixClient extends EventEmitter {
7205
7185
/**
7206
7186
* Adds a new pusher or updates an existing pusher
7207
7187
*
7208
- * @param {Object } pusher Object representing a pusher
7188
+ * @param {IPusherRequest } pusher Object representing a pusher
7209
7189
* @param {module:client.callback } callback Optional.
7210
7190
* @return {Promise } Resolves: Empty json object on success
7211
7191
* @return {module:http-api.MatrixError } Rejects: with an error response.
7212
7192
*/
7213
- public setPusher ( pusher : IPusher , callback ?: Callback ) : Promise < { } > {
7193
+ public setPusher ( pusher : IPusherRequest , callback ?: Callback ) : Promise < { } > {
7214
7194
const path = "/pushers/set" ;
7215
7195
return this . http . authedRequest ( callback , "POST" , path , null , pusher ) ;
7216
7196
}
7217
7197
7218
7198
/**
7199
+ * Get the push rules for the account from the server.
7219
7200
* @param {module:client.callback } callback Optional.
7220
- * @return {Promise } Resolves: TODO
7201
+ * @return {Promise } Resolves to the push rules.
7221
7202
* @return {module:http-api.MatrixError } Rejects: with an error response.
7222
7203
*/
7223
- public getPushRules ( callback ?: Callback ) : Promise < any > { // TODO: Types
7204
+ public getPushRules ( callback ?: Callback ) : Promise < IPushRules > {
7224
7205
return this . http . authedRequest ( callback , "GET" , "/pushrules/" ) . then ( rules => {
7225
7206
return PushProcessor . rewriteDefaultRules ( rules ) ;
7226
7207
} ) ;
@@ -7235,7 +7216,13 @@ export class MatrixClient extends EventEmitter {
7235
7216
* @return {Promise } Resolves: an empty object {}
7236
7217
* @return {module:http-api.MatrixError } Rejects: with an error response.
7237
7218
*/
7238
- public addPushRule ( scope : string , kind : string , ruleId : string , body : any , callback ?: Callback ) : Promise < { } > {
7219
+ public addPushRule (
7220
+ scope : string ,
7221
+ kind : PushRuleKind ,
7222
+ ruleId : Exclude < string , RuleId > ,
7223
+ body : any ,
7224
+ callback ?: Callback ,
7225
+ ) : Promise < any > { // TODO: Types
7239
7226
// NB. Scope not uri encoded because devices need the '/'
7240
7227
const path = utils . encodeUri ( "/pushrules/" + scope + "/$kind/$ruleId" , {
7241
7228
$kind : kind ,
@@ -7252,7 +7239,12 @@ export class MatrixClient extends EventEmitter {
7252
7239
* @return {Promise } Resolves: an empty object {}
7253
7240
* @return {module:http-api.MatrixError } Rejects: with an error response.
7254
7241
*/
7255
- public deletePushRule ( scope : string , kind : string , ruleId : string , callback ?: Callback ) : Promise < { } > {
7242
+ public deletePushRule (
7243
+ scope : string ,
7244
+ kind : PushRuleKind ,
7245
+ ruleId : Exclude < string , RuleId > ,
7246
+ callback ?: Callback ,
7247
+ ) : Promise < any > { // TODO: Types
7256
7248
// NB. Scope not uri encoded because devices need the '/'
7257
7249
const path = utils . encodeUri ( "/pushrules/" + scope + "/$kind/$ruleId" , {
7258
7250
$kind : kind ,
@@ -7273,8 +7265,8 @@ export class MatrixClient extends EventEmitter {
7273
7265
*/
7274
7266
public setPushRuleEnabled (
7275
7267
scope : string ,
7276
- kind : string ,
7277
- ruleId : string ,
7268
+ kind : PushRuleKind ,
7269
+ ruleId : RuleId | string ,
7278
7270
enabled : boolean ,
7279
7271
callback ?: Callback ,
7280
7272
) : Promise < { } > {
@@ -7299,9 +7291,9 @@ export class MatrixClient extends EventEmitter {
7299
7291
*/
7300
7292
public setPushRuleActions (
7301
7293
scope : string ,
7302
- kind : string ,
7303
- ruleId : string ,
7304
- actions : string [ ] ,
7294
+ kind : PushRuleKind ,
7295
+ ruleId : RuleId | string ,
7296
+ actions : PushRuleAction [ ] ,
7305
7297
callback ?: Callback ,
7306
7298
) : Promise < { } > {
7307
7299
const path = utils . encodeUri ( "/pushrules/" + scope + "/$kind/$ruleId/actions" , {
0 commit comments