# xCALLY MOTION Changelog
+- * 5fb560b - 2016-09-13: server side config/ami + config/tools update
+- * 51d6d3e - 2016-09-13: server side update
- * 9750695 - 2016-09-13: fix duplicate events
- * 0cbc254 - 2016-09-13: server side models interval + user
- * 0c84ddb - 2016-09-13: sever side update tools + app.js
// Get list of mailAccounts
exports.index = function(req, res) {
- console.log('index');
return MailAccount
.scope('default')
.findAndCountAll(Util.getQuery(req.query))
var Agent = require('../../models').User;
var Action = require('../../models').Action;
var ReportAgent = require('../../models').ReportAgent;
+
var _voiceQueues;
var _agents;
var activeAcw = {};
function ACW(ami) {
console.log('ACW Initialization...');
- return VoiceQueue
+ VoiceQueue
.findAll()
.then(function(voiceQueues) {
_voiceQueues = voiceQueues;
defaults: evt
})
.spread(function(call, created) {
- console.log('call', call);
if (!created) {
if (evt.answertime) {
});
emitter.on('User.beforeUpdate', function(doc, options) {
- if (doc.changed('internal')) {
+ if (options.changed.internal) {
throw new Error('You can\'t modify the internal of a User/Agent/Telephone');
}
});
emitter.on('User.afterUpdate', function(doc, options) {
- if (!doc.changed('status') && !doc.changed('queueStatus') && !doc.changed('callerid') && !doc.changed('lastLoginAt') && !doc.changed('online')) {
+ if (!options.changed.status &&
+ !options.changed.queueStatus &&
+ !options.changed.callerid &&
+ !options.changed.lastLoginAt &&
+ !options.changed.online) {
return Promise
.all([])
.then(createCallerID(doc, options))
.then(function() {
- if ((doc.chanspy && doc.changed('chanspy'))) {
+ if (doc.chanspy && options.changed.chanspy) {
return createChanspy(doc, options);
}
})
.then(function() {
- if (doc.chanspy && !doc.changed('chanspy') && doc.changed('name')) {
+ if (doc.chanspy && !options.changed.chanspy && options.changed.name) {
return deleteChanSpy(doc, options);
}
})
.then(function() {
- if (doc.chanspy && !doc.changed('chanspy') && doc.changed('name')) {
+ if (doc.chanspy && !options.changed.chanspy && options.changed.name) {
return createChanspy(doc, options);
}
})
.then(function() {
- if (!doc.chanspy && doc.changed('chanspy')) {
+ if (!doc.chanspy && options.changed.chanspy) {
return deleteChanSpy(doc, options);
}
})
function createCallerID(doc, options) {
return function() {
// devo aspettare che ci siano entrambi i campi
- if (doc.fullname && doc.internal && doc.changed('fullname')) {
+ if (doc.fullname && doc.internal && options.changed.fullname) {
console.log('Creating callerID...');
doc.callerid = util.format('"%s" <%s>', doc.fullname, doc.internal);
return doc.save({
}
}, {
tableName: 'users',
- hooks: {
- afterCreate: function(doc) {
- emitter.to(['master']).emit('User.afterCreate', doc);
- },
- afterUpdate: function(doc) {
- emitter.to(['master']).emit('User.afterUpdate', doc);
- },
- afterDestroy: function(doc) {
- emitter.to(['master']).emit('User.afterDestroy', doc);
- }
- },
instanceMethods: {
/**
* Authenticate - check if the passwords are the same
return scope;
});
},
- afterCreate: function(doc, options) {
- emitter.to(['master']).emit('User.afterCreate', doc, {
- body: options.body
- });
- },
- afterUpdate: function(doc, options) {
- emitter.to(['master']).emit('User.afterUpdate', doc);
- },
- afterDestroy: function(doc, options) {
- emitter.to(['master']).emit('User.afterDestroy', doc);
+ hooks: {
+ afterCreate: function(doc, options) {
+ emitter.to(['master']).emit('User.afterCreate', doc, {
+ body: options.body
+ });
+ },
+ afterUpdate: function(doc, options) {
+ emitter.to(['master']).emit('User.afterUpdate', doc, {
+ changed: _.keyBy(doc.changed())
+ });
+ },
+ afterDestroy: function(doc, options) {
+ emitter.to(['master']).emit('User.afterDestroy', doc);
+ }
}
});