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({
|
||||
tenantId,
|
||||
userId: profile.userId,
|
||||
eventType: "system.test_push",
|
||||
title: "FEDEO Push ist aktiv",
|
||||
message: "Diese Testbenachrichtigung wurde einmalig über das Mitarbeiterprofil ausgelöst.",
|
||||
payload: {
|
||||
link: "/",
|
||||
icon: "/favicon.ico",
|
||||
},
|
||||
channels: ["push"],
|
||||
})
|
||||
const devices = await server.db
|
||||
.select({ centralDeviceId: notificationMobilePushDevices.centralDeviceId })
|
||||
.from(notificationMobilePushDevices)
|
||||
.where(and(
|
||||
eq(notificationMobilePushDevices.tenantId, tenantId),
|
||||
eq(notificationMobilePushDevices.userId, profile.userId),
|
||||
isNull(notificationMobilePushDevices.disabledAt)
|
||||
))
|
||||
|
||||
if (result.created === 0) {
|
||||
if (!devices.length) {
|
||||
return reply.code(409).send({
|
||||
error: "Pushnachrichten sind für diesen Mitarbeiter deaktiviert",
|
||||
result,
|
||||
error: "Für diesen Mitarbeiter ist kein aktives mobiles Push-Gerät registriert",
|
||||
})
|
||||
}
|
||||
|
||||
if (!result.success || result.delivered === 0) {
|
||||
return reply.code(424).send({
|
||||
error: "Die Pushnachricht konnte an kein aktives Gerät zugestellt werden",
|
||||
result,
|
||||
try {
|
||||
const result = await pushServerClient.sendPush({
|
||||
idempotencyKey: `profile-mobile-test:${tenantId}:${profile.userId}:${Date.now()}`,
|
||||
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) => {
|
||||
|
||||
@@ -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: {
|
||||
navigateFallback: '/',
|
||||
navigateFallback: null,
|
||||
},
|
||||
|
||||
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="mt-1 text-sm text-gray-500">
|
||||
<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 v-else>
|
||||
Für einen Push-Test muss der Mitarbeiter zuerst mit einem Benutzerkonto verknüpft werden.
|
||||
|
||||
Reference in New Issue
Block a user