Skip to content

Commit ffcb1ba

Browse files
authored
Make the default invite command include support rooms (#242)
1 parent 9d3d191 commit ffcb1ba

File tree

1 file changed

+55
-36
lines changed

1 file changed

+55
-36
lines changed

src/commands/InviteCommand.ts

Lines changed: 55 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,51 @@ export class InviteCommand implements ICommand {
4343
await this.ensureInvited(targetRoomId, resolved);
4444
}
4545

46+
private async runSpeakersSupport(): Promise<void> {
47+
let people: IPerson[] = [];
48+
for (const aud of this.conference.storedAuditoriumBackstages) {
49+
people.push(...await this.conference.getInviteTargetsForAuditorium(aud, [Role.Speaker]));
50+
}
51+
const newPeople: IPerson[] = [];
52+
people.forEach(p => {
53+
if (!newPeople.some(n => n.id === p.id)) {
54+
newPeople.push(p);
55+
}
56+
});
57+
await this.createInvites(newPeople, this.config.conference.supportRooms.speakers);
58+
}
59+
60+
private async runCoordinatorsSupport(): Promise<void> {
61+
let people: IPerson[] = [];
62+
for (const aud of this.conference.storedAuditoriums) {
63+
// This hack was not wanted in 2023 or 2024.
64+
// if (!(await aud.getId()).startsWith("D.")) {
65+
// HACK: Only invite coordinators for D.* auditoriums.
66+
// TODO: Make invitations for support rooms more configurable.
67+
// https://github.com/matrix-org/this.conference-bot/issues/76
68+
// continue;
69+
// }
70+
71+
const inviteTargets = await this.conference.getInviteTargetsForAuditorium(aud, [Role.Coordinator]);
72+
people.push(...inviteTargets);
73+
}
74+
const newPeople: IPerson[] = [];
75+
people.forEach(p => {
76+
if (!newPeople.some(n => n.id == p.id)) {
77+
newPeople.push(p);
78+
}
79+
});
80+
await this.createInvites(newPeople, this.config.conference.supportRooms.coordinators);
81+
}
82+
83+
private async runSpecialInterestSupport(): Promise<void> {
84+
const people: IPerson[] = [];
85+
for (const sir of this.conference.storedInterestRooms) {
86+
people.push(...await this.conference.getInviteTargetsForInterest(sir));
87+
}
88+
await this.createInvites(people, this.config.conference.supportRooms.specialInterest);
89+
}
90+
4691
public async run(managementRoomId: string, event: any, args: string[]) {
4792
await this.client.replyNotice(managementRoomId, event, "Sending invites to participants. This might take a while.");
4893

@@ -52,46 +97,20 @@ export class InviteCommand implements ICommand {
5297
// that a subset of people are joined.
5398

5499
if (args[0] && args[0] === "speakers-support") {
55-
let people: IPerson[] = [];
56-
for (const aud of this.conference.storedAuditoriumBackstages) {
57-
people.push(...await this.conference.getInviteTargetsForAuditorium(aud, [Role.Speaker]));
58-
}
59-
const newPeople: IPerson[] = [];
60-
people.forEach(p => {
61-
if (!newPeople.some(n => n.id === p.id)) {
62-
newPeople.push(p);
63-
}
64-
});
65-
await this.createInvites(newPeople, this.config.conference.supportRooms.speakers);
100+
await this.runSpeakersSupport();
66101
} else if (args[0] && args[0] === "coordinators-support") {
67-
let people: IPerson[] = [];
68-
for (const aud of this.conference.storedAuditoriums) {
69-
// This hack was not wanted in 2023 or 2024.
70-
// if (!(await aud.getId()).startsWith("D.")) {
71-
// HACK: Only invite coordinators for D.* auditoriums.
72-
// TODO: Make invitations for support rooms more configurable.
73-
// https://github.com/matrix-org/this.conference-bot/issues/76
74-
// continue;
75-
// }
76-
77-
const inviteTargets = await this.conference.getInviteTargetsForAuditorium(aud, [Role.Coordinator]);
78-
people.push(...inviteTargets);
79-
}
80-
const newPeople: IPerson[] = [];
81-
people.forEach(p => {
82-
if (!newPeople.some(n => n.id == p.id)) {
83-
newPeople.push(p);
84-
}
85-
});
86-
await this.createInvites(newPeople, this.config.conference.supportRooms.coordinators);
102+
await this.runCoordinatorsSupport();
87103
} else if (args[0] && args[0] === "si-support") {
88-
const people: IPerson[] = [];
89-
for (const sir of this.conference.storedInterestRooms) {
90-
people.push(...await this.conference.getInviteTargetsForInterest(sir));
91-
}
92-
await this.createInvites(people, this.config.conference.supportRooms.specialInterest);
104+
await this.runSpecialInterestSupport();
93105
} else {
94106
await runRoleCommand((_client, room, people) => this.ensureInvited(room, people), this.conference, this.client, managementRoomId, event, args);
107+
108+
if (args.length === 0) {
109+
// If no specific rooms are requested, then also handle invites to all support rooms.
110+
await this.runSpeakersSupport();
111+
await this.runCoordinatorsSupport();
112+
await this.runSpecialInterestSupport();
113+
}
95114
}
96115

97116
await this.client.sendNotice(managementRoomId, "Invites sent!");

0 commit comments

Comments
 (0)