Enhance Service Messages by Config & activeUntil #9

This commit is contained in:
nocnico
2025-07-03 19:26:17 +02:00
parent e137b0c75e
commit ffe0d45ab6
9 changed files with 159 additions and 78 deletions

View File

@@ -3,19 +3,23 @@ import { prisma, Prisma } from "@repo/db";
export const addMessage = async (message: Prisma.NotamCreateInput) => {
try {
// Set all current messages with isMainMsg=true to active=false
await prisma.notam.updateMany({
where: { isMainMsg: true },
where: { active: true },
data: { active: false },
});
const showUntil = new Date(message.showUntil);
const showUntilActive = showUntil > new Date();
await prisma.notam.create({
data: {
message: message.message,
color: message.color,
isMainMsg: true,
active: true,
showUntil: new Date().toISOString(),
wartungsmodus: message.wartungsmodus,
disableHPG: message.disableHPG,
showUntilActive,
showUntil,
},
});
} catch (error) {
@@ -25,9 +29,8 @@ export const addMessage = async (message: Prisma.NotamCreateInput) => {
export const disableMessage = async () => {
try {
// Set all current messages with isMainMsg=true to active=false
await prisma.notam.updateMany({
where: { isMainMsg: true },
where: { active: true },
data: { active: false },
});
} catch (error) {