Skip to content

Commit

Permalink
Config for promoting guests to moderators
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennis Benz committed Jun 2, 2024
1 parent 27f59e7 commit 6a3feb2
Show file tree
Hide file tree
Showing 20 changed files with 87 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ trait ChangeUserRoleCmdMsgHdlr extends RightsManagementTrait {
} yield {
RegisteredUsers.updateUserRole(liveMeeting.registeredUsers, u, userRole)
}
val promoteGuest = !liveMeeting.props.usersProp.authenticatedGuest
val promoteGuest = !liveMeeting.props.usersProp.authenticatedGuest || liveMeeting.props.usersProp.allowPromoteGuestToModerator
if (msg.body.role == Roles.MODERATOR_ROLE && (!uvo.guest || promoteGuest)) {
// Promote non-guest users.
val notifyEvent = MsgBuilder.buildNotifyUserInMeetingEvtMsg(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ case class MeetingUsersPoliciesDbModel(
meetingLayout: String,
allowModsToUnmuteUsers: Boolean,
allowModsToEjectCameras: Boolean,
authenticatedGuest: Boolean
authenticatedGuest: Boolean,
allowPromoteGuestToModerator: Boolean
)

class MeetingUsersPoliciesDbTableDef(tag: Tag) extends Table[MeetingUsersPoliciesDbModel](tag, "meeting_usersPolicies") {
Expand All @@ -34,10 +35,11 @@ class MeetingUsersPoliciesDbTableDef(tag: Tag) extends Table[MeetingUsersPolicie
val allowModsToUnmuteUsers = column[Boolean]("allowModsToUnmuteUsers")
val allowModsToEjectCameras = column[Boolean]("allowModsToEjectCameras")
val authenticatedGuest = column[Boolean]("authenticatedGuest")
val allowPromoteGuestToModerator = column[Boolean]("allowPromoteGuestToModerator")

// val fk_meetingId: ForeignKeyQuery[MeetingDbTableDef, MeetingDbModel] = foreignKey("fk_meetingId", meetingId, TableQuery[MeetingDbTableDef])(_.meetingId)

override val * : ProvenShape[MeetingUsersPoliciesDbModel] = (meetingId, maxUsers, maxUserConcurrentAccesses, webcamsOnlyForModerator, userCameraCap, guestPolicy, guestLobbyMessage, meetingLayout, allowModsToUnmuteUsers, allowModsToEjectCameras, authenticatedGuest) <> (MeetingUsersPoliciesDbModel.tupled, MeetingUsersPoliciesDbModel.unapply)
override val * : ProvenShape[MeetingUsersPoliciesDbModel] = (meetingId, maxUsers, maxUserConcurrentAccesses, webcamsOnlyForModerator, userCameraCap, guestPolicy, guestLobbyMessage, meetingLayout, allowModsToUnmuteUsers, allowModsToEjectCameras, authenticatedGuest, allowPromoteGuestToModerator) <> (MeetingUsersPoliciesDbModel.tupled, MeetingUsersPoliciesDbModel.unapply)
}

object MeetingUsersPoliciesDAO {
Expand All @@ -56,6 +58,7 @@ object MeetingUsersPoliciesDAO {
allowModsToUnmuteUsers = usersProp.allowModsToUnmuteUsers,
allowModsToEjectCameras = usersProp.allowModsToEjectCameras,
authenticatedGuest = usersProp.authenticatedGuest,
allowPromoteGuestToModerator = usersProp.allowPromoteGuestToModerator,
)
)
).onComplete {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ trait AppsTestFixtures {
val allowModsToUnmuteUsers = false
val allowModsToEjectCameras = false
val authenticatedGuest = false
val allowPromoteGuestToModerator = false
val meetingLayout = ""
val captureNotesFilename = s"Room 0${sequence} (Notes)"
val captureSlidesFilename = s"Room 0${sequence} (Whiteboard)"
Expand All @@ -70,7 +71,7 @@ trait AppsTestFixtures {
val usersProp = UsersProp(maxUsers = maxUsers, webcamsOnlyForModerator = webcamsOnlyForModerator,
userCameraCap = userCameraCap,
guestPolicy = guestPolicy, allowModsToUnmuteUsers = allowModsToUnmuteUsers, allowModsToEjectCameras = allowModsToEjectCameras,
authenticatedGuest = authenticatedGuest, meetingLayout = meetingLayout)
authenticatedGuest = authenticatedGuest, allowPromoteGuestToModerator = allowPromoteGuestToModerator, meetingLayout = meetingLayout)
val metadataProp = new MetadataProp(metadata)

val defaultProps = DefaultProps(meetingProp, breakoutProps, durationProps, password, recordProp, welcomeProp, voiceProp,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,16 @@ case class WelcomeProp(welcomeMsgTemplate: String, welcomeMsg: String, modOnlyMe
case class VoiceProp(telVoice: String, voiceConf: String, dialNumber: String, muteOnStart: Boolean)

case class UsersProp(
maxUsers: Int,
maxUserConcurrentAccesses:Int,
webcamsOnlyForModerator: Boolean,
userCameraCap: Int,
guestPolicy: String,
meetingLayout: String,
allowModsToUnmuteUsers: Boolean,
allowModsToEjectCameras: Boolean,
authenticatedGuest: Boolean
maxUsers: Int,
maxUserConcurrentAccesses: Int,
webcamsOnlyForModerator: Boolean,
userCameraCap: Int,
guestPolicy: String,
meetingLayout: String,
allowModsToUnmuteUsers: Boolean,
allowModsToEjectCameras: Boolean,
authenticatedGuest: Boolean,
allowPromoteGuestToModerator: Boolean
)

case class MetadataProp(metadata: collection.immutable.Map[String, String])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ trait TestFixtures {
val keepEvents = false
val guestPolicy = "ALWAYS_ASK"
val authenticatedGuest = false
val allowPromoteGuestToModerator = false
val metadata: collection.immutable.Map[String, String] = Map("foo" -> "bar", "bar" -> "baz", "baz" -> "foo")
val captureNotesFilename = s"Room 0${sequence} (Notes)"
val captureSlidesFilename = s"Room 0${sequence} (Whiteboard)"
Expand Down Expand Up @@ -71,7 +72,7 @@ trait TestFixtures {
val voiceProp = VoiceProp(telVoice = voiceConfId, voiceConf = voiceConfId, dialNumber = dialNumber, muteOnStart = muteOnStart)
val usersProp = UsersProp(maxUsers = maxUsers, webcamsOnlyForModerator = webcamsOnlyForModerator,
userCameraCap = userCameraCap,
guestPolicy = guestPolicy, allowModsToUnmuteUsers = allowModsToUnmuteUsers, allowModsToEjectCameras = allowModsToEjectCameras, authenticatedGuest = authenticatedGuest)
guestPolicy = guestPolicy, allowModsToUnmuteUsers = allowModsToUnmuteUsers, allowModsToEjectCameras = allowModsToEjectCameras, authenticatedGuest = authenticatedGuest, allowPromoteGuestToModerator = allowPromoteGuestToModerator)
val metadataProp = new MetadataProp(metadata)
val defaultProps = DefaultProps(meetingProp, breakoutProps, durationProps, password, recordProp, welcomeProp, voiceProp,
usersProp, metadataProp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class ApiParams {
public static final String FREE_JOIN = "freeJoin";
public static final String FULL_NAME = "fullName";
public static final String GUEST_POLICY = "guestPolicy";
public static final String ALLOW_PROMOTE_GUEST_TO_MODERATOR = "allowPromoteGuestToModerator";
public static final String MEETING_LAYOUT = "meetingLayout";
public static final String IS_BREAKOUT = "isBreakout";
public static final String LOGO = "logo";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,8 +446,8 @@ private void handleCreateMeeting(Meeting m) {
m.getWebcamsOnlyForModerator(), m.getMeetingCameraCap(), m.getUserCameraCap(), m.getMaxPinnedCameras(), m.getModeratorPassword(), m.getViewerPassword(),
m.getLearningDashboardAccessToken(), m.getCreateTime(),
formatPrettyDate(m.getCreateTime()), m.isBreakout(), m.getSequence(), m.isFreeJoin(), m.getMetadata(),
m.getGuestPolicy(), m.getAuthenticatedGuest(), m.getMeetingLayout(), m.getWelcomeMessageTemplate(), m.getWelcomeMessage(), m.getModeratorOnlyMessage(),
m.getDialNumber(), m.getMaxUsers(), m.getMaxUserConcurrentAccesses(),
m.getGuestPolicy(), m.getAuthenticatedGuest(), m.getAllowPromoteGuestToModerator(), m.getMeetingLayout(), m.getWelcomeMessageTemplate(), m.getWelcomeMessage(),
m.getModeratorOnlyMessage(), m.getDialNumber(), m.getMaxUsers(), m.getMaxUserConcurrentAccesses(),
m.getMeetingExpireIfNoUserJoinedInMinutes(), m.getMeetingExpireWhenLastUserLeftInMinutes(),
m.getUserInactivityInspectTimerInMinutes(), m.getUserInactivityThresholdInMinutes(),
m.getUserActivitySignResponseDelayInMinutes(), m.getEndWhenNoModerator(), m.getEndWhenNoModeratorDelayInMinutes(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public class ParamsProcessorUtil {
private String defaultAvatarURL;
private String defaultGuestPolicy;
private Boolean authenticatedGuest;
private Boolean defaultAllowPromoteGuestToModerator;
private String defaultMeetingLayout;
private int defaultMeetingDuration;
private boolean disableRecordingDefault;
Expand Down Expand Up @@ -672,6 +673,11 @@ boolean record = processRecordMeeting(params.get(ApiParams.RECORD));
guestPolicy = params.get(ApiParams.GUEST_POLICY);
}

Boolean allowPromoteGuestToModerator = defaultAllowPromoteGuestToModerator;
if (!StringUtils.isEmpty(params.get(ApiParams.ALLOW_PROMOTE_GUEST_TO_MODERATOR))) {
allowPromoteGuestToModerator = Boolean.parseBoolean(params.get(ApiParams.ALLOW_PROMOTE_GUEST_TO_MODERATOR));
}

String presentationUploadExternalDescription = defaultPresentationUploadExternalDescription;
if (!StringUtils.isEmpty(params.get(ApiParams.PRESENTATION_UPLOAD_EXTERNAL_DESCRIPTION))) {
presentationUploadExternalDescription = params.get(ApiParams.PRESENTATION_UPLOAD_EXTERNAL_DESCRIPTION);
Expand Down Expand Up @@ -760,6 +766,7 @@ boolean record = processRecordMeeting(params.get(ApiParams.RECORD));
.withWelcomeMessage(welcomeMessage).isBreakout(isBreakout)
.withGuestPolicy(guestPolicy)
.withAuthenticatedGuest(authenticatedGuest)
.withAllowPromoteGuestToModerator(allowPromoteGuestToModerator)
.withAllowRequestsWithoutSession(allowRequestsWithoutSession)
.withMeetingLayout(meetingLayout)
.withBreakoutRoomsParams(breakoutParams)
Expand Down Expand Up @@ -1290,6 +1297,10 @@ public void setAuthenticatedGuest(Boolean value) {
this.authenticatedGuest = value;
}

public void setDefaultAllowPromoteGuestToModerator(Boolean value) {
this.defaultAllowPromoteGuestToModerator = value;
}

public void setDefaultMeetingLayout(String meetingLayout) {
this.defaultMeetingLayout = meetingLayout;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public class Meeting {
private String guestLobbyMessage = "";
private Map<String,String> usersWithGuestLobbyMessages;
private Boolean authenticatedGuest = false;
private Boolean allowPromoteGuestToModerator = false;
private String meetingLayout = MeetingLayout.SMART_LAYOUT;
private boolean userHasJoined = false;
private Map<String, String> guestUsersWithPositionInWaitingLine;
Expand Down Expand Up @@ -165,6 +166,7 @@ record = builder.record;
isBreakout = builder.isBreakout;
guestPolicy = builder.guestPolicy;
authenticatedGuest = builder.authenticatedGuest;
allowPromoteGuestToModerator = builder.allowPromoteGuestToModerator;
meetingLayout = builder.meetingLayout;
allowRequestsWithoutSession = builder.allowRequestsWithoutSession;
breakoutRoomsParams = builder.breakoutRoomsParams;
Expand Down Expand Up @@ -501,6 +503,14 @@ public Boolean getAuthenticatedGuest() {
return authenticatedGuest;
}

public void setAllowPromoteGuestToModerator(Boolean value) {
allowPromoteGuestToModerator = value;
}

public Boolean getAllowPromoteGuestToModerator() {
return allowPromoteGuestToModerator;
}

public void setMeetingLayout(String layout) {
meetingLayout = layout;
}
Expand Down Expand Up @@ -910,6 +920,7 @@ public static class Builder {
private boolean isBreakout;
private String guestPolicy;
private Boolean authenticatedGuest;
private Boolean allowPromoteGuestToModerator;
private Boolean allowRequestsWithoutSession;
private String meetingLayout;
private BreakoutRoomsParams breakoutRoomsParams;
Expand Down Expand Up @@ -1096,6 +1107,11 @@ public Builder withAuthenticatedGuest(Boolean authGuest) {
return this;
}

public Builder withAllowPromoteGuestToModerator(Boolean value) {
allowPromoteGuestToModerator = value;
return this;
}

public Builder withAllowRequestsWithoutSession(Boolean value) {
allowRequestsWithoutSession = value;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ void createMeeting(String meetingID, String externalMeetingID,
Integer maxPinnedCameras,
String moderatorPass, String viewerPass, String learningDashboardAccessToken, Long createTime,
String createDate, Boolean isBreakout, Integer sequence, Boolean freejoin, Map<String, String> metadata,
String guestPolicy, Boolean authenticatedGuest, String meetingLayout, String welcomeMsgTemplate, String welcomeMsg, String modOnlyMessage,
String guestPolicy, Boolean authenticatedGuest, Boolean allowPromoteGuestToModerator, String meetingLayout, String welcomeMsgTemplate, String welcomeMsg, String modOnlyMessage,
String dialNumber, Integer maxUsers, Integer maxUserConcurrentAccesses,
Integer meetingExpireIfNoUserJoinedInMinutes,
Integer meetingExpireWhenLastUserLeftInMinutes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public class UsersProp2 {
public final String guestPolicy;
public final String meetingLayout;
public final boolean authenticatedGuest;
public final boolean allowPromoteGuestToModerator;
public final boolean userHasJoined;
public final boolean webcamsOnlyForModerator;
public final int userCameraCap;
Expand All @@ -21,6 +22,7 @@ public UsersProp2(int maxUsers,
String guestPolicy,
String meetingLayout,
boolean authenticatedGuest,
boolean allowPromoteGuestToModerator,
boolean userHasJoined,
Map<String, String> userCustomData,
Map<String, User2> users,
Expand All @@ -31,6 +33,7 @@ public UsersProp2(int maxUsers,
this.guestPolicy = guestPolicy;
this.meetingLayout = meetingLayout;
this.authenticatedGuest = authenticatedGuest;
this.allowPromoteGuestToModerator = allowPromoteGuestToModerator;
this.userHasJoined = userHasJoined;
this.userCustomData = userCustomData;
this.users = users;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ class BbbWebApiGWApp(
createTime: java.lang.Long, createDate: String, isBreakout: java.lang.Boolean,
sequence: java.lang.Integer,
freeJoin: java.lang.Boolean,
metadata: java.util.Map[String, String], guestPolicy: String, authenticatedGuest: java.lang.Boolean, meetingLayout: String,
metadata: java.util.Map[String, String], guestPolicy: String, authenticatedGuest: java.lang.Boolean, allowPromoteGuestToModerator: java.lang.Boolean,
meetingLayout: String,
welcomeMsgTemplate: String, welcomeMsg: String, modOnlyMessage: String,
dialNumber: String,
maxUsers: java.lang.Integer,
Expand Down Expand Up @@ -216,7 +217,8 @@ class BbbWebApiGWApp(
userCameraCap = userCameraCap.intValue(),
guestPolicy = guestPolicy, meetingLayout = meetingLayout, allowModsToUnmuteUsers = allowModsToUnmuteUsers.booleanValue(),
allowModsToEjectCameras = allowModsToEjectCameras.booleanValue(),
authenticatedGuest = authenticatedGuest.booleanValue()
authenticatedGuest = authenticatedGuest.booleanValue(),
allowPromoteGuestToModerator = allowPromoteGuestToModerator.booleanValue()
)
val metadataProp = MetadataProp(mapAsScalaMap(metadata).toMap)

Expand Down
22 changes: 12 additions & 10 deletions bbb-graphql-server/bbb_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,17 @@ create view "v_meeting_voiceSettings" as select * from meeting_voice;

create table "meeting_usersPolicies" (
"meetingId" varchar(100) primary key references "meeting"("meetingId") ON DELETE CASCADE,
"maxUsers" integer,
"maxUserConcurrentAccesses" integer,
"webcamsOnlyForModerator" boolean,
"userCameraCap" integer,
"guestPolicy" varchar(100),
"guestLobbyMessage" text,
"meetingLayout" varchar(100),
"allowModsToUnmuteUsers" boolean,
"allowModsToEjectCameras" boolean,
"authenticatedGuest" boolean
"maxUsers" integer,
"maxUserConcurrentAccesses" integer,
"webcamsOnlyForModerator" boolean,
"userCameraCap" integer,
"guestPolicy" varchar(100),
"guestLobbyMessage" text,
"meetingLayout" varchar(100),
"allowModsToUnmuteUsers" boolean,
"allowModsToEjectCameras" boolean,
"authenticatedGuest" boolean,
"allowPromoteGuestToModerator" boolean
);
create index "idx_meeting_usersPolicies_meetingId" on "meeting_usersPolicies"("meetingId");

Expand All @@ -153,6 +154,7 @@ SELECT "meeting_usersPolicies"."meetingId",
"meeting_usersPolicies"."allowModsToUnmuteUsers",
"meeting_usersPolicies"."allowModsToEjectCameras",
"meeting_usersPolicies"."authenticatedGuest",
"meeting_usersPolicies"."allowPromoteGuestToModerator",
"meeting"."isBreakout" is false "moderatorsCanMuteAudio",
"meeting"."isBreakout" is false and "meeting_usersPolicies"."allowModsToUnmuteUsers" is true "moderatorsCanUnmuteAudio"
FROM "meeting_usersPolicies"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ select_permissions:
- allowModsToEjectCameras
- allowModsToUnmuteUsers
- authenticatedGuest
- allowPromoteGuestToModerator
- guestLobbyMessage
- guestPolicy
- maxUserConcurrentAccesses
Expand Down
1 change: 1 addition & 0 deletions bigbluebutton-html5/imports/ui/Types/meeting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export interface UsersPolicies {
allowModsToEjectCameras: boolean;
allowModsToUnmuteUsers: boolean;
authenticatedGuest: boolean;
allowPromoteGuestToModerator: boolean;
guestPolicy: string;
maxUserConcurrentAccesses: number;
maxUsers: number;
Expand Down
10 changes: 8 additions & 2 deletions bigbluebutton-html5/imports/ui/components/user-list/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ const getUsersProp = () => {
'usersPolicies.allowModsToUnmuteUsers': 1,
'usersPolicies.allowModsToEjectCameras': 1,
'usersPolicies.authenticatedGuest': 1,
'usersPolicies.allowPromoteGuestToModerator': 1,
},
},
);
Expand All @@ -289,6 +290,7 @@ const getUsersProp = () => {
allowModsToUnmuteUsers: false,
allowModsToEjectCameras: false,
authenticatedGuest: false,
allowPromoteGuestToModerator: false,
};
};

Expand Down Expand Up @@ -341,14 +343,18 @@ const getAvailableActions = (
&& !isSubjectUserModerator
&& !isDialInUser
&& !isBreakoutRoom
&& !(isSubjectUserGuest && usersProp.authenticatedGuest);
&& !(isSubjectUserGuest
&& usersProp.authenticatedGuest
&& !usersProp.allowPromoteGuestToModerator);

const allowedToDemote = amIModerator
&& !amISubjectUser
&& isSubjectUserModerator
&& !isDialInUser
&& !isBreakoutRoom
&& !(isSubjectUserGuest && usersProp.authenticatedGuest);
&& !(isSubjectUserGuest
&& usersProp.authenticatedGuest
&& !usersProp.allowPromoteGuestToModerator);

const allowedToChangeStatus = amISubjectUser && USER_STATUS_ENABLED;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ subscription MeetingPermissions {
allowModsToEjectCameras
allowModsToUnmuteUsers
authenticatedGuest
allowPromoteGuestToModerator
guestPolicy
maxUserConcurrentAccesses
maxUsers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ export const generateActionsPermissions = (
&& !isSubjectUserModerator
&& !isDialInUser
&& !isBreakout
&& !(isSubjectUserGuest && usersPolicies?.authenticatedGuest);
&& !(isSubjectUserGuest && usersPolicies?.authenticatedGuest && !usersPolicies?.allowPromoteGuestToModerator);

const allowedToDemote = amIModerator
&& !amISubjectUser
&& isSubjectUserModerator
&& !isDialInUser
&& !isBreakout
&& !(isSubjectUserGuest && usersPolicies?.authenticatedGuest);
&& !(isSubjectUserGuest && usersPolicies?.authenticatedGuest && !usersPolicies?.allowPromoteGuestToModerator);

const allowedToChangeStatus = amISubjectUser && USER_STATUS_ENABLED;

Expand Down
Loading

0 comments on commit 6a3feb2

Please sign in to comment.