button zum prüfen
This commit is contained in:
@@ -98,6 +98,16 @@ async function sendSlotNotification({ profileId, storeName, pickupDate, onlyNoti
|
||||
});
|
||||
}
|
||||
|
||||
function formatStoreWatchStatus(status) {
|
||||
if (status === 1) {
|
||||
return 'Suchend';
|
||||
}
|
||||
if (status === 0) {
|
||||
return 'Nicht suchend';
|
||||
}
|
||||
return 'Status unbekannt';
|
||||
}
|
||||
|
||||
async function sendStoreWatchNotification({ profileId, storeName, storeId, regionName }) {
|
||||
const storeLink = storeId ? `https://foodsharing.de/store/${storeId}` : null;
|
||||
const title = `Team sucht Verstärkung: ${storeName}`;
|
||||
@@ -112,6 +122,33 @@ async function sendStoreWatchNotification({ profileId, storeName, storeId, regio
|
||||
});
|
||||
}
|
||||
|
||||
async function sendStoreWatchSummaryNotification({ profileId, entries = [], triggeredBy = 'manual' }) {
|
||||
if (!profileId || !Array.isArray(entries) || entries.length === 0) {
|
||||
return;
|
||||
}
|
||||
const lines = entries
|
||||
.map((entry) => {
|
||||
const regionSuffix = entry.regionName ? ` (${entry.regionName})` : '';
|
||||
const statusLabel = formatStoreWatchStatus(entry.status);
|
||||
const timestamp = entry.checkedAt ? ` – Stand ${formatDateLabel(entry.checkedAt)}` : '';
|
||||
const errorLabel = entry.error ? ` – Fehler: ${entry.error}` : '';
|
||||
return `• ${entry.storeName || `Store ${entry.storeId}`}${regionSuffix}: ${statusLabel}${timestamp}${errorLabel}`;
|
||||
})
|
||||
.join('\n');
|
||||
const prefix =
|
||||
triggeredBy === 'manual'
|
||||
? 'Manuell angestoßene Store-Watch-Prüfung abgeschlossen:'
|
||||
: 'Store-Watch-Prüfung abgeschlossen:';
|
||||
const title =
|
||||
triggeredBy === 'manual' ? 'Ad-hoc Store-Watch-Prüfung' : 'Store-Watch-Prüfung';
|
||||
const message = `${prefix}\n${lines}`;
|
||||
await notifyChannels(profileId, {
|
||||
title,
|
||||
message,
|
||||
priority: 'default'
|
||||
});
|
||||
}
|
||||
|
||||
async function sendDesiredWindowMissedNotification({ profileId, storeName, desiredWindowLabel }) {
|
||||
if (!profileId) {
|
||||
return;
|
||||
@@ -165,6 +202,7 @@ async function sendTestNotification(profileId, channel) {
|
||||
module.exports = {
|
||||
sendSlotNotification,
|
||||
sendStoreWatchNotification,
|
||||
sendStoreWatchSummaryNotification,
|
||||
sendTestNotification,
|
||||
sendDesiredWindowMissedNotification
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user