mirror of
https://github.com/bitwarden/browser
synced 2025-12-15 15:53:27 +00:00
Parse web push payload JSON (#13594)
This commit is contained in:
@@ -12,7 +12,16 @@ export class NotificationResponse extends BaseResponse {
|
||||
this.contextId = this.getResponseProperty("ContextId");
|
||||
this.type = this.getResponseProperty("Type");
|
||||
|
||||
const payload = this.getResponseProperty("Payload");
|
||||
let payload = this.getResponseProperty("Payload");
|
||||
|
||||
if (typeof payload === "string") {
|
||||
try {
|
||||
payload = JSON.parse(payload);
|
||||
} catch {
|
||||
// guess it was a string
|
||||
}
|
||||
}
|
||||
|
||||
switch (this.type) {
|
||||
case NotificationType.SyncCipherCreate:
|
||||
case NotificationType.SyncCipherDelete:
|
||||
|
||||
@@ -124,7 +124,9 @@ class MyWebPushConnector implements WebPushConnector {
|
||||
return this.webPushApiService.putSubscription(subscription.toJSON());
|
||||
}).pipe(
|
||||
switchMap(() => this.pushEvent$),
|
||||
map((e) => new NotificationResponse(e.data.json().data)),
|
||||
map((e) => {
|
||||
return new NotificationResponse(e.data.json().data);
|
||||
}),
|
||||
);
|
||||
}),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user