Journal für abholungen

This commit is contained in:
2026-01-04 01:37:36 +01:00
parent 1c12bf6bd1
commit 8b0326bac9
8 changed files with 1501 additions and 3 deletions

View File

@@ -21,6 +21,22 @@ function formatDateLabel(dateInput) {
}
}
function formatDateOnly(dateInput) {
try {
const date = new Date(dateInput);
if (Number.isNaN(date.getTime())) {
return 'unbekanntes Datum';
}
return date.toLocaleDateString('de-DE', {
day: '2-digit',
month: '2-digit',
year: 'numeric'
});
} catch (_error) {
return 'unbekanntes Datum';
}
}
async function sendNtfyNotification(adminNtfy, userNtfy, payload) {
if (!adminNtfy?.enabled || !userNtfy?.enabled || !userNtfy.topic) {
return;
@@ -230,6 +246,34 @@ async function sendDormantPickupWarning({ profileId, storeName, storeId, reasonL
});
}
async function sendJournalReminderNotification({
profileId,
storeName,
pickupDate,
reminderDate,
note
}) {
if (!profileId) {
return;
}
const adminSettings = adminConfig.readSettings();
const userSettings = readNotificationSettings(profileId);
const title = `Erinnerung: Abholung bei ${storeName}`;
const reminderLabel = formatDateOnly(reminderDate);
const pickupLabel = formatDateOnly(pickupDate);
const noteLine = note ? `Notiz: ${note}` : null;
const messageLines = [
`Geplante Abholung: ${pickupLabel}`,
`Erinnerungstermin: ${reminderLabel}`,
noteLine
].filter(Boolean);
await sendTelegramNotification(adminSettings.notifications?.telegram, userSettings.notifications?.telegram, {
title,
message: messageLines.join('\n'),
priority: 'default'
});
}
async function sendAdminBookingErrorNotification({ profileId, profileEmail, storeName, storeId, pickupDate, error }) {
const dateLabel = formatDateLabel(pickupDate);
const storeLabel = storeName || storeId || 'Unbekannter Store';
@@ -257,5 +301,6 @@ module.exports = {
sendTestNotification,
sendDesiredWindowMissedNotification,
sendDormantPickupWarning,
sendJournalReminderNotification,
sendAdminBookingErrorNotification
};