Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
save_ami: function (host, port, user, pass) {
if (!Meteor.userId() || !Roles.userIsInRole(Meteor.userId(), ['admin'])) {
throw new Meteor.Error("not-authorized");
}
check(host, String);
check(port, String);
check(user, String);
check(pass, String);
const ami = new asterisk(
port,
host,
user,
pass,
true); // This parameter determines whether events are emitted.
if (ami) {
ami.keepConnected();
ami.on('error', function (err) {
console.log('ERROR', err);
});
ami.action({
'action': 'ping'
},
Meteor.bindEnvironment((err, res) => {
if (err) {
function StartAMI() {
const amiserver = ServerSettings.find({
'module': 'ami'
}).fetch()[0];
if (amiserver) {
if (amiserver.port && amiserver.host && amiserver.user && amiserver.pass) {
const ami = new asterisk(
amiserver.port,
amiserver.host,
amiserver.user,
amiserver.pass,
true); // This parameter determines whether events are emited.
ami.keepConnected();
/*
TODO:
Create different collections for each event type or use the AmiLog for everything and then filter events?
A list of event names can be found at
https://wiki.asterisk.org/wiki/display/AST/Asterisk+11+AMI+Events
*/
//AmiLog._ensureIndex( { 'starmon_timestamp': 1 }, { expireAfterSeconds: 60 } );
ami.on('managerevent', Meteor.bindEnvironment(function (evt) {
conference_mute_user: function (bridgeuniqueid, bridge, channel) {
if (!Meteor.userId()) {
throw new Meteor.Error("not-authorized");
}
check(bridge, Number);
check(channel, String);
var amiserver = ServerSettings.find({
'module': 'ami'
}).fetch()[0];
if (amiserver) {
if (amiserver.port && amiserver.host && amiserver.user && amiserver.pass) {
var ami = new asterisk(
amiserver.port,
amiserver.host,
amiserver.user,
amiserver.pass,
true);
ami.action({
'action': 'confbridgemute',
'conference': bridge,
'channel': channel,
}, Meteor.bindEnvironment(function (err, res) {
if (err) {
throw new Meteor.Error('conf-mute-error', err);
}
ConferenceMembers.update({
'bridgeuniqueid': bridgeuniqueid,
'usernum': user_id,