Skip to content

Commit

Permalink
Apply invite target filtering at the source, before role trumps
Browse files Browse the repository at this point in the history
This is because the speakers room should not have devroom managers
  • Loading branch information
reivilibre committed Feb 4, 2024
1 parent cd1fe40 commit e87a1ea
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 12 deletions.
5 changes: 2 additions & 3 deletions src/Conference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -747,14 +747,13 @@ export class Conference {
return [];
}

public async getInviteTargetsForAuditorium(auditorium: Auditorium, backstage = false): Promise<IPerson[]> {
public async getInviteTargetsForAuditorium(auditorium: Auditorium, roles = [Role.Coordinator, Role.Host, Role.Speaker]): Promise<IPerson[]> {
const people = await this.getPeopleForAuditorium(auditorium);
const roles = [Role.Coordinator, Role.Host, Role.Speaker];

// HACK dedupe people by name.
const namesToPersons: Map<string, IPerson> = new Map();

let shouldWritePerson = (person) => {
let shouldWritePerson = (person: IPerson) => {
// ignore unknown roles
if (! roles.includes(person.role)) return false;

Expand Down
2 changes: 1 addition & 1 deletion src/commands/AttendanceCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/commands/DevCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = [];
Expand Down
7 changes: 3 additions & 4 deletions src/commands/InviteCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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 => {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/VerifyCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/commands/actions/people.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);

Expand Down

0 comments on commit e87a1ea

Please sign in to comment.