feat: deletePusher
This commit is contained in:
parent
793ddddd3f
commit
477780d779
|
|
@ -1312,50 +1312,80 @@ class PusherData {
|
||||||
}
|
}
|
||||||
|
|
||||||
@_NameSource('spec')
|
@_NameSource('spec')
|
||||||
class Pusher {
|
class PusherId {
|
||||||
Pusher({
|
PusherId({
|
||||||
required this.appDisplayName,
|
|
||||||
required this.appId,
|
required this.appId,
|
||||||
|
required this.pushkey,
|
||||||
|
});
|
||||||
|
|
||||||
|
PusherId.fromJson(Map<String, dynamic> json)
|
||||||
|
: appId = json['app_id'] as String,
|
||||||
|
pushkey = json['pushkey'] as String;
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
'app_id': appId,
|
||||||
|
'pushkey': pushkey,
|
||||||
|
};
|
||||||
|
|
||||||
|
/// This is a reverse-DNS style identifier for the application.
|
||||||
|
/// Max length, 64 chars.
|
||||||
|
String appId;
|
||||||
|
|
||||||
|
/// This is a unique identifier for this pusher. See `/set` for
|
||||||
|
/// more detail.
|
||||||
|
/// Max length, 512 bytes.
|
||||||
|
String pushkey;
|
||||||
|
}
|
||||||
|
|
||||||
|
@_NameSource('spec')
|
||||||
|
class Pusher implements PusherId {
|
||||||
|
Pusher({
|
||||||
|
required this.appId,
|
||||||
|
required this.pushkey,
|
||||||
|
required this.appDisplayName,
|
||||||
required this.data,
|
required this.data,
|
||||||
required this.deviceDisplayName,
|
required this.deviceDisplayName,
|
||||||
required this.kind,
|
required this.kind,
|
||||||
required this.lang,
|
required this.lang,
|
||||||
this.profileTag,
|
this.profileTag,
|
||||||
required this.pushkey,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Pusher.fromJson(Map<String, dynamic> json)
|
Pusher.fromJson(Map<String, dynamic> json)
|
||||||
: appDisplayName = json['app_display_name'] as String,
|
: appId = json['app_id'] as String,
|
||||||
appId = json['app_id'] as String,
|
pushkey = json['pushkey'] as String,
|
||||||
|
appDisplayName = json['app_display_name'] as String,
|
||||||
data = PusherData.fromJson(json['data']),
|
data = PusherData.fromJson(json['data']),
|
||||||
deviceDisplayName = json['device_display_name'] as String,
|
deviceDisplayName = json['device_display_name'] as String,
|
||||||
kind = json['kind'] as String,
|
kind = json['kind'] as String,
|
||||||
lang = json['lang'] as String,
|
lang = json['lang'] as String,
|
||||||
profileTag =
|
profileTag =
|
||||||
((v) => v != null ? v as String : null)(json['profile_tag']),
|
((v) => v != null ? v as String : null)(json['profile_tag']);
|
||||||
pushkey = json['pushkey'] as String;
|
|
||||||
Map<String, dynamic> toJson() {
|
Map<String, dynamic> toJson() {
|
||||||
final profileTag = this.profileTag;
|
final profileTag = this.profileTag;
|
||||||
return {
|
return {
|
||||||
'app_display_name': appDisplayName,
|
|
||||||
'app_id': appId,
|
'app_id': appId,
|
||||||
|
'pushkey': pushkey,
|
||||||
|
'app_display_name': appDisplayName,
|
||||||
'data': data.toJson(),
|
'data': data.toJson(),
|
||||||
'device_display_name': deviceDisplayName,
|
'device_display_name': deviceDisplayName,
|
||||||
'kind': kind,
|
'kind': kind,
|
||||||
'lang': lang,
|
'lang': lang,
|
||||||
if (profileTag != null) 'profile_tag': profileTag,
|
if (profileTag != null) 'profile_tag': profileTag,
|
||||||
'pushkey': pushkey,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A string that will allow the user to identify what application
|
|
||||||
/// owns this pusher.
|
|
||||||
String appDisplayName;
|
|
||||||
|
|
||||||
/// This is a reverse-DNS style identifier for the application.
|
/// This is a reverse-DNS style identifier for the application.
|
||||||
/// Max length, 64 chars.
|
/// Max length, 64 chars.
|
||||||
String appId;
|
String appId;
|
||||||
|
|
||||||
|
/// This is a unique identifier for this pusher. See `/set` for
|
||||||
|
/// more detail.
|
||||||
|
/// Max length, 512 bytes.
|
||||||
|
String pushkey;
|
||||||
|
|
||||||
|
/// A string that will allow the user to identify what application
|
||||||
|
/// owns this pusher.
|
||||||
|
String appDisplayName;
|
||||||
|
|
||||||
/// A dictionary of information for the pusher implementation
|
/// A dictionary of information for the pusher implementation
|
||||||
/// itself.
|
/// itself.
|
||||||
PusherData data;
|
PusherData data;
|
||||||
|
|
@ -1375,11 +1405,6 @@ class Pusher {
|
||||||
/// This string determines which set of device specific rules this
|
/// This string determines which set of device specific rules this
|
||||||
/// pusher executes.
|
/// pusher executes.
|
||||||
String? profileTag;
|
String? profileTag;
|
||||||
|
|
||||||
/// This is a unique identifier for this pusher. See `/set` for
|
|
||||||
/// more detail.
|
|
||||||
/// Max length, 512 bytes.
|
|
||||||
String pushkey;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@_NameSource('spec')
|
@_NameSource('spec')
|
||||||
|
|
|
||||||
|
|
@ -173,6 +173,9 @@ class MatrixApi extends Api {
|
||||||
/// This endpoint allows the creation, modification and deletion of pushers
|
/// This endpoint allows the creation, modification and deletion of pushers
|
||||||
/// for this user ID. The behaviour of this endpoint varies depending on the
|
/// for this user ID. The behaviour of this endpoint varies depending on the
|
||||||
/// values in the JSON body.
|
/// values in the JSON body.
|
||||||
|
///
|
||||||
|
/// See [deletePusher] to issue requests with `kind: null`.
|
||||||
|
///
|
||||||
/// https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-pushers-set
|
/// https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-pushers-set
|
||||||
Future<void> postPusher(Pusher pusher, {bool? append}) async {
|
Future<void> postPusher(Pusher pusher, {bool? append}) async {
|
||||||
final data = pusher.toJson();
|
final data = pusher.toJson();
|
||||||
|
|
@ -187,6 +190,20 @@ class MatrixApi extends Api {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Variant of postPusher operation that deletes pushers by setting `kind: null`.
|
||||||
|
///
|
||||||
|
/// https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-pushers-set
|
||||||
|
Future<void> deletePusher(PusherId pusher) async {
|
||||||
|
final data = PusherData.fromJson(pusher.toJson()).toJson();
|
||||||
|
data['kind'] = null;
|
||||||
|
await request(
|
||||||
|
RequestType.POST,
|
||||||
|
'/client/r0/pushers/set',
|
||||||
|
data: data,
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/// This API provides credentials for the client to use when initiating
|
/// This API provides credentials for the client to use when initiating
|
||||||
/// calls.
|
/// calls.
|
||||||
@override
|
@override
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue