Remove: voice call state

This commit is contained in:
Tainan Felipe 2024-04-22 23:20:45 -03:00
parent 4b2df4738e
commit 80397964aa
12 changed files with 4 additions and 213 deletions

View File

@ -1,17 +1,10 @@
import { Tracker } from 'meteor/tracker';
import VoiceCallStates from '/imports/api/voice-call-states';
import CallStateOptions from '/imports/api/voice-call-states/utils/callStates';
import logger from '/imports/startup/client/logger';
import Auth from '/imports/ui/services/auth';
import {
getAudioConstraints,
doGUM,
} from '/imports/api/audio/client/bridge/service';
const MEDIA = Meteor.settings.public.media;
const BASE_BRIDGE_NAME = 'base';
const CALL_TRANSFER_TIMEOUT = MEDIA.callTransferTimeout;
const TRANSFER_TONE = '1';
export default class BaseAudioBridge {
constructor(userData) {
@ -134,44 +127,9 @@ export default class BaseAudioBridge {
}
trackTransferState(transferCallback) {
return new Promise((resolve, reject) => {
let trackerControl = null;
const timeout = setTimeout(() => {
trackerControl.stop();
logger.warn({ logCode: 'audio_transfer_timed_out' },
'Timeout on transferring from echo test to conference');
this.callback({
status: this.baseCallStates.failed,
error: 1008,
bridgeError: 'Timeout on call transfer',
bridge: this.bridgeName,
});
this.exitAudio();
reject(this.baseErrorCodes.REQUEST_TIMEOUT);
}, CALL_TRANSFER_TIMEOUT);
this.sendDtmf(TRANSFER_TONE);
Tracker.autorun((c) => {
trackerControl = c;
const selector = { meetingId: Auth.meetingID, userId: Auth.userID };
const query = VoiceCallStates.find(selector);
query.observeChanges({
changed: (id, fields) => {
if (fields.callState === CallStateOptions.IN_CONFERENCE) {
clearTimeout(timeout);
transferCallback();
c.stop();
resolve();
}
},
});
});
return new Promise((resolve) => {
transferCallback();
resolve();
});
}
}

View File

@ -14,13 +14,8 @@ import {
logSelectedCandidate,
forceDisableStereo,
} from '/imports/utils/sdpUtils';
import { Tracker } from 'meteor/tracker';
import VoiceCallStates from '/imports/api/voice-call-states';
import CallStateOptions from '/imports/api/voice-call-states/utils/callStates';
import Auth from '/imports/ui/services/auth';
import browserInfo from '/imports/utils/browserInfo';
import {
getCurrentAudioSessionNumber,
getAudioSessionNumber,
getAudioConstraints,
filterSupportedConstraints,
@ -1080,34 +1075,6 @@ class SIPSession {
this._currentSessionState = state;
});
Tracker.autorun((c) => {
const selector = {
meetingId: Auth.meetingID,
userId: Auth.userID,
clientSession: getCurrentAudioSessionNumber(),
};
const query = VoiceCallStates.find(selector);
const callback = (id, fields) => {
if (!fsReady && ((this.inEchoTest && fields.callState === CallStateOptions.IN_ECHO_TEST)
|| (!this.inEchoTest && fields.callState === CallStateOptions.IN_CONFERENCE))) {
fsReady = true;
checkIfCallReady();
}
if (fields.callState === CallStateOptions.CALL_ENDED) {
fsReady = false;
c.stop();
checkIfCallStopped();
}
};
query.observeChanges({
added: (id, fields) => callback(id, fields),
changed: (id, fields) => callback(id, fields),
});
});
resolve();
});
}

View File

@ -13,7 +13,6 @@ import clearScreenshare from '/imports/api/screenshare/server/modifiers/clearScr
import clearTimer from '/imports/api/timer/server/modifiers/clearTimer';
import clearMeetingTimeRemaining from '/imports/api/meetings/server/modifiers/clearMeetingTimeRemaining';
import clearRecordMeeting from './clearRecordMeeting';
import clearVoiceCallStates from '/imports/api/voice-call-states/server/modifiers/clearVoiceCallStates';
import clearVideoStreams from '/imports/api/video-streams/server/modifiers/clearVideoStreams';
import clearAuthTokenValidation from '/imports/api/auth-token-validation/server/modifiers/clearAuthTokenValidation';
import clearReactions from '/imports/api/user-reaction/server/modifiers/clearReactions';
@ -28,7 +27,6 @@ export default async function meetingHasEnded(meetingId) {
await Meetings.removeAsync({ meetingId });
await Promise.all([
clearCaptions(meetingId),
clearPads(meetingId),
clearBreakouts(meetingId),
clearUsers(meetingId),
@ -38,7 +36,6 @@ export default async function meetingHasEnded(meetingId) {
clearTimer(meetingId),
clearMeetingTimeRemaining(meetingId),
clearRecordMeeting(meetingId),
clearVoiceCallStates(meetingId),
clearVideoStreams(meetingId),
clearAuthTokenValidation(meetingId),
clearWhiteboardMultiUser(meetingId),

View File

@ -1,13 +0,0 @@
import { Meteor } from 'meteor/meteor';
const VoiceCallStates = new Mongo.Collection('voiceCallStates');
if (Meteor.isServer) {
// types of queries for the voice users:
// 1. intId
// 2. meetingId, intId
VoiceCallStates.createIndexAsync({ meetingId: 1, userId: 1 });
}
export default VoiceCallStates;

View File

@ -1,4 +0,0 @@
import RedisPubSub from '/imports/startup/server/redis';
import handleVoiceCallStateEvent from './handlers/voiceCallStateEvent';
RedisPubSub.on('VoiceCallStateEvtMsg', handleVoiceCallStateEvent);

View File

@ -1,50 +0,0 @@
import { check } from 'meteor/check';
import VoiceCallState from '/imports/api/voice-call-states';
import Logger from '/imports/startup/server/logger';
// "CALL_STARTED", "IN_ECHO_TEST", "IN_CONFERENCE", "CALL_ENDED"
export default async function handleVoiceCallStateEvent({ body }, meetingId) {
const {
voiceConf,
clientSession,
userId,
callerName,
callState,
} = body;
check(meetingId, String);
check(voiceConf, String);
check(clientSession, String);
check(userId, String);
check(callerName, String);
check(callState, String);
const selector = {
meetingId,
userId,
clientSession,
};
const modifier = {
$set: {
meetingId,
userId,
voiceConf,
clientSession,
callState,
},
};
try {
const { numberAffected } = await VoiceCallState.upsertAsync(selector, modifier);
if (numberAffected) {
Logger.debug('Update voice call', {
state: userId, meetingId, clientSession, callState,
});
}
} catch (err) {
Logger.error(`Update voice call state=${userId}: ${err}`);
}
}

View File

@ -1,2 +0,0 @@
import './eventHandlers';
import './publishers';

View File

@ -1,26 +0,0 @@
import Logger from '/imports/startup/server/logger';
import VoiceCallStates from '/imports/api/voice-call-states';
export default async function clearVoiceCallStates(meetingId) {
if (meetingId) {
try {
const numberAffected = await VoiceCallStates.removeAsync({ meetingId });
if (numberAffected) {
Logger.info(`Cleared VoiceCallStates in (${meetingId})`);
}
} catch (err) {
Logger.info(`Error on clearing VoiceCallStates in (${meetingId}). ${err}`);
}
} else {
try {
const numberAffected = await VoiceCallStates.removeAsync({});
if (numberAffected) {
Logger.info('Cleared VoiceCallStates in all meetings');
}
} catch (err) {
Logger.error(`Error on clearing VoiceCallStates in all meetings. ${err}`);
}
}
}

View File

@ -1,27 +0,0 @@
import VoiceCallStates from '/imports/api/voice-call-states';
import { Meteor } from 'meteor/meteor';
import Logger from '/imports/startup/server/logger';
import AuthTokenValidation, { ValidationStates } from '/imports/api/auth-token-validation';
async function voiceCallStates() {
const tokenValidation = await AuthTokenValidation
.findOneAsync({ connectionId: this.connection.id });
if (!tokenValidation || tokenValidation.validationStatus !== ValidationStates.VALIDATED) {
Logger.warn(`Publishing VoiceCallStates was requested by unauth connection ${this.connection.id}`);
return VoiceCallStates.find({ meetingId: '' });
}
const { meetingId, userId } = tokenValidation;
Logger.debug('Publishing Voice Call States', { meetingId, userId });
return VoiceCallStates.find({ meetingId, userId });
}
function publish(...args) {
const boundVoiceCallStates = voiceCallStates.bind(this);
return boundVoiceCallStates(...args);
}
Meteor.publish('voice-call-states', publish);

View File

@ -1,8 +0,0 @@
const CallStateOptions = {
CALL_STARTED: 'CALL_STARTED',
IN_ECHO_TEST: 'IN_ECHO_TEST',
IN_CONFERENCE: 'IN_CONFERENCE',
CALL_ENDED: 'CALL_ENDED',
};
export default CallStateOptions;

View File

@ -22,7 +22,7 @@ const SUBSCRIPTIONS = [
'meeting-time-remaining',
'record-meetings',
'video-streams',
'voice-call-states',
// 'voice-call-states',
'breakouts',
// 'breakouts-history',
'pads',

View File

@ -14,7 +14,6 @@ import '/imports/api/users-infos/server';
import '/imports/api/connection-status/server';
import '/imports/api/timer/server';
import '/imports/api/pads/server';
import '/imports/api/voice-call-states/server';
import '/imports/api/user-reaction/server';
// Commons