make webpush enabled check better

Because Continuwuity sends a VAPID even when webpush is disabled.
This commit is contained in:
Henry Hiles 2026-12-02 13:50:34 -05:00
commit 9d495410f6
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs
3 changed files with 12 additions and 3 deletions

View file

@ -225,7 +225,8 @@ class UnifiedPushController extends AsyncNotifier<String?> {
CapabilitiesController.provider.future, CapabilitiesController.provider.future,
); );
if (capabilities.webpush?.vapid == null) { final vapid = capabilities.webPushVapid;
if (vapid == null) {
throw UnsupportedError( throw UnsupportedError(
"Your homeserver does not support MSC4174 (Web Push), and therefore cannot send notifications to Nexus.", "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([ await Future.wait([
UnifiedPush.register( UnifiedPush.register(
instance: deviceId, instance: deviceId,
vapid: capabilities.webpush?.vapid, vapid: vapid,
), ),
endpoint.future, endpoint.future,
], eagerError: true); ], eagerError: true);

View file

@ -23,7 +23,7 @@ class UnifiedPushAllowedController extends AsyncNotifier<String?> {
CapabilitiesController.provider.future, 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."; return "Your homeserver does not support MSC4174 (Web Push), and therefore cannot send notifications to Nexus.";
} }

View file

@ -10,6 +10,14 @@ class const Capabilities({
@JsonKey(name: "org.matrix.msc4174.webpush") final WebPush? webpush, @JsonKey(name: "org.matrix.msc4174.webpush") final WebPush? webpush,
@JsonKey(name: "m.room_versions") final RoomVersions? roomVersions, @JsonKey(name: "m.room_versions") final RoomVersions? roomVersions,
}) with _$Capabilities { }) 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); Map<String, Object?> toJson() => _$CapabilitiesToJson(this);
factory Capabilities.fromJson(Map<String, Object?> json) => factory Capabilities.fromJson(Map<String, Object?> json) =>