2017-10-12 10:00:28 +08:00
|
|
|
import Users from '/imports/api/users';
|
2017-04-19 23:01:28 +08:00
|
|
|
import Auth from '/imports/ui/services/auth';
|
2017-10-13 03:22:10 +08:00
|
|
|
import AudioManager from '/imports/ui/services/audio-manager';
|
2017-10-12 10:00:28 +08:00
|
|
|
import Meetings from '/imports/api/meetings';
|
2018-07-10 03:23:16 +08:00
|
|
|
import mapUser from '/imports/ui/services/user/mapUser';
|
2017-03-28 22:02:23 +08:00
|
|
|
|
2017-10-19 03:40:01 +08:00
|
|
|
const init = (messages) => {
|
2018-04-20 03:57:54 +08:00
|
|
|
AudioManager.setAudioMessages(messages);
|
2017-11-18 03:01:52 +08:00
|
|
|
if (AudioManager.initialized) return;
|
2017-10-12 20:50:23 +08:00
|
|
|
const meetingId = Auth.meetingID;
|
2017-04-19 23:01:28 +08:00
|
|
|
const userId = Auth.userID;
|
2018-03-06 04:00:52 +08:00
|
|
|
const { sessionToken } = Auth;
|
2017-04-19 23:01:28 +08:00
|
|
|
const User = Users.findOne({ userId });
|
2017-07-26 22:31:35 +08:00
|
|
|
const username = User.name;
|
2017-07-18 22:59:05 +08:00
|
|
|
const Meeting = Meetings.findOne({ meetingId: User.meetingId });
|
|
|
|
const voiceBridge = Meeting.voiceProp.voiceConf;
|
2017-04-19 23:01:28 +08:00
|
|
|
|
2017-07-13 02:51:29 +08:00
|
|
|
// FIX ME
|
2017-07-18 22:59:05 +08:00
|
|
|
const microphoneLockEnforced = false;
|
2017-04-19 22:59:57 +08:00
|
|
|
|
2017-04-19 23:01:28 +08:00
|
|
|
const userData = {
|
2017-10-12 20:50:23 +08:00
|
|
|
meetingId,
|
2017-04-19 23:01:28 +08:00
|
|
|
userId,
|
2017-09-29 21:38:10 +08:00
|
|
|
sessionToken,
|
2017-04-19 23:01:28 +08:00
|
|
|
username,
|
|
|
|
voiceBridge,
|
2017-05-04 04:12:47 +08:00
|
|
|
microphoneLockEnforced,
|
2017-04-19 23:01:28 +08:00
|
|
|
};
|
|
|
|
|
2018-04-20 03:57:54 +08:00
|
|
|
AudioManager.init(userData);
|
2017-04-19 23:01:28 +08:00
|
|
|
};
|
2017-04-19 22:59:57 +08:00
|
|
|
|
2018-07-10 03:23:16 +08:00
|
|
|
const audioLocked = () => {
|
|
|
|
const userId = Auth.userID;
|
|
|
|
const User = mapUser(Users.findOne({ userId }));
|
|
|
|
|
|
|
|
const Meeting = Meetings.findOne({ meetingId: Auth.meetingID });
|
2018-07-24 02:54:49 +08:00
|
|
|
const lockSetting = Meeting.lockSettingsProp;
|
2018-07-12 22:35:37 +08:00
|
|
|
const audioLock = lockSetting ? lockSetting.disableMic : false;
|
2018-07-10 03:23:16 +08:00
|
|
|
|
|
|
|
return audioLock && User.isLocked;
|
|
|
|
};
|
|
|
|
|
2017-05-03 01:18:01 +08:00
|
|
|
export default {
|
2017-04-19 22:59:57 +08:00
|
|
|
init,
|
2017-09-20 01:47:57 +08:00
|
|
|
exitAudio: () => AudioManager.exitAudio(),
|
2017-10-12 20:50:23 +08:00
|
|
|
transferCall: () => AudioManager.transferCall(),
|
2018-03-16 02:57:25 +08:00
|
|
|
joinListenOnly: () => AudioManager.joinListenOnly(),
|
|
|
|
joinMicrophone: () => AudioManager.joinMicrophone(),
|
|
|
|
joinEchoTest: () => AudioManager.joinEchoTest(),
|
2017-09-20 01:47:57 +08:00
|
|
|
toggleMuteMicrophone: () => AudioManager.toggleMuteMicrophone(),
|
2017-10-11 02:03:29 +08:00
|
|
|
changeInputDevice: inputDeviceId => AudioManager.changeInputDevice(inputDeviceId),
|
|
|
|
changeOutputDevice: outputDeviceId => AudioManager.changeOutputDevice(outputDeviceId),
|
2017-09-20 01:47:57 +08:00
|
|
|
isConnected: () => AudioManager.isConnected,
|
2018-06-20 23:36:26 +08:00
|
|
|
isTalking: () => AudioManager.isTalking,
|
2017-10-27 01:14:56 +08:00
|
|
|
isHangingUp: () => AudioManager.isHangingUp,
|
2018-06-20 23:36:26 +08:00
|
|
|
isUsingAudio: () => AudioManager.isUsingAudio(),
|
2017-11-09 02:41:15 +08:00
|
|
|
isWaitingPermissions: () => AudioManager.isWaitingPermissions,
|
2017-09-20 01:47:57 +08:00
|
|
|
isMuted: () => AudioManager.isMuted,
|
|
|
|
isConnecting: () => AudioManager.isConnecting,
|
|
|
|
isListenOnly: () => AudioManager.isListenOnly,
|
|
|
|
inputDeviceId: () => AudioManager.inputDeviceId,
|
|
|
|
outputDeviceId: () => AudioManager.outputDeviceId,
|
2017-09-29 21:38:10 +08:00
|
|
|
isEchoTest: () => AudioManager.isEchoTest,
|
2017-10-11 20:05:57 +08:00
|
|
|
error: () => AudioManager.error,
|
2018-03-06 04:00:52 +08:00
|
|
|
isUserModerator: () => Users.findOne({ userId: Auth.userID }).moderator,
|
2018-07-10 03:23:16 +08:00
|
|
|
audioLocked,
|
2017-09-29 21:42:08 +08:00
|
|
|
};
|