Skip to content

Commit

Permalink
For support room invites, fix multiple-role people not being invited (#…
Browse files Browse the repository at this point in the history
…231)

* HACK Coordinator role trumps Speaker role

* Apply invite target filtering at the source, before role trumps

This is because the speakers room should not have devroom managers
  • Loading branch information
reivilibre committed Jun 3, 2024
1 parent b91e633 commit 340b81a
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 22 deletions.
35 changes: 22 additions & 13 deletions src/Conference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -747,24 +747,33 @@ 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];
let includesPerson = (person, array) => {
for (const element of array) {
if (element.name === person.name) {
return true
}
}
return false

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

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

if (! namesToPersons.has(person.name)) return true;

// (TODO HACK we should figure out a nicer way of doing this, like directly tracking multiple roles for people)
// overwrite the previous person entry if this person is a coordinator
// (coordinator role is more important than speaker)
if (person.role == Role.Coordinator) return true;

return false;
};
let uniquePeople: IPerson[] = []

for (const person of people) {
if (!includesPerson(person, uniquePeople)) {
uniquePeople.push(person)
if (shouldWritePerson(person)) {
namesToPersons.set(person.name, person);
}
}
return uniquePeople.filter(p => roles.includes(p.role));

return Array.from(namesToPersons.values());
}

public async getInviteTargetsForTalk(talk: Talk): Promise<IPerson[]> {
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 340b81a

Please sign in to comment.