From 51f4233939378483d2185b075d8f269a86263454 Mon Sep 17 00:00:00 2001 From: Grace Kind Date: Sun, 16 Aug 2026 12:56:40 -0500 Subject: [PATCH] Fix push unregister --- package.json | 2 +- src/js/api.js | 4 ++-- src/js/push/courierPushService.js | 2 ++ tests/unit/specs/courierPushService.test.js | 7 +++++++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 1c2df5f5..2d3e6b43 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "impro", - "version": "0.18.203", + "version": "0.18.204", "type": "module", "scripts": { "start": "rm -rf \"${BUILD_DIR:-build}\" && NODE_ENV=development eleventy --serve", diff --git a/src/js/api.js b/src/js/api.js index be594ee9..b5e21ae8 100644 --- a/src/js/api.js +++ b/src/js/api.js @@ -741,10 +741,10 @@ export class Api { }); } - async unregisterPush({ serviceDid, token }) { + async unregisterPush({ serviceDid, token, platform, appId }) { await this.request("app.bsky.notification.unregisterPush", { method: "POST", - body: { serviceDid, token }, + body: { serviceDid, token, platform, appId }, headers: { "atproto-proxy": `${serviceDid}#bsky_notif`, }, diff --git a/src/js/push/courierPushService.js b/src/js/push/courierPushService.js index d14109b7..a72c9be4 100644 --- a/src/js/push/courierPushService.js +++ b/src/js/push/courierPushService.js @@ -202,6 +202,8 @@ export class CourierPushService { await this.api.unregisterPush({ serviceDid: this.serviceDid, token: JSON.stringify(subscription), + platform: PLATFORM, + appId: APP_ID, }); } catch (error) { console.error("Failed to unregister push subscription", error); diff --git a/tests/unit/specs/courierPushService.test.js b/tests/unit/specs/courierPushService.test.js index 59ac0d1a..823f4d63 100644 --- a/tests/unit/specs/courierPushService.test.js +++ b/tests/unit/specs/courierPushService.test.js @@ -170,6 +170,13 @@ describe("CourierPushService registration", () => { service.api.unregisterPush = unregisterPush; await service.disable(); assert.equal(unregisterPush.mock.calls.length, 1); + const args = unregisterPush.mock.calls[0].arguments[0]; + assert.equal(args.appId, "social.impro"); + assert.equal(args.platform, "web"); + assert.deepEqual(JSON.parse(args.token), { + endpoint: SUBSCRIPTION.endpoint, + keys: SUBSCRIPTION.keys, + }); assert.equal(service.$enabled.get(), false); }); -- 2.51.2