Skip to content

Commit 7a6256b

Browse files
committed
chore: test push notification logic, harmonize logs
1 parent f70ed20 commit 7a6256b

3 files changed

Lines changed: 5 additions & 120 deletions

File tree

ATP.md

Lines changed: 0 additions & 107 deletions
This file was deleted.

src/server/features/push-cron.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ let cronDeliveryApp = new Hono().get(
6262
})
6363

6464
if (!serverAccount || !serverAccount.root) {
65-
console.log("🔔 Missing server account or root, aborting cron")
65+
console.log("⚠️ Missing server account or root, aborting cron")
6666
return c.json({
6767
message: "Missing server account or root",
6868
results: [],
@@ -86,7 +86,7 @@ let cronDeliveryApp = new Hono().get(
8686

8787
let notificationSettings = ref.notificationSettings
8888
if (!notificationSettings?.$isLoaded) {
89-
console.log(` User ${ref.userId}: Settings not loaded`)
89+
console.log(`⚠️ User ${ref.userId}: Settings not loaded, skipping`)
9090
continue
9191
}
9292

@@ -202,15 +202,11 @@ async function processNotificationRef(
202202
if (enabledDevices.length === 0) {
203203
console.log(`✅ User ${userId}: No enabled devices`)
204204
markNotificationSettingsAsDelivered(notificationSettings, currentUtc)
205-
console.log(
206-
`✅ User ${userId}: Marked as delivered (skipped - no action needed)`,
207-
)
205+
console.log(`✅ User ${userId}: Marked as delivered (no devices to notify)`)
208206
return { status: "skipped", reason: "No enabled devices" }
209207
}
210208

211-
console.log(
212-
`✅ User ${userId}: Ready to send wake notification to ${enabledDevices.length} devices`,
213-
)
209+
console.log(`📤 User ${userId}: Notifying ${enabledDevices.length} device(s)`)
214210

215211
// Create localized payload
216212
let payload = createLocalizedNotificationPayload(userId, notificationSettings)

src/server/features/push-shared.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,7 @@ async function sendNotificationToDevice(
8181
device: PushDevice,
8282
payload: NotificationPayload,
8383
): Promise<SendResult> {
84-
console.log("[Push] Sending to endpoint:", device.endpoint.slice(-20))
85-
console.log(
86-
"[Push] Using VAPID public key:",
87-
PUBLIC_VAPID_KEY.slice(0, 20) + "...",
88-
)
84+
console.log(`📤 Sending to: ${device.endpoint.slice(-20)}`)
8985

9086
let result = await tryCatch(
9187
webpush.sendNotification(

0 commit comments

Comments
 (0)