Skip to content

Commit d3ec6f7

Browse files
committed
feat: route push notifications by server and session
Include serverID in relay event payloads and prefer server+session matching in mobile notification handling so taps reliably open the correct context and stale state is refreshed.
1 parent 9a8b2ae commit d3ec6f7

File tree

3 files changed

+326
-18
lines changed

3 files changed

+326
-18
lines changed

packages/apn-relay/src/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ const unreg = z.object({
5050

5151
const evt = z.object({
5252
secret: z.string().min(1),
53+
serverID: z.string().min(1).optional(),
5354
eventType: z.enum(["complete", "permission", "error"]),
5455
sessionID: z.string().min(1),
5556
title: z.string().min(1).optional(),
@@ -325,6 +326,7 @@ app.post("/v1/event", async (c) => {
325326
const list = await db.select().from(device_registration).where(eq(device_registration.secret_hash, key))
326327
console.log("[relay] event", {
327328
type: check.data.eventType,
329+
serverID: check.data.serverID,
328330
session: check.data.sessionID,
329331
secretHash: `${key.slice(0, 12)}...`,
330332
devices: list.length,
@@ -333,6 +335,7 @@ app.post("/v1/event", async (c) => {
333335
const [total] = await db.select({ value: sql<number>`count(*)` }).from(device_registration)
334336
console.log("[relay] event:no-matching-devices", {
335337
type: check.data.eventType,
338+
serverID: check.data.serverID,
336339
session: check.data.sessionID,
337340
secretHash: `${key.slice(0, 12)}...`,
338341
totalDevices: Number(total?.value ?? 0),
@@ -354,6 +357,7 @@ app.post("/v1/event", async (c) => {
354357
title: check.data.title ?? title(check.data.eventType),
355358
body: check.data.body ?? body(check.data.eventType),
356359
data: {
360+
serverID: check.data.serverID,
357361
eventType: check.data.eventType,
358362
sessionID: check.data.sessionID,
359363
},

0 commit comments

Comments
 (0)