aktueller stand

This commit is contained in:
2025-12-29 19:51:45 +01:00
parent f4323e20de
commit 41ef5107aa
9 changed files with 438 additions and 98 deletions

View File

@@ -62,6 +62,19 @@ async function sendTelegramNotification(adminTelegram, userTelegram, payload) {
);
}
async function sendAdminTelegramNotification(payload) {
const adminSettings = adminConfig.readSettings();
const adminTelegram = adminSettings.notifications?.telegram;
if (!adminTelegram?.enabled || !adminTelegram.botToken || !adminTelegram.chatId) {
return;
}
await sendTelegramNotification(
adminTelegram,
{ enabled: true, chatId: adminTelegram.chatId },
payload
);
}
async function notifyChannels(profileId, template) {
const adminSettings = adminConfig.readSettings();
const userSettings = readNotificationSettings(profileId);
@@ -217,11 +230,32 @@ async function sendDormantPickupWarning({ profileId, storeName, storeId, reasonL
});
}
async function sendAdminBookingErrorNotification({ profileId, profileEmail, storeName, storeId, pickupDate, error }) {
const dateLabel = formatDateLabel(pickupDate);
const storeLabel = storeName || storeId || 'Unbekannter Store';
const storeLink = storeId ? `https://foodsharing.de/store/${storeId}` : null;
const profileLabel = profileEmail || profileId || 'Unbekanntes Profil';
const messageLines = [
`Buchung fehlgeschlagen für ${storeLabel} am ${dateLabel}.`,
`Profil: ${profileLabel}.`,
`Fehler: ${error || 'Unbekannter Fehler'}.`
];
if (storeLink) {
messageLines.push(storeLink);
}
await sendAdminTelegramNotification({
title: 'Fehler beim Slot-Buchen',
message: messageLines.join('\n'),
priority: 'high'
});
}
module.exports = {
sendSlotNotification,
sendStoreWatchNotification,
sendStoreWatchSummaryNotification,
sendTestNotification,
sendDesiredWindowMissedNotification,
sendDormantPickupWarning
sendDormantPickupWarning,
sendAdminBookingErrorNotification
};