fix: send employee test push via mobile service
All checks were successful
Build and Push Docker Images / build-backend (push) Successful in 43s
Build and Push Docker Images / build-website (push) Successful in 23s
Build and Push Docker Images / build-central-services-admin (push) Successful in 23s
Build and Push Docker Images / build-frontend (push) Successful in 1m12s
Build and Push Docker Images / build-central-services-api (push) Successful in 22s
Build and Push Docker Images / build-docs (push) Successful in 22s
All checks were successful
Build and Push Docker Images / build-backend (push) Successful in 43s
Build and Push Docker Images / build-website (push) Successful in 23s
Build and Push Docker Images / build-central-services-admin (push) Successful in 23s
Build and Push Docker Images / build-frontend (push) Successful in 1m12s
Build and Push Docker Images / build-central-services-api (push) Successful in 22s
Build and Push Docker Images / build-docs (push) Successful in 22s
This commit is contained in:
@@ -198,34 +198,51 @@ export default async function notificationsRoutes(server: FastifyInstance) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await svc.trigger({
|
const devices = await server.db
|
||||||
tenantId,
|
.select({ centralDeviceId: notificationMobilePushDevices.centralDeviceId })
|
||||||
userId: profile.userId,
|
.from(notificationMobilePushDevices)
|
||||||
eventType: "system.test_push",
|
.where(and(
|
||||||
title: "FEDEO Push ist aktiv",
|
eq(notificationMobilePushDevices.tenantId, tenantId),
|
||||||
message: "Diese Testbenachrichtigung wurde einmalig über das Mitarbeiterprofil ausgelöst.",
|
eq(notificationMobilePushDevices.userId, profile.userId),
|
||||||
payload: {
|
isNull(notificationMobilePushDevices.disabledAt)
|
||||||
link: "/",
|
))
|
||||||
icon: "/favicon.ico",
|
|
||||||
},
|
|
||||||
channels: ["push"],
|
|
||||||
})
|
|
||||||
|
|
||||||
if (result.created === 0) {
|
if (!devices.length) {
|
||||||
return reply.code(409).send({
|
return reply.code(409).send({
|
||||||
error: "Pushnachrichten sind für diesen Mitarbeiter deaktiviert",
|
error: "Für diesen Mitarbeiter ist kein aktives mobiles Push-Gerät registriert",
|
||||||
result,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!result.success || result.delivered === 0) {
|
try {
|
||||||
return reply.code(424).send({
|
const result = await pushServerClient.sendPush({
|
||||||
error: "Die Pushnachricht konnte an kein aktives Gerät zugestellt werden",
|
idempotencyKey: `profile-mobile-test:${tenantId}:${profile.userId}:${Date.now()}`,
|
||||||
result,
|
devices: devices.map((device) => device.centralDeviceId),
|
||||||
|
priority: "high",
|
||||||
|
ttlSeconds: 600,
|
||||||
|
notification: {
|
||||||
|
title: "FEDEO Push ist aktiv",
|
||||||
|
body: "Diese Testbenachrichtigung wurde einmalig über das Mitarbeiterprofil ausgelöst.",
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
type: "system.test_mobile_push",
|
||||||
|
link: "/",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
if (result.accepted === 0) {
|
||||||
|
return reply.code(502).send({
|
||||||
|
error: "Der zentrale Push-Server hat kein Gerät zur Zustellung angenommen",
|
||||||
|
result,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
|
} catch (error: any) {
|
||||||
|
server.log.error({ err: error, profileId, userId: profile.userId }, "Mitarbeiter-Test-Push fehlgeschlagen")
|
||||||
|
return reply.code(502).send({
|
||||||
|
error: error?.message || "Der zentrale Push-Server konnte die Nachricht nicht annehmen",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
|
||||||
})
|
})
|
||||||
|
|
||||||
server.post("/notifications/trigger", async (req, reply) => {
|
server.post("/notifications/trigger", async (req, reply) => {
|
||||||
|
|||||||
@@ -119,9 +119,10 @@ export default defineNuxtConfig({
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
/* WICHTIG FÜR SAFARI / iOS */
|
// FEDEO wird serverseitig gerendert; es gibt daher keine vorab gecachte
|
||||||
|
// index.html, die Workbox als Navigations-Fallback verwenden könnte.
|
||||||
workbox: {
|
workbox: {
|
||||||
navigateFallback: '/',
|
navigateFallback: null,
|
||||||
},
|
},
|
||||||
|
|
||||||
devOptions: {
|
devOptions: {
|
||||||
|
|||||||
@@ -490,7 +490,7 @@ onMounted(async () => {
|
|||||||
<p class="text-sm font-medium text-gray-900 dark:text-white">Push-Zustellung testen</p>
|
<p class="text-sm font-medium text-gray-900 dark:text-white">Push-Zustellung testen</p>
|
||||||
<p class="mt-1 text-sm text-gray-500">
|
<p class="mt-1 text-sm text-gray-500">
|
||||||
<template v-if="profile.user_id">
|
<template v-if="profile.user_id">
|
||||||
Sendet einmalig eine Testnachricht an alle aktiven Push-Geräte dieses Mitarbeiters.
|
Sendet einmalig eine Testnachricht an alle aktiven mobilen Push-Geräte dieses Mitarbeiters.
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
Für einen Push-Test muss der Mitarbeiter zuerst mit einem Benutzerkonto verknüpft werden.
|
Für einen Push-Test muss der Mitarbeiter zuerst mit einem Benutzerkonto verknüpft werden.
|
||||||
|
|||||||
Reference in New Issue
Block a user