Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

For support room invites, fix multiple-role people not being invited #231

Merged
merged 2 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading