aktueller stand
This commit is contained in:
@@ -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
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user