forked from Nexus/nexus
Push Notifications (#66)
Fixes #35. Things to do: - [x] Register with local distributor - [x] Register with homeserver - [x] Recieve messages - [x] Show notifications - [ ] Notifications page (could come later) Reviewed-on: Nexus/nexus#66
This commit is contained in:
parent
6e42902322
commit
ff9bf3bec4
30 changed files with 772 additions and 36 deletions
13
lib/models/requests/deregister_pusher.dart
Normal file
13
lib/models/requests/deregister_pusher.dart
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import "package:freezed_annotation/freezed_annotation.dart";
|
||||
|
||||
part "deregister_pusher.freezed.dart";
|
||||
part "deregister_pusher.g.dart";
|
||||
|
||||
@Freezed(toJson: false, fromJson: false)
|
||||
@JsonSerializable()
|
||||
class const DeregisterPusherRequest({
|
||||
required final String appId,
|
||||
@JsonKey(name: "pushkey") required final String pushKey,
|
||||
}) with _$DeregisterPusherRequest {
|
||||
Map<String, Object?> toJson() => _$DeregisterPusherRequestToJson(this);
|
||||
}
|
||||
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