fix: leave blank participant names out of saved events

This commit is contained in:
Linus Rath
2026-10-29 03:27:44 +01:00
parent 0fb7c8cd09
commit 59c3278259
2 changed files with 17 additions and 2 deletions
@@ -349,6 +349,17 @@ describe('answers on save (Stalwart 0.16 and 1.0)', () => {
]);
});
it('writes no blank names', () => {
const map = buildParticipantMap({ name: '', email: 'me@example.com' }, [
{ name: ' ', email: 'bob@example.com' },
{ name: ' Carol ', email: 'carol@example.com' },
]);
const byEmail = Object.fromEntries(Object.values(map).map((p) => [p.email, p]));
expect(byEmail['me@example.com']).not.toHaveProperty('name');
expect(byEmail['bob@example.com']).not.toHaveProperty('name');
expect(byEmail['carol@example.com'].name).toBe('Carol');
});
it('tells whether anyone but the organizer answered', () => {
expect(hasAnsweredAttendees(meeting.participants)).toBe(true);
expect(hasAnsweredAttendees(participantsAskedAgain(meeting))).toBe(false);
+6 -2
View File
@@ -355,9 +355,12 @@ export function buildParticipantMap(
// stored as an inert JSPROP, so it is intentionally not sent.
const organizerKey = organizer.email.trim().toLowerCase();
const organizerStatus = known.get(organizerKey)?.status;
// A blank name is left out: written, it reaches the attendees' copies as
// an empty CN.
const organizerName = organizer.name?.trim();
participants[idFor(organizerKey)] = {
'@type': 'Participant',
name: organizer.name,
...(organizerName ? { name: organizerName } : {}),
email: organizer.email,
calendarAddress: `mailto:${organizer.email}`,
// owner only, NOT attendee: with roles.attendee set, Stalwart's server-side
@@ -380,9 +383,10 @@ export function buildParticipantMap(
if (!key || seen.has(key)) return;
seen.add(key);
const name = a.name?.trim();
participants[idFor(key)] = {
'@type': 'Participant',
name: a.name,
...(name ? { name } : {}),
email,
calendarAddress: `mailto:${email}`,
roles: { attendee: true },