migrate moveUser action
This commit is contained in:
parent
4ed689fa6d
commit
534bfb83f7
@ -2,11 +2,9 @@ import { Meteor } from 'meteor/meteor';
|
||||
import requestJoinURL from './methods/requestJoinURL';
|
||||
import setBreakoutsTime from '/imports/api/breakouts/server/methods/setBreakoutsTime';
|
||||
import sendMessageToAllBreakouts from './methods/sendMessageToAllBreakouts';
|
||||
import moveUser from '/imports/api/breakouts/server/methods/moveUser';
|
||||
|
||||
Meteor.methods({
|
||||
requestJoinURL,
|
||||
setBreakoutsTime,
|
||||
sendMessageToAllBreakouts,
|
||||
moveUser,
|
||||
});
|
||||
|
@ -1,32 +0,0 @@
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
import RedisPubSub from '/imports/startup/server/redis';
|
||||
import { extractCredentials } from '/imports/api/common/server/helpers';
|
||||
import { check } from 'meteor/check';
|
||||
import Logger from '/imports/startup/server/logger';
|
||||
|
||||
export default function moveUser(fromBreakoutId, toBreakoutId, userIdToMove) {
|
||||
const REDIS_CONFIG = Meteor.settings.private.redis;
|
||||
const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
|
||||
const EVENT_NAME = 'ChangeUserBreakoutReqMsg';
|
||||
|
||||
try {
|
||||
const { meetingId, requesterUserId } = extractCredentials(this.userId);
|
||||
|
||||
check(meetingId, String);
|
||||
check(requesterUserId, String);
|
||||
|
||||
const userId = userIdToMove || requesterUserId;
|
||||
|
||||
return RedisPubSub.publishUserMessage(
|
||||
CHANNEL, EVENT_NAME, meetingId, requesterUserId,
|
||||
{
|
||||
meetingId,
|
||||
fromBreakoutId,
|
||||
toBreakoutId,
|
||||
userId,
|
||||
},
|
||||
);
|
||||
} catch (err) {
|
||||
Logger.error(`Exception while invoking method moveUser ${err.stack}`);
|
||||
}
|
||||
}
|
@ -49,7 +49,6 @@ export default {
|
||||
breakoutJoinedUsers: () => Breakouts.find({
|
||||
joinedUsers: { $exists: true },
|
||||
}, { fields: { joinedUsers: 1, breakoutId: 1, sequence: 1 }, sort: { sequence: 1 } }).fetch(),
|
||||
moveUser: (fromBreakoutId, toBreakoutId, userId) => makeCall('moveUser', fromBreakoutId, toBreakoutId, userId),
|
||||
getBreakouts,
|
||||
getLastBreakouts,
|
||||
getUsersNotJoined,
|
||||
|
@ -25,8 +25,7 @@ import {
|
||||
BreakoutUser,
|
||||
moveUserRegistery,
|
||||
} from './room-managment-state/types';
|
||||
import { moveUser } from './service';
|
||||
import { BREAKOUT_ROOM_CREATE } from '../../mutations';
|
||||
import { BREAKOUT_ROOM_CREATE, BREAKOUT_ROOM_MOVE_USER } from '../../mutations';
|
||||
|
||||
const BREAKOUT_LIM = Meteor.settings.public.app.breakouts.breakoutRoomLimit;
|
||||
const MIN_BREAKOUT_ROOMS = 2;
|
||||
@ -238,6 +237,7 @@ const CreateBreakoutRoom: React.FC<CreateBreakoutRoomProps> = ({
|
||||
const [durationTime, setDurationTime] = React.useState(DEFAULT_BREAKOUT_TIME);
|
||||
|
||||
const [createBreakoutRoom] = useMutation(BREAKOUT_ROOM_CREATE);
|
||||
const [moveUser] = useMutation(BREAKOUT_ROOM_MOVE_USER);
|
||||
|
||||
const roomsRef = React.useRef<Rooms>({});
|
||||
const moveRegisterRef = React.useRef<moveUserRegistery>({});
|
||||
@ -312,7 +312,13 @@ const CreateBreakoutRoom: React.FC<CreateBreakoutRoomProps> = ({
|
||||
userIds.forEach((userId) => {
|
||||
const { fromRoomId, toRoomId } = moveRegisterRef.current[userId];
|
||||
if (fromRoomId !== toRoomId) {
|
||||
moveUser(userId, fromRoomId, toRoomId);
|
||||
moveUser({
|
||||
variables: {
|
||||
userId,
|
||||
fromBreakoutRoomId: fromRoomId,
|
||||
toBreakoutRoomId: toRoomId,
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
setIsOpen(false);
|
||||
|
@ -1,11 +0,0 @@
|
||||
import { makeCall } from '/imports/ui/services/api';
|
||||
|
||||
export const moveUser = (
|
||||
userId: string,
|
||||
fromBreakoutId: string | undefined,
|
||||
toBreakoutId: string | undefined,
|
||||
) => makeCall('moveUser', fromBreakoutId, toBreakoutId, userId);
|
||||
|
||||
export default {
|
||||
moveUser,
|
||||
};
|
@ -26,4 +26,18 @@ export const BREAKOUT_ROOM_END_ALL = gql`
|
||||
}
|
||||
`;
|
||||
|
||||
export default { BREAKOUT_ROOM_CREATE, BREAKOUT_ROOM_END_ALL };
|
||||
export const BREAKOUT_ROOM_MOVE_USER = gql`
|
||||
mutation BreakoutRoomMoveUser(
|
||||
$userId: String!,
|
||||
$fromBreakoutRoomId: String!,
|
||||
$toBreakoutRoomId: String!,
|
||||
) {
|
||||
breakoutRoomMoveUser(
|
||||
userId: $userId,
|
||||
fromBreakoutRoomId: $fromBreakoutRoomId,
|
||||
toBreakoutRoomId: $toBreakoutRoomId,
|
||||
)
|
||||
}
|
||||
`;
|
||||
|
||||
export default { BREAKOUT_ROOM_CREATE, BREAKOUT_ROOM_END_ALL, BREAKOUT_ROOM_MOVE_USER };
|
||||
|
Loading…
Reference in New Issue
Block a user