Benachrichtigungen erweitert
Emails korrigiert
This commit is contained in:
@@ -276,12 +276,23 @@ function parseBirthday(value) {
|
||||
return null
|
||||
}
|
||||
|
||||
function hasBirthdayNotificationConsent(person) {
|
||||
return person?.visibility?.showBirthday === true || person?.showBirthday === true
|
||||
}
|
||||
|
||||
function formatBirthdaySummary(names) {
|
||||
const visibleNames = names.map(name => String(name || '').trim()).filter(Boolean)
|
||||
if (visibleNames.length === 1) return `${visibleNames[0]} hat heute Geburtstag.`
|
||||
return `Geburtstage heute: ${visibleNames.slice(0, 5).join(', ')}${visibleNames.length > 5 ? ` und ${visibleNames.length - 5} weitere` : ''}.`
|
||||
}
|
||||
|
||||
async function birthdaysOn(dateKey) {
|
||||
const [, month, day] = dateKey.split('-').map(Number)
|
||||
const [manualMembers, users] = await Promise.all([readMembers(), readUsers()])
|
||||
const people = []
|
||||
for (const member of manualMembers) {
|
||||
if (member?.active === false) continue
|
||||
if (!hasBirthdayNotificationConsent(member)) continue
|
||||
const birthday = parseBirthday(member.geburtsdatum || member.birthday)
|
||||
if (birthday?.month === month && birthday?.day === day) {
|
||||
people.push(String(member.name || `${member.firstName || ''} ${member.lastName || ''}`.trim()).trim())
|
||||
@@ -289,7 +300,7 @@ async function birthdaysOn(dateKey) {
|
||||
}
|
||||
for (const user of users) {
|
||||
if (isHiddenUser(user) || user?.active === false) continue
|
||||
if (user.visibility?.showBirthday === false) continue
|
||||
if (!hasBirthdayNotificationConsent(user)) continue
|
||||
const birthday = parseBirthday(user.geburtsdatum || user.birthday)
|
||||
if (birthday?.month === month && birthday?.day === day) {
|
||||
people.push(userDisplayName(user))
|
||||
@@ -397,7 +408,7 @@ export async function runNotificationSchedulerTick(now = new Date()) {
|
||||
|
||||
results.birthdays = await sendIfDue(state, dateKey, time, 'birthdays', todaysBirthdays.length > 0, () => sendPushToUsers({
|
||||
title: 'Geburtstage heute',
|
||||
body: todaysBirthdays.length === 1 ? `${todaysBirthdays[0]} hat heute Geburtstag.` : `${todaysBirthdays.length} Mitglieder haben heute Geburtstag.`,
|
||||
body: formatBirthdaySummary(todaysBirthdays),
|
||||
data: { type: 'birthdays', date: dateKey },
|
||||
predicate: (_user, settings) => settings.notificationTime === time && settings.birthdays,
|
||||
failureLabel: 'FCM Geburtstags-Push'
|
||||
|
||||
Reference in New Issue
Block a user