87 lines
3.0 KiB
JavaScript
Executable File
87 lines
3.0 KiB
JavaScript
Executable File
import Users from '/imports/api/users';
|
|
import Auth from '/imports/ui/services/auth';
|
|
import AudioManager from '/imports/ui/services/audio-manager';
|
|
import Meetings from '/imports/api/meetings';
|
|
import mapUser from '/imports/ui/services/user/mapUser';
|
|
import { makeCall } from '/imports/ui/services/api';
|
|
import VoiceUsers from '/imports/api/voice-users';
|
|
import logger from '/imports/startup/client/logger';
|
|
|
|
const ROLE_MODERATOR = Meteor.settings.public.user.role_moderator;
|
|
|
|
const init = (messages, intl) => {
|
|
AudioManager.setAudioMessages(messages, intl);
|
|
if (AudioManager.initialized) return;
|
|
const meetingId = Auth.meetingID;
|
|
const userId = Auth.userID;
|
|
const { sessionToken } = Auth;
|
|
const User = Users.findOne({ userId });
|
|
const username = User.name;
|
|
const Meeting = Meetings.findOne({ meetingId: User.meetingId });
|
|
const voiceBridge = Meeting.voiceProp.voiceConf;
|
|
|
|
// FIX ME
|
|
const microphoneLockEnforced = false;
|
|
|
|
const userData = {
|
|
meetingId,
|
|
userId,
|
|
sessionToken,
|
|
username,
|
|
voiceBridge,
|
|
microphoneLockEnforced,
|
|
};
|
|
|
|
AudioManager.init(userData);
|
|
};
|
|
|
|
const currentUser = () => mapUser(Users.findOne({ intId: Auth.userID }));
|
|
|
|
const toggleMuteMicrophone = () => {
|
|
const userIsMuted = VoiceUsers.findOne({
|
|
meetingId: Auth.meetingID, intId: Auth.userID,
|
|
}, { fields: { muted: 1 } });
|
|
|
|
if (userIsMuted) {
|
|
logger.info({
|
|
logCode: 'audiomanager_unmute_audio',
|
|
extraInfo: { logType: 'user_action' },
|
|
}, 'microphone unmuted by user');
|
|
makeCall('toggleSelfVoice');
|
|
} else {
|
|
logger.info({
|
|
logCode: 'audiomanager_mute_audio',
|
|
extraInfo: { logType: 'user_action' },
|
|
}, 'microphone muted by user');
|
|
makeCall('toggleSelfVoice');
|
|
}
|
|
};
|
|
|
|
export default {
|
|
init,
|
|
exitAudio: () => AudioManager.exitAudio(),
|
|
transferCall: () => AudioManager.transferCall(),
|
|
joinListenOnly: () => AudioManager.joinListenOnly(),
|
|
joinMicrophone: () => AudioManager.joinMicrophone(),
|
|
joinEchoTest: () => AudioManager.joinEchoTest(),
|
|
toggleMuteMicrophone,
|
|
changeInputDevice: inputDeviceId => AudioManager.changeInputDevice(inputDeviceId),
|
|
changeOutputDevice: outputDeviceId => AudioManager.changeOutputDevice(outputDeviceId),
|
|
isConnected: () => AudioManager.isConnected,
|
|
isTalking: () => AudioManager.isTalking,
|
|
isHangingUp: () => AudioManager.isHangingUp,
|
|
isUsingAudio: () => AudioManager.isUsingAudio(),
|
|
isWaitingPermissions: () => AudioManager.isWaitingPermissions,
|
|
isMuted: () => AudioManager.isMuted,
|
|
isConnecting: () => AudioManager.isConnecting,
|
|
isListenOnly: () => AudioManager.isListenOnly,
|
|
inputDeviceId: () => AudioManager.inputDeviceId,
|
|
outputDeviceId: () => AudioManager.outputDeviceId,
|
|
isEchoTest: () => AudioManager.isEchoTest,
|
|
error: () => AudioManager.error,
|
|
isUserModerator: () => Users.findOne({ userId: Auth.userID }).role === ROLE_MODERATOR,
|
|
currentUser,
|
|
autoplayBlocked: () => AudioManager.autoplayBlocked,
|
|
handleAllowAutoplay: () => AudioManager.handleAllowAutoplay(),
|
|
};
|