From e87a1eac69a117e92a9a2a5d55a4104259157140 Mon Sep 17 00:00:00 2001 From: Olivier 'reivilibre Date: Sat, 3 Feb 2024 11:27:23 +0000 Subject: [PATCH] Apply invite target filtering at the source, before role trumps This is because the speakers room should not have devroom managers --- src/Conference.ts | 5 ++--- src/commands/AttendanceCommand.ts | 2 +- src/commands/DevCommand.ts | 2 +- src/commands/InviteCommand.ts | 7 +++---- src/commands/VerifyCommand.ts | 2 +- src/commands/actions/people.ts | 4 ++-- 6 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/Conference.ts b/src/Conference.ts index f1d17062..5d5db102 100644 --- a/src/Conference.ts +++ b/src/Conference.ts @@ -747,14 +747,13 @@ export class Conference { return []; } - public async getInviteTargetsForAuditorium(auditorium: Auditorium, backstage = false): Promise { + public async getInviteTargetsForAuditorium(auditorium: Auditorium, roles = [Role.Coordinator, Role.Host, Role.Speaker]): Promise { const people = await this.getPeopleForAuditorium(auditorium); - const roles = [Role.Coordinator, Role.Host, Role.Speaker]; // HACK dedupe people by name. const namesToPersons: Map = new Map(); - let shouldWritePerson = (person) => { + let shouldWritePerson = (person: IPerson) => { // ignore unknown roles if (! roles.includes(person.role)) return false; diff --git a/src/commands/AttendanceCommand.ts b/src/commands/AttendanceCommand.ts index 7d2badc9..f79a0f42 100644 --- a/src/commands/AttendanceCommand.ts +++ b/src/commands/AttendanceCommand.ts @@ -88,7 +88,7 @@ export class AttendanceCommand implements ICommand { const doAppend = !!targetAudId && (targetAudId === "all" || targetAudId === await auditorium.getId()); const bs = this.conference.getAuditoriumBackstage(await auditorium.getId()); const inviteTargets = await this.conference.getInviteTargetsForAuditorium(auditorium); - const bsInviteTargets = await this.conference.getInviteTargetsForAuditorium(auditorium, true); + const bsInviteTargets = await this.conference.getInviteTargetsForAuditorium(auditorium); try { await append(inviteTargets, bsInviteTargets, await auditorium.getId(), auditorium.roomId, bs.roomId, doAppend); } diff --git a/src/commands/DevCommand.ts b/src/commands/DevCommand.ts index 208ab658..053f7366 100644 --- a/src/commands/DevCommand.ts +++ b/src/commands/DevCommand.ts @@ -27,7 +27,7 @@ export class DevCommand implements ICommand { public async run(roomId: string, event: any, args: string[]) { let people: IPerson[] = []; for (const aud of this.conference.storedAuditoriums) { - const inviteTargets = await this.conference.getInviteTargetsForAuditorium(aud, true); + const inviteTargets = await this.conference.getInviteTargetsForAuditorium(aud); people.push(...inviteTargets.filter(i => i.role === Role.Coordinator)); } const newPeople: IPerson[] = []; diff --git a/src/commands/InviteCommand.ts b/src/commands/InviteCommand.ts index 37b5617c..fe76848d 100644 --- a/src/commands/InviteCommand.ts +++ b/src/commands/InviteCommand.ts @@ -54,9 +54,8 @@ export class InviteCommand implements ICommand { if (args[0] && args[0] === "speakers-support") { let people: IPerson[] = []; for (const aud of this.conference.storedAuditoriumBackstages) { - people.push(...await this.conference.getInviteTargetsForAuditorium(aud, true)); + people.push(...await this.conference.getInviteTargetsForAuditorium(aud, [Role.Speaker])); } - people = people.filter(p => p.role === Role.Speaker); const newPeople: IPerson[] = []; people.forEach(p => { if (!newPeople.some(n => n.id === p.id)) { @@ -75,8 +74,8 @@ export class InviteCommand implements ICommand { // continue; // } - const inviteTargets = await this.conference.getInviteTargetsForAuditorium(aud, true); - people.push(...inviteTargets.filter(i => i.role === Role.Coordinator)); + const inviteTargets = await this.conference.getInviteTargetsForAuditorium(aud, [Role.Coordinator]); + people.push(...inviteTargets); } const newPeople: IPerson[] = []; people.forEach(p => { diff --git a/src/commands/VerifyCommand.ts b/src/commands/VerifyCommand.ts index 9ee0cdd4..086d9610 100644 --- a/src/commands/VerifyCommand.ts +++ b/src/commands/VerifyCommand.ts @@ -68,7 +68,7 @@ export class VerifyCommand implements ICommand { if (aud instanceof Auditorium) { audToInvite = await this.conference.getInviteTargetsForAuditorium(aud); - audBackstageToInvite = await this.conference.getInviteTargetsForAuditorium(aud, true); + audBackstageToInvite = await this.conference.getInviteTargetsForAuditorium(aud); audToMod = await this.conference.getModeratorsForAuditorium(aud); } else if (aud instanceof InterestRoom) { audToInvite = await this.conference.getInviteTargetsForInterest(aud); diff --git a/src/commands/actions/people.ts b/src/commands/actions/people.ts index 0542fe37..3244dd9f 100644 --- a/src/commands/actions/people.ts +++ b/src/commands/actions/people.ts @@ -40,7 +40,7 @@ export async function doAuditoriumResolveAction( // We know that everyone should be in the backstage room, so resolve that list of people // to make the identity server lookup efficient. const backstagePeople = isInvite - ? await conference.getInviteTargetsForAuditorium(aud, true) + ? await conference.getInviteTargetsForAuditorium(aud) : await conference.getModeratorsForAuditorium(aud); LogService.info("backstagePeople", `${backstagePeople}`); const resolvedBackstagePeople = await resolveIdentifiers(client, backstagePeople); @@ -50,7 +50,7 @@ export async function doAuditoriumResolveAction( const allPossiblePeople = isInvite ? resolvedBackstagePeople - : await resolveIdentifiers(client, await conference.getInviteTargetsForAuditorium(aud, true)); + : await resolveIdentifiers(client, await conference.getInviteTargetsForAuditorium(aud)); await action(client, backstage.roomId, resolvedBackstagePeople);