Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
fix(notifications): count iPhones enrolled for push in the preference center
nirholasd1e2c7343a4a
diff --git a/api/notifications/preferences.js b/api/notifications/preferences.jsindex 721ccb852..61ef5d89f 100644--- a/api/notifications/preferences.js+++ b/api/notifications/preferences.js@@ -51,8 +51,12 @@ export default wrap(async (req, res) => {if (req.method === 'GET') {const prefs = await resolvePrefs(user.id);- const [[pushRow], chats] = await Promise.all([+ const [[pushRow], [iosRow], chats] = await Promise.all([sql`select count(*)::int as count from push_subscriptions where user_id = ${user.id}`,+ // iPhones enrolled through the iOS app (APNs), which has no Web Push+ // endpoint. Counted beside browsers so an iPhone-only user is not told+ // push is off everywhere.+ sql`select count(*)::int as count from apns_devices where user_id = ${user.id}`.catch(() => [{ count: 0 }]),// Chats paired through the chat gateways (/settings/connections). The// telegram and discord channels deliver there, so the matrix enables// those columns once a chat with notifications on exists.@@ -70,7 +74,10 @@ export default wrap(async (req, res) => {// gates push and email with. Shipping it here keeps one source of truth.type_categories: typeCategoryMap(),prefs,- push: { subscribed_devices: pushRow?.count ?? 0 },+ push: {+ subscribed_devices: (pushRow?.count ?? 0) + (iosRow?.count ?? 0),+ ios_devices: iosRow?.count ?? 0,+ },gateways,});}diff --git a/tests/api/notifications-item-and-prefs.test.js b/tests/api/notifications-item-and-prefs.test.jsindex 263b5105e..af1e2a545 100644--- a/tests/api/notifications-item-and-prefs.test.js+++ b/tests/api/notifications-item-and-prefs.test.js@@ -18,7 +18,7 @@import { describe, it, expect, vi, beforeEach } from 'vitest';-const dbState = { deleted: [], marked: [], stored: null, pushDevices: 0 };+const dbState = { deleted: [], marked: [], stored: null, pushDevices: 0, iosDevices: 0 };const sqlCalls = [];vi.mock('../../api/_lib/db.js', () => ({sql: Object.assign(@@ -33,6 +33,9 @@ vi.mock('../../api/_lib/db.js', () => ({if (/from push_subscriptions/.test(text)) {return Promise.resolve([{ count: dbState.pushDevices }]);}+ if (/from apns_devices/.test(text)) {+ return Promise.resolve([{ count: dbState.iosDevices }]);+ }return Promise.resolve([]);}),{ transaction: vi.fn(async (fns) => { for (const f of fns) await f; }) },@@ -194,11 +197,19 @@ describe('GET /api/notifications/preferences', () => {// Pinned deliberately as a literal, not derived from CHANNELS: this is the// wire contract the notifications page and the SDK read, so adding a// channel should have to come here and say so. 'avatar' landed with the- // corner-avatar delivery lane.- expect(body.channels).toEqual(['in_app', 'push', 'email', 'telegram', 'avatar']);+ // corner-avatar delivery lane, 'discord' with the chat gateways.+ expect(body.channels).toEqual(['in_app', 'push', 'email', 'telegram', 'discord', 'avatar']);expect(body.categories.map((c) => c.key)).toContain('social');expect(body.prefs.categories.social).toBeTruthy();- expect(body.push).toEqual({ subscribed_devices: 2 });+ expect(body.push).toEqual({ subscribed_devices: 2, ios_devices: 0 });+ });++ it('counts iPhones enrolled through the iOS app as push devices', async () => {+ dbState.pushDevices = 1;+ dbState.iosDevices = 2;+ const { body } = await call(prefsHandler, { method: 'GET' });+ expect(body.push).toEqual({ subscribed_devices: 3, ios_devices: 2 });+ dbState.iosDevices = 0;});});