migrate setExitReason meteor call
This commit is contained in:
parent
ce5bb3aaf5
commit
b9d4841b26
@ -5,7 +5,6 @@ import setUserEffectiveConnectionType from './methods/setUserEffectiveConnection
|
||||
import userActivitySign from './methods/userActivitySign';
|
||||
import userLeftMeeting from './methods/userLeftMeeting';
|
||||
import setRandomUser from './methods/setRandomUser';
|
||||
import setExitReason from './methods/setExitReason';
|
||||
|
||||
Meteor.methods({
|
||||
setSpeechLocale,
|
||||
@ -14,5 +13,4 @@ Meteor.methods({
|
||||
userActivitySign,
|
||||
userLeftMeeting,
|
||||
setRandomUser,
|
||||
setExitReason,
|
||||
});
|
||||
|
@ -1,21 +0,0 @@
|
||||
import { check } from 'meteor/check';
|
||||
import Logger from '/imports/startup/server/logger';
|
||||
import { extractCredentials } from '/imports/api/common/server/helpers';
|
||||
import setUserExitReason from '/imports/api/users/server/modifiers/setUserExitReason';
|
||||
|
||||
export default async function setExitReason(reason) {
|
||||
try {
|
||||
const { meetingId, requesterUserId } = extractCredentials(this.userId);
|
||||
|
||||
// Unauthenticated user, just ignore and go ahead.
|
||||
if (!meetingId || !requesterUserId) return;
|
||||
|
||||
check(meetingId, String);
|
||||
check(requesterUserId, String);
|
||||
check(reason, String);
|
||||
|
||||
await setUserExitReason(meetingId, requesterUserId, reason);
|
||||
} catch (err) {
|
||||
Logger.error(`Exception while invoking method setExitReason ${err.stack}`);
|
||||
}
|
||||
}
|
@ -20,8 +20,9 @@ import VideoService from '/imports/ui/components/video-provider/service';
|
||||
import DebugWindow from '/imports/ui/components/debug-window/component';
|
||||
import { ACTIONS, PANELS } from '../../ui/components/layout/enums';
|
||||
import { isChatEnabled } from '/imports/ui/services/features';
|
||||
import { makeCall } from '/imports/ui/services/api';
|
||||
import BBBStorage from '/imports/ui/services/storage';
|
||||
import { useMutation } from '@apollo/client';
|
||||
import { SET_EXIT_REASON } from '/imports/ui/core/graphql/mutations/userMutations';
|
||||
|
||||
const CHAT_CONFIG = Meteor.settings.public.chat;
|
||||
const PUBLIC_CHAT_ID = CHAT_CONFIG.public_group_id;
|
||||
@ -241,10 +242,6 @@ class Base extends Component {
|
||||
});
|
||||
}
|
||||
|
||||
static async setExitReason(reason) {
|
||||
return await makeCall('setExitReason', reason);
|
||||
}
|
||||
|
||||
renderByState() {
|
||||
const { loading, userRemoved } = this.state;
|
||||
const {
|
||||
@ -257,6 +254,7 @@ class Base extends Component {
|
||||
meetingIsBreakout,
|
||||
subscriptionsReady,
|
||||
userWasEjected,
|
||||
setUserExitReason,
|
||||
} = this.props;
|
||||
|
||||
if ((loading || !subscriptionsReady) && !meetingHasEnded && meetingExist) {
|
||||
@ -264,7 +262,7 @@ class Base extends Component {
|
||||
}
|
||||
|
||||
if (( meetingHasEnded || ejected || userRemoved ) && meetingIsBreakout) {
|
||||
Base.setExitReason('breakoutEnded').finally(() => {
|
||||
setUserExitReason('breakoutEnded', () => {
|
||||
Meteor.disconnect();
|
||||
window.close();
|
||||
});
|
||||
@ -276,7 +274,7 @@ class Base extends Component {
|
||||
<MeetingEnded
|
||||
code="403"
|
||||
ejectedReason={ejectedReason}
|
||||
callback={() => Base.setExitReason('ejected')}
|
||||
callback={() => setUserExitReason('ejected')}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@ -286,7 +284,7 @@ class Base extends Component {
|
||||
<MeetingEnded
|
||||
code={codeError}
|
||||
endedReason={meetingEndedReason}
|
||||
callback={() => Base.setExitReason('meetingEnded')}
|
||||
callback={() => setUserExitReason('meetingEnded')}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@ -294,9 +292,9 @@ class Base extends Component {
|
||||
if ((codeError && !meetingHasEnded) || userWasEjected) {
|
||||
// 680 is set for the codeError when the user requests a logout.
|
||||
if (codeError !== '680') {
|
||||
return (<ErrorScreen code={codeError} callback={() => Base.setExitReason('error')} />);
|
||||
return (<ErrorScreen code={codeError} callback={setUserExitReason} endedReason="error" />);
|
||||
}
|
||||
return (<MeetingEnded code={codeError} callback={() => Base.setExitReason('logout')} />);
|
||||
return (<MeetingEnded code={codeError} callback={setUserExitReason} endedReason="logout" />);
|
||||
}
|
||||
|
||||
return (<AppContainer {...this.props} />);
|
||||
@ -330,7 +328,15 @@ const BaseContainer = (props) => {
|
||||
const { sidebarContentPanel } = sidebarContent;
|
||||
const layoutContextDispatch = layoutDispatch();
|
||||
|
||||
return <Base {...{ sidebarContentPanel, layoutContextDispatch, ...props }} />;
|
||||
const [setExitReason] = useMutation(SET_EXIT_REASON);
|
||||
|
||||
const setUserExitReason = (exitReason, callback) => {
|
||||
setExitReason({ variables: { exitReason } }).then(() => {
|
||||
if (callback) callback();
|
||||
});
|
||||
};
|
||||
|
||||
return <Base {...{ sidebarContentPanel, layoutContextDispatch, setUserExitReason, ...props }} />;
|
||||
};
|
||||
|
||||
export default withTracker(() => {
|
||||
|
@ -84,17 +84,16 @@ const propTypes = {
|
||||
|
||||
const defaultProps = {
|
||||
code: '500',
|
||||
callback: async () => {},
|
||||
callback: () => {},
|
||||
endedReason: null,
|
||||
};
|
||||
|
||||
class ErrorScreen extends PureComponent {
|
||||
componentDidMount() {
|
||||
const { code, callback } = this.props;
|
||||
const { code, callback, endedReason } = this.props;
|
||||
const log = code === '403' ? 'warn' : 'error';
|
||||
AudioManager.exitAudio();
|
||||
callback().finally(() => {
|
||||
Meteor.disconnect();
|
||||
});
|
||||
callback(endedReason, () => Meteor.disconnect());
|
||||
logger[log]({ logCode: 'startup_client_usercouldnotlogin_error' }, `User could not log in HTML5, hit ${code}`);
|
||||
}
|
||||
|
||||
|
@ -120,7 +120,7 @@ const propTypes = {
|
||||
const defaultProps = {
|
||||
ejectedReason: null,
|
||||
endedReason: null,
|
||||
callback: async () => {},
|
||||
callback: () => {},
|
||||
};
|
||||
|
||||
class MeetingEnded extends PureComponent {
|
||||
@ -164,9 +164,8 @@ class MeetingEnded extends PureComponent {
|
||||
AudioManager.exitAudio();
|
||||
Storage.removeItem('getEchoTest');
|
||||
Storage.removeItem('isFirstJoin');
|
||||
this.props.callback().finally(() => {
|
||||
Meteor.disconnect();
|
||||
});
|
||||
const { callback, endedReason } = this.props;
|
||||
callback(endedReason, () => Meteor.disconnect());
|
||||
}
|
||||
|
||||
setSelectedStar(starNumber) {
|
||||
|
@ -89,6 +89,14 @@ export const CLEAR_ALL_REACTION = gql`
|
||||
}
|
||||
`;
|
||||
|
||||
export const SET_EXIT_REASON = gql`
|
||||
mutation SetExitReason($exitReason: String!) {
|
||||
userSetExitReason(
|
||||
exitReason: $exitReason,
|
||||
)
|
||||
}
|
||||
`;
|
||||
|
||||
export default {
|
||||
SET_CAMERA_PINNED,
|
||||
SET_RAISE_HAND,
|
||||
@ -101,4 +109,5 @@ export default {
|
||||
SET_LOCKED,
|
||||
CLEAR_ALL_EMOJI,
|
||||
CLEAR_ALL_REACTION,
|
||||
SET_EXIT_REASON,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user