migrate setPrivateGuestLobbyMessage action

This commit is contained in:
Ramón Souza 2024-01-10 10:21:48 -03:00
parent f557218d7e
commit 5c428f257d
8 changed files with 26 additions and 50 deletions

View File

@ -1,9 +0,0 @@
import { Mongo } from 'meteor/mongo';
const collectionOptions = Meteor.isClient ? {
connection: null,
} : {};
const GuestUsers = new Mongo.Collection('guestUsers', collectionOptions);
export default GuestUsers;

View File

@ -1 +0,0 @@
import './methods';

View File

@ -1,6 +0,0 @@
import { Meteor } from 'meteor/meteor';
import setPrivateGuestLobbyMessage from '/imports/api/guest-users/server/methods/setPrivateGuestLobbyMessage';
Meteor.methods({
setPrivateGuestLobbyMessage,
});

View File

@ -1,27 +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 { extractCredentials, parseMessage } from '/imports/api/common/server/helpers';
const REDIS_CONFIG = Meteor.settings.private.redis;
const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
const EVENT_NAME = 'SetPrivateGuestLobbyMessageCmdMsg';
export default function setPrivateGuestLobbyMessage(message, guestId) {
check(message, String);
check(guestId, String);
const { meetingId, requesterUserId } = extractCredentials(this.userId);
check(meetingId, String);
check(requesterUserId, String);
const payload = { guestId, message: parseMessage(message) };
Logger.info(`User=${requesterUserId} sent a private guest lobby message to guest user=${guestId}`);
return RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, requesterUserId, payload);
}

View File

@ -29,4 +29,18 @@ export const SET_LOBBY_MESSAGE = gql`
}
`;
export default { SET_POLICY, SUBMIT_APPROVAL_STATUS, SET_LOBBY_MESSAGE };
export const SET_LOBBY_MESSAGE_PRIVATE = gql`
mutation SetLobbyMessage($guestId: String!, $message: String!) {
guestUsersSetLobbyMessagePrivate(
guestId: $guestId,
message: $message,
)
}
`;
export default {
SET_POLICY,
SUBMIT_APPROVAL_STATUS,
SET_LOBBY_MESSAGE,
SET_LOBBY_MESSAGE_PRIVATE,
};

View File

@ -1,6 +1,5 @@
import Meetings from '/imports/api/meetings';
import Auth from '/imports/ui/services/auth';
import { makeCall } from '/imports/ui/services/api';
const getGuestPolicy = () => {
const meeting = Meetings.findOne(
@ -29,8 +28,6 @@ const getGuestLobbyMessage = () => {
return '';
};
const setPrivateGuestLobbyMessage = (message, guestId) => makeCall('setPrivateGuestLobbyMessage', message, guestId);
const privateMessageVisible = (id) => {
const privateInputSpace = document.getElementById(id);
if (privateInputSpace.style.display === 'block') {
@ -46,6 +43,5 @@ export default {
isWaitingRoomEnabled,
isGuestLobbyMessageEnabled,
getGuestLobbyMessage,
setPrivateGuestLobbyMessage,
allowRememberChoice,
};

View File

@ -19,7 +19,6 @@ import { ACTIONS, PANELS } from '../../layout/enums';
import Styled from './styles';
import {
privateMessageVisible,
setPrivateGuestLobbyMessage,
} from './service';
import browserInfo from '/imports/utils/browserInfo';
import Header from '/imports/ui/components/common/control-header/component';
@ -31,6 +30,7 @@ import {
SET_POLICY,
SUBMIT_APPROVAL_STATUS,
SET_LOBBY_MESSAGE,
SET_LOBBY_MESSAGE_PRIVATE,
} from '../mutations';
// @ts-ignore - temporary, while meteor exists in the project
@ -171,6 +171,7 @@ const GuestUsersManagementPanel: React.FC<GuestUsersManagementPanelProps> = ({
const [setPolicy] = useMutation(SET_POLICY);
const [submitApprovalStatus] = useMutation(SUBMIT_APPROVAL_STATUS);
const [setLobbyMessage] = useMutation(SET_LOBBY_MESSAGE);
const [setLobbyMessagePrivate] = useMutation(SET_LOBBY_MESSAGE_PRIVATE);
const guestUsersCall = useCallback((users: GuestWaitingUser[], status: string) => {
const guests = users.map((user) => ({
@ -193,6 +194,15 @@ const GuestUsersManagementPanel: React.FC<GuestUsersManagementPanelProps> = ({
});
}, []);
const setPrivateGuestLobbyMessage = useCallback((message: string, guestId: string) => {
setLobbyMessagePrivate({
variables: {
guestId,
message,
},
});
}, []);
const existPendingUsers = authedGuestUsers.length > 0 || unauthedGuestUsers.length > 0;
const closePanel = useCallback(() => {

View File

@ -26,7 +26,6 @@ import '/imports/api/timer/server';
import '/imports/api/audio-captions/server';
import '/imports/api/external-videos/server';
import '/imports/api/pads/server';
import '/imports/api/guest-users/server';
import '/imports/api/local-settings/server';
import '/imports/api/voice-call-states/server';
import '/imports/api/user-reaction/server';