fix: multi device lost notifications
Some checks failed
/ build (map[dockerfile:./services/api/Dockerfile name:api]) (push) Successful in 1m28s
/ build (map[dockerfile:./services/app/Dockerfile name:app]) (push) Successful in 1m45s
/ build (map[dockerfile:./services/files/Dockerfile name:files]) (push) Successful in 1m55s
/ build (map[dockerfile:./services/watchers/Dockerfile name:watchers]) (push) Successful in 2m10s
/ build (map[dockerfile:./services/tasks/Dockerfile name:tasks]) (push) Successful in 2m18s
/ build (map[dockerfile:./services/hasura/Dockerfile name:hasura]) (push) Successful in 2m20s
/ build (map[dockerfile:./services/web/Dockerfile name:web]) (push) Failing after 12m45s
/ deploy (push) Has been cancelled

This commit is contained in:
Jo 2025-08-24 13:01:30 +02:00
parent 1cc35a57c9
commit 74e1b5f10b
Signed by: devthejo
GPG key ID: 00CCA7A92B1D5351

View file

@ -134,34 +134,17 @@ module.exports = async function () {
const { reason, alertId, userId: alertingUserId } = alertingRow
logger.debug({ reason, alertId, alertingUserId }, "Found alerting record")
let devicesList
if (reason === "relative") {
logger.debug({ alertingUserId }, "Querying device record for user")
devicesList = await sql`
SELECT
"id",
"fcm_token" as "fcmToken",
"notification_alert_level" as "notificationAlertLevel"
FROM
"device"
WHERE
"user_id" = ${alertingUserId}
AND "fcm_token" IS NOT NULL
`
} else {
const { deviceId } = alertingRow
logger.debug({ deviceId }, "Querying device record")
devicesList = await sql`
SELECT
"fcm_token" as "fcmToken",
"notification_alert_level" as "notificationAlertLevel"
FROM
"device"
WHERE
"user_id" = ${alertingUserId}
AND "fcm_token" IS NOT NULL
`
}
const devicesList = await sql`
SELECT
"id",
"fcm_token" as "fcmToken",
"notification_alert_level" as "notificationAlertLevel"
FROM
"device"
WHERE
"user_id" = ${alertingUserId}
AND "fcm_token" IS NOT NULL
`
const devices = devicesList.map((device) => ({ ...device }))
logger.debug({ alertId }, "Querying alert record")