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

Make the default invite command include support rooms #242

Merged
merged 1 commit into from
Jan 15, 2025
Merged
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
91 changes: 55 additions & 36 deletions src/commands/InviteCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,51 @@ export class InviteCommand implements ICommand {
await this.ensureInvited(targetRoomId, resolved);
}

private async runSpeakersSupport(): Promise<void> {
let people: IPerson[] = [];
for (const aud of this.conference.storedAuditoriumBackstages) {
people.push(...await this.conference.getInviteTargetsForAuditorium(aud, [Role.Speaker]));
}
const newPeople: IPerson[] = [];
people.forEach(p => {
if (!newPeople.some(n => n.id === p.id)) {
newPeople.push(p);
}
});
await this.createInvites(newPeople, this.config.conference.supportRooms.speakers);
}

private async runCoordinatorsSupport(): Promise<void> {
let people: IPerson[] = [];
for (const aud of this.conference.storedAuditoriums) {
// This hack was not wanted in 2023 or 2024.
// if (!(await aud.getId()).startsWith("D.")) {
// HACK: Only invite coordinators for D.* auditoriums.
// TODO: Make invitations for support rooms more configurable.
// https://github.com/matrix-org/this.conference-bot/issues/76
// continue;
// }

const inviteTargets = await this.conference.getInviteTargetsForAuditorium(aud, [Role.Coordinator]);
people.push(...inviteTargets);
}
const newPeople: IPerson[] = [];
people.forEach(p => {
if (!newPeople.some(n => n.id == p.id)) {
newPeople.push(p);
}
});
await this.createInvites(newPeople, this.config.conference.supportRooms.coordinators);
}

private async runSpecialInterestSupport(): Promise<void> {
const people: IPerson[] = [];
for (const sir of this.conference.storedInterestRooms) {
people.push(...await this.conference.getInviteTargetsForInterest(sir));
}
await this.createInvites(people, this.config.conference.supportRooms.specialInterest);
}

public async run(managementRoomId: string, event: any, args: string[]) {
await this.client.replyNotice(managementRoomId, event, "Sending invites to participants. This might take a while.");

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

if (args[0] && args[0] === "speakers-support") {
let people: IPerson[] = [];
for (const aud of this.conference.storedAuditoriumBackstages) {
people.push(...await this.conference.getInviteTargetsForAuditorium(aud, [Role.Speaker]));
}
const newPeople: IPerson[] = [];
people.forEach(p => {
if (!newPeople.some(n => n.id === p.id)) {
newPeople.push(p);
}
});
await this.createInvites(newPeople, this.config.conference.supportRooms.speakers);
await this.runSpeakersSupport();
} else if (args[0] && args[0] === "coordinators-support") {
let people: IPerson[] = [];
for (const aud of this.conference.storedAuditoriums) {
// This hack was not wanted in 2023 or 2024.
// if (!(await aud.getId()).startsWith("D.")) {
// HACK: Only invite coordinators for D.* auditoriums.
// TODO: Make invitations for support rooms more configurable.
// https://github.com/matrix-org/this.conference-bot/issues/76
// continue;
// }

const inviteTargets = await this.conference.getInviteTargetsForAuditorium(aud, [Role.Coordinator]);
people.push(...inviteTargets);
}
const newPeople: IPerson[] = [];
people.forEach(p => {
if (!newPeople.some(n => n.id == p.id)) {
newPeople.push(p);
}
});
await this.createInvites(newPeople, this.config.conference.supportRooms.coordinators);
await this.runCoordinatorsSupport();
} else if (args[0] && args[0] === "si-support") {
const people: IPerson[] = [];
for (const sir of this.conference.storedInterestRooms) {
people.push(...await this.conference.getInviteTargetsForInterest(sir));
}
await this.createInvites(people, this.config.conference.supportRooms.specialInterest);
await this.runSpecialInterestSupport();
} else {
await runRoleCommand((_client, room, people) => this.ensureInvited(room, people), this.conference, this.client, managementRoomId, event, args);

if (args.length === 0) {
// If no specific rooms are requested, then also handle invites to all support rooms.
await this.runSpeakersSupport();
await this.runCoordinatorsSupport();
await this.runSpecialInterestSupport();
}
}

await this.client.sendNotice(managementRoomId, "Invites sent!");
Expand Down
Loading