mirror of
https://github.com/bulwarkmail/native.git
synced 2026-11-01 16:05:39 +00:00
fix: leave blank participant names out of saved events
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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 },
|
||||
|
||||
Reference in New Issue
Block a user