forked from Nexus/nexus
make webpush enabled check better
Because Continuwuity sends a VAPID even when webpush is disabled.
This commit is contained in:
parent
7424bec0fb
commit
9d495410f6
3 changed files with 12 additions and 3 deletions
|
|
@ -225,7 +225,8 @@ class UnifiedPushController extends AsyncNotifier<String?> {
|
|||
CapabilitiesController.provider.future,
|
||||
);
|
||||
|
||||
if (capabilities.webpush?.vapid == null) {
|
||||
final vapid = capabilities.webPushVapid;
|
||||
if (vapid == null) {
|
||||
throw UnsupportedError(
|
||||
"Your homeserver does not support MSC4174 (Web Push), and therefore cannot send notifications to Nexus.",
|
||||
);
|
||||
|
|
@ -243,7 +244,7 @@ class UnifiedPushController extends AsyncNotifier<String?> {
|
|||
await Future.wait([
|
||||
UnifiedPush.register(
|
||||
instance: deviceId,
|
||||
vapid: capabilities.webpush?.vapid,
|
||||
vapid: vapid,
|
||||
),
|
||||
endpoint.future,
|
||||
], eagerError: true);
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class UnifiedPushAllowedController extends AsyncNotifier<String?> {
|
|||
CapabilitiesController.provider.future,
|
||||
);
|
||||
|
||||
if (capabilities.webpush?.vapid == null) {
|
||||
if (capabilities.webPushVapid == null) {
|
||||
return "Your homeserver does not support MSC4174 (Web Push), and therefore cannot send notifications to Nexus.";
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,14 @@ class const Capabilities({
|
|||
@JsonKey(name: "org.matrix.msc4174.webpush") final WebPush? webpush,
|
||||
@JsonKey(name: "m.room_versions") final RoomVersions? roomVersions,
|
||||
}) with _$Capabilities {
|
||||
/// The VAPID key to register Web Push pushers with, or null if the
|
||||
/// homeserver can't send Web Push. Continuwuity sends a key even when the
|
||||
/// feature is disabled, so `enabled` must be checked too.
|
||||
String? get webPushVapid => switch (webpush) {
|
||||
WebPush(enabled: true, :final vapid) => vapid,
|
||||
_ => null,
|
||||
};
|
||||
|
||||
Map<String, Object?> toJson() => _$CapabilitiesToJson(this);
|
||||
|
||||
factory Capabilities.fromJson(Map<String, Object?> json) =>
|
||||
|
|
|
|||
Loading…
Reference in a new issue