migrate allowPendingUsers action
This commit is contained in:
parent
326a4a06b2
commit
a5ede6429c
@ -1,10 +1,8 @@
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
import allowPendingUsers from '/imports/api/guest-users/server/methods/allowPendingUsers';
|
||||
import setGuestLobbyMessage from '/imports/api/guest-users/server/methods/setGuestLobbyMessage';
|
||||
import setPrivateGuestLobbyMessage from '/imports/api/guest-users/server/methods/setPrivateGuestLobbyMessage';
|
||||
|
||||
Meteor.methods({
|
||||
allowPendingUsers,
|
||||
setGuestLobbyMessage,
|
||||
setPrivateGuestLobbyMessage,
|
||||
});
|
||||
|
@ -1,31 +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 } from '/imports/api/common/server/helpers';
|
||||
|
||||
const REDIS_CONFIG = Meteor.settings.private.redis;
|
||||
const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
|
||||
const EVENT_NAME = 'GuestsWaitingApprovedMsg';
|
||||
|
||||
export default function allowPendingUsers(guests, status) {
|
||||
try {
|
||||
const { meetingId, requesterUserId } = extractCredentials(this.userId);
|
||||
|
||||
check(meetingId, String);
|
||||
check(requesterUserId, String);
|
||||
check(guests, Array);
|
||||
const mappedGuests = guests.map((guest) => ({ status, guest: guest.userId }));
|
||||
|
||||
const payload = {
|
||||
approvedBy: requesterUserId,
|
||||
guests: mappedGuests,
|
||||
};
|
||||
|
||||
Logger.info(`User=${requesterUserId} ${status} guests ${JSON.stringify(mappedGuests)}`);
|
||||
|
||||
RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, requesterUserId, payload);
|
||||
} catch (err) {
|
||||
Logger.error(`Exception while invoking method allowPendingUsers ${err.stack}`);
|
||||
}
|
||||
}
|
@ -1,5 +1,10 @@
|
||||
import { gql } from '@apollo/client';
|
||||
|
||||
export interface GuestUserApprovalStatus {
|
||||
guest: string;
|
||||
status: string;
|
||||
}
|
||||
|
||||
export const SET_POLICY = gql`
|
||||
mutation SetPolicy($guestPolicy: String!) {
|
||||
guestUsersSetPolicy(
|
||||
@ -8,4 +13,12 @@ export const SET_POLICY = gql`
|
||||
}
|
||||
`;
|
||||
|
||||
export default { SET_POLICY };
|
||||
export const SUBMIT_APPROVAL_STATUS = gql`
|
||||
mutation SubmitApprovalStatus($guests: [GuestUserApprovalStatus]!) {
|
||||
guestUsersSubmitApprovalStatus(
|
||||
guests: $guests,
|
||||
)
|
||||
}
|
||||
`;
|
||||
|
||||
export default { SET_POLICY, SUBMIT_APPROVAL_STATUS };
|
||||
|
@ -2,8 +2,6 @@ import Meetings from '/imports/api/meetings';
|
||||
import Auth from '/imports/ui/services/auth';
|
||||
import { makeCall } from '/imports/ui/services/api';
|
||||
|
||||
const guestUsersCall = (guestsArray, status) => makeCall('allowPendingUsers', guestsArray, status);
|
||||
|
||||
const getGuestPolicy = () => {
|
||||
const meeting = Meetings.findOne(
|
||||
{ meetingId: Auth.meetingID },
|
||||
@ -45,7 +43,6 @@ const privateMessageVisible = (id) => {
|
||||
};
|
||||
|
||||
export default {
|
||||
guestUsersCall,
|
||||
privateMessageVisible,
|
||||
getGuestPolicy,
|
||||
isWaitingRoomEnabled,
|
||||
|
@ -18,7 +18,6 @@ import { layoutDispatch } from '../../layout/context';
|
||||
import { ACTIONS, PANELS } from '../../layout/enums';
|
||||
import Styled from './styles';
|
||||
import {
|
||||
guestUsersCall,
|
||||
privateMessageVisible,
|
||||
setGuestLobbyMessage,
|
||||
setPrivateGuestLobbyMessage,
|
||||
@ -29,7 +28,7 @@ import TextInput from '/imports/ui/components/text-input/component';
|
||||
import renderNoUserWaitingItem from './guest-items/noPendingGuestUser';
|
||||
import renderPendingUsers from './guest-items/guestPendingUser';
|
||||
import logger from '/imports/startup/client/logger';
|
||||
import { SET_POLICY } from '../mutations';
|
||||
import { SET_POLICY, SUBMIT_APPROVAL_STATUS } from '../mutations';
|
||||
|
||||
// @ts-ignore - temporary, while meteor exists in the project
|
||||
const isGuestLobbyMessageEnabled = Meteor.settings.public.app.enableGuestLobbyMessage;
|
||||
@ -167,6 +166,20 @@ const GuestUsersManagementPanel: React.FC<GuestUsersManagementPanelProps> = ({
|
||||
const { isChrome } = browserInfo;
|
||||
const [rememberChoice, setRememberChoice] = useState(false);
|
||||
const [setPolicy] = useMutation(SET_POLICY);
|
||||
const [submitApprovalStatus] = useMutation(SUBMIT_APPROVAL_STATUS);
|
||||
|
||||
const guestUsersCall = useCallback((users: GuestWaitingUser[], status: string) => {
|
||||
const guests = users.map((user) => ({
|
||||
guest: user.user.userId,
|
||||
status,
|
||||
}));
|
||||
|
||||
submitApprovalStatus({
|
||||
variables: {
|
||||
guests,
|
||||
},
|
||||
});
|
||||
}, []);
|
||||
|
||||
const existPendingUsers = authedGuestUsers.length > 0 || unauthedGuestUsers.length > 0;
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
import { GuestWaitingUser } from './queries';
|
||||
import { makeCall } from '/imports/ui/services/api';
|
||||
|
||||
export const privateMessageVisible = (id: string) => {
|
||||
@ -18,15 +17,12 @@ export const getNameInitials = (name: string) => {
|
||||
return nameInitials.replace(/^\w/, (c: string) => c.toUpperCase());
|
||||
};
|
||||
|
||||
export const guestUsersCall = (guestsArray: GuestWaitingUser[], status: string) => makeCall('allowPendingUsers', guestsArray, status);
|
||||
|
||||
export const setGuestLobbyMessage = (message: string) => makeCall('setGuestLobbyMessage', message);
|
||||
|
||||
export const setPrivateGuestLobbyMessage = (message: string, guestId: string) => makeCall('setPrivateGuestLobbyMessage', message, guestId);
|
||||
|
||||
export default {
|
||||
privateMessageVisible,
|
||||
guestUsersCall,
|
||||
setGuestLobbyMessage,
|
||||
getNameInitials,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user