migrate assignPresenter meteor call

This commit is contained in:
Ramón Souza 2023-12-07 10:02:13 -03:00
parent e6af8390a3
commit 0f046de941
9 changed files with 26 additions and 52 deletions

View File

@ -2,7 +2,6 @@ import { Meteor } from 'meteor/meteor';
import validateAuthToken from './methods/validateAuthToken';
import setSpeechLocale from './methods/setSpeechLocale';
import setEmojiStatus from './methods/setEmojiStatus';
import assignPresenter from './methods/assignPresenter';
import toggleUserLock from './methods/toggleUserLock';
import setUserEffectiveConnectionType from './methods/setUserEffectiveConnectionType';
import userActivitySign from './methods/userActivitySign';
@ -15,7 +14,6 @@ Meteor.methods({
setSpeechLocale,
setEmojiStatus,
clearAllUsersEmoji,
assignPresenter,
validateAuthToken,
toggleUserLock,
setUserEffectiveConnectionType,

View File

@ -1,39 +0,0 @@
import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
import RedisPubSub from '/imports/startup/server/redis';
import Logger from '/imports/startup/server/logger';
import Users from '/imports/api/users';
import { extractCredentials } from '/imports/api/common/server/helpers';
export default async function assignPresenter(userId) { // TODO-- send username from client side
try {
const REDIS_CONFIG = Meteor.settings.private.redis;
const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
const EVENT_NAME = 'AssignPresenterReqMsg';
const { meetingId, requesterUserId } = extractCredentials(this.userId);
check(meetingId, String);
check(requesterUserId, String);
check(userId, String);
const User = await Users.findOneAsync({
meetingId,
userId,
});
if (!User) {
throw new Meteor.Error('user-not-found', 'You need a valid user to be able to set presenter');
}
const payload = {
assignedBy: requesterUserId,
newPresenterId: userId,
};
Logger.verbose('User set as presenter', { userId, meetingId, setBy: requesterUserId });
RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, requesterUserId, payload);
} catch (err) {
Logger.error(`Exception while invoking method assignPresenter ${err.stack}`);
}
}

View File

@ -5,10 +5,12 @@ import { layoutSelectInput, layoutDispatch, layoutSelect } from '../../layout/co
import { SMALL_VIEWPORT_BREAKPOINT } from '../../layout/enums';
import { isCameraAsContentEnabled, isTimerFeatureEnabled } from '/imports/ui/services/features';
import { PluginsContext } from '/imports/ui/components/components-data/plugin-context/context';
import { useSubscription } from '@apollo/client';
import { useSubscription, useMutation } from '@apollo/client';
import {
PROCESSED_PRESENTATIONS_SUBSCRIPTION,
} from '/imports/ui/components/whiteboard/queries';
import { SET_PRESENTER } from '/imports/ui/core/graphql/mutations/userMutations';
import Auth from '/imports/ui/services/auth';
const ActionsDropdownContainer = (props) => {
const sidebarContent = layoutSelectInput((i) => i.sidebarContent);
@ -26,6 +28,12 @@ const ActionsDropdownContainer = (props) => {
const { data: presentationData } = useSubscription(PROCESSED_PRESENTATIONS_SUBSCRIPTION);
const presentations = presentationData?.pres_presentation || [];
const [setPresenter] = useMutation(SET_PRESENTER);
const handleTakePresenter = () => {
setPresenter({ variables: { userId: Auth.userID } });
};
return (
<ActionsDropdown
{...{
@ -40,6 +48,7 @@ const ActionsDropdownContainer = (props) => {
isDropdownOpen: Session.get('dropdownOpen'),
setPresentation: PresentationUploaderService.setPresentation,
isCameraAsContentEnabled: isCameraAsContentEnabled(),
handleTakePresenter,
...props,
}}
/>

View File

@ -102,7 +102,6 @@ class ActionsBar extends PureComponent {
enableVideo,
presentationIsOpen,
setPresentationIsOpen,
handleTakePresenter,
intl,
isSharingVideo,
isSharedNotesPinned,
@ -154,7 +153,6 @@ class ActionsBar extends PureComponent {
isPollingEnabled,
isSelectRandomUserEnabled,
allowExternalVideo,
handleTakePresenter,
intl,
isSharingVideo,
stopExternalVideoShare,

View File

@ -90,7 +90,6 @@ export default withTracker(() => ({
stopExternalVideoShare: ExternalVideoService.stopWatching,
enableVideo: getFromUserSettings('bbb_enable_video', Meteor.settings.public.kurento.enableVideo),
setPresentationIsOpen: MediaService.setPresentationIsOpen,
handleTakePresenter: Service.takePresenterRole,
isSharedNotesPinned: Service.isSharedNotesPinned(),
hasScreenshare: isScreenBroadcasting(),
hasCameraAsContent: isCameraAsContentBroadcasting(),

View File

@ -30,8 +30,6 @@ const filterBreakoutUsers = (filter) => (users) => users.filter(filter);
const getUsersNotJoined = filterBreakoutUsers(currentBreakoutUsers);
const takePresenterRole = () => makeCall('assignPresenter', Auth.userID);
const isMe = (intId) => intId === Auth.userID;
export default {
@ -56,6 +54,5 @@ export default {
getBreakouts,
getLastBreakouts,
getUsersNotJoined,
takePresenterRole,
isSharedNotesPinned: () => NotesService.isSharedNotesPinned(),
};

View File

@ -495,8 +495,6 @@ const clearAllReactions = () => {
makeCall('clearAllUsersReaction');
};
const assignPresenter = (userId) => { makeCall('assignPresenter', userId); };
const toggleVoice = (userId) => {
if (userId === Auth.userID) {
AudioService.toggleMuteMicrophone();
@ -726,7 +724,6 @@ export default {
setEmojiStatus,
clearAllEmojiStatus,
clearAllReactions,
assignPresenter,
toggleVoice,
muteAllUsers,
muteAllExceptPresenter,

View File

@ -13,6 +13,7 @@ import {
SET_CAMERA_PINNED,
EJECT_FROM_MEETING,
EJECT_FROM_VOICE,
SET_PRESENTER,
} from '/imports/ui/core/graphql/mutations/userMutations';
import {
isVideoPinEnabledForCurrentUser,
@ -258,6 +259,7 @@ const UserActions: React.FC<UserActionsProps> = ({
const [setCameraPinned] = useMutation(SET_CAMERA_PINNED);
const [ejectFromMeeting] = useMutation(EJECT_FROM_MEETING);
const [ejectFromVoice] = useMutation(EJECT_FROM_VOICE);
const [setPresenter] = useMutation(SET_PRESENTER);
const removeUser = (userId: string, banUser: boolean) => {
if (isVoiceOnlyUser(user.userId)) {
@ -399,7 +401,11 @@ const UserActions: React.FC<UserActionsProps> = ({
? intl.formatMessage(messages.takePresenterLabel)
: intl.formatMessage(messages.makePresenterLabel),
onClick: () => {
makeCall('assignPresenter', user.userId);
setPresenter({
variables: {
userId: user.userId,
},
});
setSelected(false);
},
icon: 'presentation',

View File

@ -44,10 +44,19 @@ export const EJECT_FROM_VOICE = gql`
}
`;
export const SET_PRESENTER = gql`
mutation SetPresenter($userId: String!) {
userSetPresenter(
userId: $userId,
)
}
`;
export default {
SET_CAMERA_PINNED,
SET_RAISE_HAND,
SET_MOBILE_FLAG,
EJECT_FROM_MEETING,
EJECT_FROM_VOICE,
SET_PRESENTER,
};