diff --git a/bigbluebutton-html5/imports/api/guest-users/server/methods.js b/bigbluebutton-html5/imports/api/guest-users/server/methods.js index 3cc2da8776726c0f421f8794323883fcfd22c1f7..dc7ccd93f0dea3c9a099a50a4b653a9c4b1734d2 100644 --- a/bigbluebutton-html5/imports/api/guest-users/server/methods.js +++ b/bigbluebutton-html5/imports/api/guest-users/server/methods.js @@ -1,6 +1,8 @@ import { Meteor } from 'meteor/meteor'; import allowPendingUsers from '/imports/api/guest-users/server/methods/allowPendingUsers'; +import changeGuestPolicy from '/imports/api/guest-users/server/methods/changeGuestPolicy'; Meteor.methods({ allowPendingUsers, + changeGuestPolicy, }); diff --git a/bigbluebutton-html5/imports/api/guest-users/server/methods/changeGuestPolicy.js b/bigbluebutton-html5/imports/api/guest-users/server/methods/changeGuestPolicy.js new file mode 100644 index 0000000000000000000000000000000000000000..638993955884b635d7e5bc09971341e0e385949b --- /dev/null +++ b/bigbluebutton-html5/imports/api/guest-users/server/methods/changeGuestPolicy.js @@ -0,0 +1,30 @@ +import { Meteor } from 'meteor/meteor'; +import { check } from 'meteor/check'; +import RedisPubSub from '/imports/startup/server/redis'; +import Logger from '/imports/startup/server/logger'; + +const REDIS_CONFIG = Meteor.settings.private.redis; +const CHANNEL = REDIS_CONFIG.channels.toAkkaApps; +const EVENT_NAME = 'SetGuestPolicyCmdMsg'; + +export default function changeGuestPolicy(credentials, policyRule) { + const { + meetingId, + requesterUserId, + requesterToken, + } = credentials; + + check(meetingId, String); + check(requesterUserId, String); + check(requesterToken, String); + check(policyRule, String); + + const payload = { + setBy: requesterUserId, + policy: policyRule, + }; + + Logger.info(`User=${requesterUserId} change guest policy to ${policyRule}`); + + return RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, requesterUserId, payload); +} diff --git a/bigbluebutton-html5/imports/ui/components/waiting-users/component.jsx b/bigbluebutton-html5/imports/ui/components/waiting-users/component.jsx index a642bb85bde435695ed3cbf226b3884ca4f513b1..8c5d929f3f9bcf3225a886c9e3a5f72b649c878c 100755 --- a/bigbluebutton-html5/imports/ui/components/waiting-users/component.jsx +++ b/bigbluebutton-html5/imports/ui/components/waiting-users/component.jsx @@ -1,4 +1,4 @@ -import React, { useEffect } from 'react'; +import React, { useEffect, useState } from 'react'; import { Session } from 'meteor/session'; import { defineMessages, injectIntl } from 'react-intl'; import injectWbResizeEvent from '/imports/ui/components/presentation/resize-wrapper/component'; @@ -43,22 +43,15 @@ const intlMessages = defineMessages({ id: 'app.userList.guest.pendingGuestUsers', description: 'Title for the waiting users', }, + rememberChoice: { + id: 'app.userList.guest.rememberChoice', + description: 'Remember label for checkbox', + }, }); const ALLOW_STATUS = 'ALLOW'; const DENY_STATUS = 'DENY'; -const renderButton = (message, action, key) => ( - <Button - key={key} - color="primary" - label={message} - size="lg" - onClick={action} - className={styles.customBtn} - /> -); - const renderGuestUserItem = (name, color, handleAccept, handleDeny, role, sequence, userId) => ( <div key={`userlist-item-${userId}`} className={styles.listItem}> <div key={`user-content-container-${userId}`} className={styles.userContentContainer}> @@ -122,6 +115,8 @@ const renderPendingUsers = (message, usersArray, action) => { }; const WaitingUsers = (props) => { + const [rememberChoice, setRememberChoice] = useState(false); + useEffect(() => { const { authenticatedUsers, @@ -135,28 +130,59 @@ const WaitingUsers = (props) => { authenticatedUsers, guestUsers, guestUsersCall, + changeGuestPolicy, } = props; + const onCheckBoxChange = (e) => { + const { checked } = e.target; + setRememberChoice(checked); + }; + + const changePolicy = (shouldExecutePolicy, policyRule, cb) => () => { + if (shouldExecutePolicy) { + changeGuestPolicy(policyRule); + } + return cb(); + }; + + const renderButton = (message, { key, policy, action }) => ( + <Button + key={key} + color="primary" + label={message} + size="lg" + onClick={changePolicy(rememberChoice, policy, action)} + className={styles.customBtn} + /> + ); + const buttonsData = [ { messageId: intlMessages.allowAllAuthenticated, action: () => guestUsersCall(authenticatedUsers, ALLOW_STATUS), key: 'allow-all-auth', + policy: 'ALWAYS_ACCEPT_AUTH', }, { messageId: intlMessages.allowAllGuests, - action: () => guestUsersCall(guestUsers, ALLOW_STATUS), + action: () => guestUsersCall( + [...guestUsers].concat(rememberChoice ? authenticatedUsers : []), + ALLOW_STATUS, + ), key: 'allow-all-guest', + policy: 'ALWAYS_ACCEPT', }, { messageId: intlMessages.allowEveryone, action: () => guestUsersCall([...guestUsers, ...authenticatedUsers], ALLOW_STATUS), key: 'allow-everyone', + policy: 'ALWAYS_ACCEPT', }, { messageId: intlMessages.denyEveryone, action: () => guestUsersCall([...guestUsers, ...authenticatedUsers], DENY_STATUS), key: 'deny-everyone', + policy: 'ALWAYS_DENY', }, ]; @@ -186,11 +212,16 @@ const WaitingUsers = (props) => { { buttonsData.map(buttonData => renderButton( intl.formatMessage(buttonData.messageId), - buttonData.action, - buttonData.key, + buttonData, )) } </div> + <div> + <label htmlFor="remiderUsersId" className={styles.rememberContainer}> + <input id="remiderUsersId" type="checkbox" onChange={onCheckBoxChange} /> + <p>{intl.formatMessage(intlMessages.rememberChoice)}</p> + </label> + </div> {renderPendingUsers( intl.formatMessage(intlMessages.pendingUsers, { 0: authenticatedUsers.length }), diff --git a/bigbluebutton-html5/imports/ui/components/waiting-users/container.jsx b/bigbluebutton-html5/imports/ui/components/waiting-users/container.jsx index cd7904b7a67418ed54bc26bcd70d97efb3c706f5..b3fe25c21d16d87eb2e88f28613cc3f1b7143112 100644 --- a/bigbluebutton-html5/imports/ui/components/waiting-users/container.jsx +++ b/bigbluebutton-html5/imports/ui/components/waiting-users/container.jsx @@ -14,7 +14,7 @@ class WaitingContainer extends PureComponent { } export default withTracker(() => { - const guestUsers = GuestUsers.find({ + const guestUsers = GuestUsers.find({ meetingId: Auth.meetingID, guest: true, approved: false, @@ -34,5 +34,6 @@ export default withTracker(() => { guestUsers, authenticatedUsers, guestUsersCall: Service.guestUsersCall, + changeGuestPolicy: Service.changeGuestPolicy, }; })(WaitingContainer); diff --git a/bigbluebutton-html5/imports/ui/components/waiting-users/service.js b/bigbluebutton-html5/imports/ui/components/waiting-users/service.js index 8485c60dbd14265028d5d08464b72f9fc1c7777e..23392f0c522fb66f18ee4c0e7cd1c78b1f3fdd4a 100644 --- a/bigbluebutton-html5/imports/ui/components/waiting-users/service.js +++ b/bigbluebutton-html5/imports/ui/components/waiting-users/service.js @@ -2,6 +2,8 @@ import { makeCall } from '/imports/ui/services/api'; const guestUsersCall = (guestsArray, status) => makeCall('allowPendingUsers', guestsArray, status); +const changeGuestPolicy = policyRule => makeCall('changeGuestPolicy', policyRule); export default { guestUsersCall, + changeGuestPolicy, }; diff --git a/bigbluebutton-html5/imports/ui/components/waiting-users/styles.scss b/bigbluebutton-html5/imports/ui/components/waiting-users/styles.scss index 834fb8875296db613f2169d29731f17d21001e36..2112d544a90beae49b3bf1032a3008a4e59c0259 100644 --- a/bigbluebutton-html5/imports/ui/components/waiting-users/styles.scss +++ b/bigbluebutton-html5/imports/ui/components/waiting-users/styles.scss @@ -142,4 +142,17 @@ overflow: hidden; text-overflow: ellipsis; width: 100%; +} + +.remenberContainer { + margin: 1rem 0; + height: 2rem; + display: flex; + align-items: center; + & > p { + height: fit-content; + padding: 0; + margin: 0; + margin-left: .5rem; + } } \ No newline at end of file diff --git a/bigbluebutton-html5/private/locales/en.json b/bigbluebutton-html5/private/locales/en.json index 4756289a13205ecd42362fc07696eb68b9d35370..aa59fd68142ef80eb9bf10c45596134d9d17a222 100755 --- a/bigbluebutton-html5/private/locales/en.json +++ b/bigbluebutton-html5/private/locales/en.json @@ -404,6 +404,7 @@ "app.userList.guest.pendingUsers": "{0} Pending Users", "app.userList.guest.pendingGuestUsers": "{0} Pending Guest Users", "app.userList.guest.pendingGuestAlert": "Has joined the session and is waiting for your approval.", + "app.userList.guest.rememberChoice": "Remember choice", "app.toast.breakoutRoomEnded": "The breakout room ended. Please rejoin in the audio.", "app.toast.chat.public": "New Public Chat message", "app.toast.chat.private": "New Private Chat message",