support for registering pushers
This commit is contained in:
parent
88cdcf9863
commit
fe871217b2
21 changed files with 350 additions and 22 deletions
25
lib/models/capabilities.dart
Normal file
25
lib/models/capabilities.dart
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import "package:freezed_annotation/freezed_annotation.dart";
|
||||
|
||||
part "capabilities.freezed.dart";
|
||||
part "capabilities.g.dart";
|
||||
|
||||
@Freezed(toJson: false, fromJson: false)
|
||||
@JsonSerializable()
|
||||
class const Capabilities({
|
||||
@JsonKey(name: "org.matrix.msc4174.webpush") final WebPush? webpush,
|
||||
}) with _$Capabilities {
|
||||
Map<String, Object?> toJson() => _$CapabilitiesToJson(this);
|
||||
|
||||
factory Capabilities.fromJson(Map<String, Object?> json) =>
|
||||
_$CapabilitiesFromJson(json);
|
||||
}
|
||||
|
||||
@Freezed(toJson: false, fromJson: false)
|
||||
@JsonSerializable()
|
||||
class const WebPush({required final bool enabled, final String? vapid})
|
||||
with _$WebPush {
|
||||
Map<String, Object?> toJson() => _$WebPushToJson(this);
|
||||
|
||||
factory WebPush.fromJson(Map<String, Object?> json) =>
|
||||
_$WebPushFromJson(json);
|
||||
}
|
||||
|
|
@ -10,6 +10,7 @@ class const ClientState({
|
|||
required final bool isLoggedIn,
|
||||
required final bool isVerified,
|
||||
required final String? userId,
|
||||
required final String? deviceId,
|
||||
required final String? homeserverUrl,
|
||||
}) with _$ClientState {
|
||||
Map<String, Object?> toJson() => _$ClientStateToJson(this);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import "package:freezed_annotation/freezed_annotation.dart";
|
||||
|
||||
@JsonEnum(fieldRename: FieldRename.snake)
|
||||
@JsonEnum(fieldRename: .snake)
|
||||
enum JoinRule { public, knock, invite, private, restricted, knockRestricted }
|
||||
|
|
|
|||
|
|
@ -1,4 +1 @@
|
|||
import "package:freezed_annotation/freezed_annotation.dart";
|
||||
|
||||
@JsonEnum()
|
||||
enum MembershipAction { ban, kick, unban, invite }
|
||||
|
|
|
|||
|
|
@ -1,4 +1 @@
|
|||
import "package:freezed_annotation/freezed_annotation.dart";
|
||||
|
||||
@JsonEnum()
|
||||
enum MembershipStatus { leave, invite, ban, join, knock }
|
||||
|
|
|
|||
56
lib/models/requests/register_pusher.dart
Normal file
56
lib/models/requests/register_pusher.dart
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
import "package:freezed_annotation/freezed_annotation.dart";
|
||||
|
||||
part "register_pusher.freezed.dart";
|
||||
part "register_pusher.g.dart";
|
||||
|
||||
@Freezed(toJson: false, fromJson: false)
|
||||
@JsonSerializable()
|
||||
class const RegisterPusherRequest({
|
||||
required final String appDisplayName,
|
||||
required final String appId,
|
||||
final bool append = false,
|
||||
required final PusherData data,
|
||||
required final String deviceDisplayName,
|
||||
required final PusherKind kind,
|
||||
required final String lang,
|
||||
|
||||
/// TODO: What does this do?
|
||||
final String? profileTag,
|
||||
|
||||
@JsonKey(name: "pushkey") required final String pushKey,
|
||||
}) with _$RegisterPusherRequest {
|
||||
Map<String, Object?> toJson() => _$RegisterPusherRequestToJson(this);
|
||||
}
|
||||
|
||||
@freezed
|
||||
sealed class PusherData with _$PusherData {
|
||||
const factory PusherData.http({
|
||||
required Uri url,
|
||||
@Default(PushFormat.eventIdOnly) PushFormat format,
|
||||
}) = HttpPusherData;
|
||||
|
||||
const factory PusherData.webPush({
|
||||
required Uri url,
|
||||
@Default(PushFormat.eventIdOnly) PushFormat format,
|
||||
|
||||
/// `data.auth`: RFC8291 authentication secret.
|
||||
required String auth,
|
||||
}) = WebPushPusherData;
|
||||
|
||||
factory PusherData.fromJson(Map<String, Object?> json) =>
|
||||
_$PusherDataFromJson(json);
|
||||
}
|
||||
|
||||
@JsonEnum(fieldRename: .snake)
|
||||
enum PushFormat {
|
||||
@JsonValue(null)
|
||||
all,
|
||||
eventIdOnly,
|
||||
}
|
||||
|
||||
enum PusherKind {
|
||||
http,
|
||||
email,
|
||||
@JsonValue("org.matrix.msc4174.webpush")
|
||||
webPush,
|
||||
}
|
||||
Loading…
Reference in a new issue