Skip to content

Commit f6184cd

Browse files
Add Orchestration room to room attendant spaces
1 parent a3d2480 commit f6184cd

File tree

3 files changed

+34
-12
lines changed

3 files changed

+34
-12
lines changed

data/plan.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ rooms:
209209
name: Orchestration
210210
topic: >-
211211
Ready your batons! The SeaGL 2024 control-center.
212+
inviteAttendants: true
212213
SeaGL2024-Volunteers:
213214
tag: seagl2024-volunteers
214215
name: Volunteers

src/lib/Plan.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export namespace Plan {
1818
control?: boolean;
1919
destroy?: boolean;
2020
intro?: string;
21+
inviteAttendants?: boolean;
2122
moderatorsOnly?: boolean;
2223
name: string;
2324
private?: boolean;

src/modules/Reconciler.ts

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ export default class extends Module {
7676
#scheduledReconcile: Scheduled | undefined;
7777
#scheduledRegroups: Map<Room["id"], Scheduled>;
7878
#sessionGroups: { [id in SessionGroupId]?: ListedSpace };
79+
#sharedWithAttendants: Map<Room["id"], Room>;
7980

8081
public constructor(
8182
patch: Patch,
@@ -90,6 +91,7 @@ export default class extends Module {
9091
this.#roomByTag = new Map();
9192
this.#scheduledRegroups = new Map();
9293
this.#sessionGroups = {};
94+
this.#sharedWithAttendants = new Map();
9395
}
9496

9597
public getPublicParent(child: string): string | undefined {
@@ -479,19 +481,23 @@ export default class extends Module {
479481
}
480482

481483
private async reconcileInvitations(child: Room, parent?: Room) {
482-
if (!child.private) return;
484+
if (!(child.private || parent?.private)) return;
483485

484486
this.debug("🛡️ List moderators", { room: (parent ?? child).local });
485487
const moderators = await this.getModerators((parent ?? child).id);
486488

489+
const extra = [];
490+
if (child.inviteAttendants)
491+
extra.push(...Object.values(this.plan.roomAttendants ?? {}));
492+
487493
this.debug("🚪 Get memberships", { room: child.local });
488494
const childMemberships = await this.matrix.getRoomMembers(child.id);
489495

490496
for (const { membership, membershipFor: invitee, sender } of childMemberships) {
491497
if (
492498
membership === "invite" &&
493499
sender === this.plan.steward.id &&
494-
!moderators.includes(invitee)
500+
!(moderators.includes(invitee) || extra.includes(invitee))
495501
) {
496502
this.info("🎟️ Withdraw invitation", { room: child.local, invitee });
497503
await this.matrix.sendStateEvent(child.id, "m.room.member", invitee, {
@@ -503,16 +509,26 @@ export default class extends Module {
503509
if (parent) this.debug("🚪 Get memberships", { space: parent.local });
504510
const parentMemberships = parent && (await this.matrix.getRoomMembers(parent.id));
505511

506-
for (const invitee of moderators) {
507-
const childMembership = childMemberships.find((m) => m.membershipFor === invitee);
512+
if (child.private) {
513+
for (const invitee of moderators) {
514+
const childMembership = childMemberships.find((m) => m.membershipFor === invitee);
515+
if (
516+
(!parentMemberships ||
517+
parentMemberships.some(
518+
(m) => m.membershipFor === invitee && m.membership === "join",
519+
)) &&
520+
(!childMembership ||
521+
(childMembership.membership === "leave" &&
522+
childMembership.sender === this.plan.steward.id))
523+
)
524+
await this.tryInvite(child.id, child.local, invitee);
525+
}
526+
}
527+
for (const invitee of extra) {
528+
const membership = childMemberships.find((m) => m.membershipFor === invitee);
508529
if (
509-
(!parentMemberships ||
510-
parentMemberships.some(
511-
(m) => m.membershipFor === invitee && m.membership === "join",
512-
)) &&
513-
(!childMembership ||
514-
(childMembership.membership === "leave" &&
515-
childMembership.sender === this.plan.steward.id))
530+
!membership ||
531+
(membership.membership === "leave" && membership.sender === this.plan.steward.id)
516532
)
517533
await this.tryInvite(child.id, child.local, invitee);
518534
}
@@ -667,6 +683,9 @@ export default class extends Module {
667683
await this.reconcileIntro(room);
668684
await this.reconcileRedirect(room);
669685

686+
if (expected.inviteAttendants) this.#sharedWithAttendants.set(id, room);
687+
else this.#sharedWithAttendants.delete(id);
688+
670689
if (expected.children) {
671690
this.debug("🏘️ Get space", { local });
672691
const space = await this.matrix.getSpace(id);
@@ -785,7 +804,8 @@ export default class extends Module {
785804
const tag = `pretalx-room-${id}`;
786805
const local = `${plan.prefix}room-${id}`;
787806
const invitees = optional(this.plan.roomAttendants?.[id]);
788-
await this.reconcileView(local, { avatar: "room", name, tag }, children, invitees);
807+
const visible = [...this.#sharedWithAttendants.values(), ...children];
808+
await this.reconcileView(local, { avatar: "room", name, tag }, visible, invitees);
789809
}
790810
}
791811

0 commit comments

Comments
 (0)