-
Notifications
You must be signed in to change notification settings - Fork 8
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
Allow configuration of multiple moderator users to be invited to all rooms. #234
Changes from 1 commit
57ffd23
1b41a6c
e01d120
e530fd2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -394,7 +394,7 @@ export class Conference { | |
this.client, | ||
mergeWithCreationTemplate(AUDITORIUM_BACKSTAGE_CREATION_TEMPLATE, { | ||
room_alias_name: (new RoomAlias(alias)).localpart, | ||
invite: [this.config.moderatorUserId], | ||
invite: this.config.moderatorUserIds, | ||
}), | ||
); | ||
await rootSpace.addChildRoom(roomId); | ||
|
@@ -433,7 +433,7 @@ export class Conference { | |
subspace = await this.client.createSpace({ | ||
isPublic: true, | ||
name: name, | ||
invites: [this.config.moderatorUserId], | ||
invites: this.config.moderatorUserIds, | ||
}); | ||
this.subspaces[subspaceId] = subspace; | ||
|
||
|
@@ -448,9 +448,11 @@ export class Conference { | |
roomId: subspace.roomId, | ||
} as IStoredSubspace); | ||
|
||
// Grants PL100 to the moderator in the subspace. | ||
// Grants PL100 to the moderators in the subspace. | ||
// We can't do this directly with `createSpace` unfortunately, as we could for plain rooms. | ||
await this.client.setUserPowerLevel(this.config.moderatorUserId, subspace.roomId, 100); | ||
for (let moderator of this.config.moderatorUserIds) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Technically we could convert There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel more happy leaving it as it is (in a 'known working' state) than messing TBH. It is a shame that these don't compose well though. |
||
await this.client.setUserPowerLevel(moderator, subspace.roomId, 100); | ||
} | ||
} else { | ||
subspace = this.subspaces[subspaceId]; | ||
} | ||
|
@@ -481,7 +483,7 @@ export class Conference { | |
); | ||
} else { | ||
// Create a new interest room. | ||
roomId = await safeCreateRoom(this.client, mergeWithCreationTemplate(SPECIAL_INTEREST_CREATION_TEMPLATE(this.config.moderatorUserId), { | ||
roomId = await safeCreateRoom(this.client, mergeWithCreationTemplate(SPECIAL_INTEREST_CREATION_TEMPLATE(this.config.moderatorUserIds), { | ||
creation_content: { | ||
[RSC_CONFERENCE_ID]: this.id, | ||
[RSC_SPECIAL_INTEREST_ID]: interestRoom.id, | ||
|
@@ -571,7 +573,7 @@ export class Conference { | |
|
||
await parentSpace.addChildSpace(audSpace, { order: `auditorium-${auditorium.id}` }); | ||
|
||
const roomId = await safeCreateRoom(this.client, mergeWithCreationTemplate(AUDITORIUM_CREATION_TEMPLATE(this.config.moderatorUserId), { | ||
const roomId = await safeCreateRoom(this.client, mergeWithCreationTemplate(AUDITORIUM_CREATION_TEMPLATE(this.config.moderatorUserIds), { | ||
creation_content: { | ||
[RSC_CONFERENCE_ID]: this.id, | ||
[RSC_AUDITORIUM_ID]: auditorium.id, | ||
|
@@ -629,7 +631,7 @@ export class Conference { | |
} | ||
|
||
if (!this.talks[talk.id]) { | ||
roomId = await safeCreateRoom(this.client, mergeWithCreationTemplate(TALK_CREATION_TEMPLATE(this.config.moderatorUserId), { | ||
roomId = await safeCreateRoom(this.client, mergeWithCreationTemplate(TALK_CREATION_TEMPLATE(this.config.moderatorUserIds), { | ||
name: talk.title, | ||
creation_content: { | ||
[RSC_CONFERENCE_ID]: this.id, | ||
|
@@ -848,7 +850,9 @@ export class Conference { | |
// we'll be unable to do promotions/demotions in the future. | ||
const pls = await this.client.getRoomStateEvent(roomId, "m.room.power_levels", ""); | ||
pls['users'][await this.client.getUserId()] = 100; | ||
pls['users'][this.config.moderatorUserId] = 100; | ||
for (let moderator of this.config.moderatorUserIds) { | ||
pls['users'][moderator] = 100; | ||
} | ||
for (const userId of mxids) { | ||
if (pls['users'][userId]) continue; | ||
pls['users'][userId] = 50; | ||
|
@@ -916,7 +920,9 @@ export class Conference { | |
this.membersInRooms[roomId] = joinedOrLeftMembers; | ||
const total = new Set(Object.values(this.membersInRooms).flat()); | ||
total.delete(myUserId); | ||
total.delete(this.config.moderatorUserId); | ||
for (let moderator of this.config.moderatorUserIds) { | ||
total.delete(moderator); | ||
} | ||
attendeeTotalGauge.set(total.size); | ||
} catch (ex) { | ||
LogService.warn("Conference", `Failed to recalculate room membership for ${roomId}`, ex); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,7 @@ export interface IConfig { | |
managementRoom: string; | ||
idServerDomain?: string; | ||
idServerBrand?: string; | ||
moderatorUserId: string; | ||
moderatorUserIds: string[]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want to still have the legacy moderatorUserId option, which we internally convert to Or failing that, warn on startup that the old field is unused? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. refusing to start up seems like a reasonable option. I don't think we should force ourselves into too much backwards compat given we don't expect anyone else to be running this really. But refusing to start up sounds like a decent footgun-avoider. |
||
livestream: { | ||
auditoriumUrl: string; | ||
talkUrl: string; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ import { RoomCreateOptions } from "matrix-bot-sdk"; | |
|
||
export const KickPowerLevel = 50; | ||
|
||
export const PUBLIC_ROOM_POWER_LEVELS_TEMPLATE = (moderatorUserId: string) => ({ | ||
export const PUBLIC_ROOM_POWER_LEVELS_TEMPLATE = (moderatorUserIds: string[]) => ({ | ||
ban: 50, | ||
events_default: 0, | ||
invite: 50, | ||
|
@@ -40,10 +40,7 @@ export const PUBLIC_ROOM_POWER_LEVELS_TEMPLATE = (moderatorUserId: string) => ({ | |
"m.space.parent": 100, | ||
"m.space.child": 100, | ||
}, | ||
users: { | ||
[moderatorUserId]: 100, | ||
// should be populated with the creator | ||
}, | ||
users: Object.fromEntries(moderatorUserIds.map(moderator => [moderator, 100])), | ||
}); | ||
|
||
export const PRIVATE_ROOM_POWER_LEVELS_TEMPLATE = { | ||
|
@@ -91,7 +88,7 @@ export const CONFERENCE_ROOM_CREATION_TEMPLATE: RoomCreateOptions = { | |
}, | ||
}; | ||
|
||
export const AUDITORIUM_CREATION_TEMPLATE = (moderatorUserId: string) => ({ | ||
export const AUDITORIUM_CREATION_TEMPLATE = (moderatorUserIds: string[]) => ({ | ||
preset: 'public_chat', | ||
visibility: 'public', | ||
initial_state: [ | ||
|
@@ -101,8 +98,8 @@ export const AUDITORIUM_CREATION_TEMPLATE = (moderatorUserId: string) => ({ | |
creation_content: { | ||
[RSC_ROOM_KIND_FLAG]: RoomKind.Auditorium, | ||
}, | ||
power_level_content_override: PUBLIC_ROOM_POWER_LEVELS_TEMPLATE(moderatorUserId), | ||
invite: [moderatorUserId], | ||
power_level_content_override: PUBLIC_ROOM_POWER_LEVELS_TEMPLATE(moderatorUserIds), | ||
invite: moderatorUserIds, | ||
} satisfies RoomCreateOptions); | ||
|
||
export const AUDITORIUM_BACKSTAGE_CREATION_TEMPLATE: RoomCreateOptions = { | ||
|
@@ -118,7 +115,7 @@ export const AUDITORIUM_BACKSTAGE_CREATION_TEMPLATE: RoomCreateOptions = { | |
power_level_content_override: PRIVATE_ROOM_POWER_LEVELS_TEMPLATE, | ||
}; | ||
|
||
export const TALK_CREATION_TEMPLATE = (moderatorUserId: string) => ({ // before being opened up to the public | ||
export const TALK_CREATION_TEMPLATE = (moderatorUserIds: string[]) => ({ // before being opened up to the public | ||
preset: 'private_chat', | ||
visibility: 'private', | ||
initial_state: [ | ||
|
@@ -128,11 +125,11 @@ export const TALK_CREATION_TEMPLATE = (moderatorUserId: string) => ({ // before | |
creation_content: { | ||
[RSC_ROOM_KIND_FLAG]: RoomKind.Talk, | ||
}, | ||
power_level_content_override: PUBLIC_ROOM_POWER_LEVELS_TEMPLATE(moderatorUserId), | ||
invite: [moderatorUserId], | ||
power_level_content_override: PUBLIC_ROOM_POWER_LEVELS_TEMPLATE(moderatorUserIds), | ||
invite: moderatorUserIds, | ||
} satisfies RoomCreateOptions); | ||
|
||
export const SPECIAL_INTEREST_CREATION_TEMPLATE = (moderatorUserId: string) => ({ | ||
export const SPECIAL_INTEREST_CREATION_TEMPLATE = (moderatorUserIds: string[]) => ({ | ||
preset: 'public_chat', | ||
visibility: 'public', | ||
initial_state: [ | ||
|
@@ -149,7 +146,7 @@ export const SPECIAL_INTEREST_CREATION_TEMPLATE = (moderatorUserId: string) => ( | |
"m.room.power_levels": 50, | ||
}, | ||
}, | ||
invite: [moderatorUserId], | ||
invite: moderatorUserIds, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hard to tell, but does There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as you point out, this is probably broken. We haven't used special interest rooms for at least a couple of years now so I guess it wouldn't be a surprise. I may as well fix that obvious part up now though |
||
} satisfies RoomCreateOptions); | ||
|
||
export function mergeWithCreationTemplate(template: RoomCreateOptions, addlProps: any): any { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we attempt a test for this, should be easy to whip one up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wrote this now, a little fiddly but I think it's better than nothing? :-)