Subject: Built motion from commit 9750695.|0.0.141
From: Daniele Cinti <[email-masked]>
Date: Tue, 13 Sep 2016 13:11:03 +0000 (+0200)

Built motion from commit 9750695.|0.0.141
---

diff --git a/release-notes/changelog_0.0.141.txt b/release-notes/changelog_0.0.141.txt
index bac1ae5..f805e39 100644
--- a/release-notes/changelog_0.0.141.txt
+++ b/release-notes/changelog_0.0.141.txt
@@ -1,5 +1,6 @@
 # xCALLY MOTION Changelog
 
+- * 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 
 - * f8ce2ee - 2016-09-13: automation chat update (server side - emitter) 
diff --git a/server/config/tools/interval.js b/server/config/tools/interval.js
index e5ec6f1..f89478b 100644
--- a/server/config/tools/interval.js
+++ b/server/config/tools/interval.js
@@ -17,12 +17,12 @@ function Interval() {
 
   emitter.on('MailRoom.beforeDestroy', function(doc, options) {
     if (doc.IntervalId !== null) {
-      updatevoiceExtension(interval);
+      updatevoiceExtension(doc);
     }
   });
   emitter.on('MailRoom.afterCreate', function(doc, options) {
-    if (interval.IntervalId !== null) {
-      updatevoiceExtension(interval);
+    if (doc.IntervalId !== null) {
+      updatevoiceExtension(doc);
     }
   });
 }
@@ -70,5 +70,4 @@ function updatevoiceExtension(interval) {
     });
 }
 
-
 module.exports = Interval;
diff --git a/server/models/tools_interval.js b/server/models/tools_interval.js
index b223bde..de98180 100644
--- a/server/models/tools_interval.js
+++ b/server/models/tools_interval.js
@@ -2,8 +2,6 @@
 
 const emitter = require('cluster-emitter');
 
-var emitter = require('cluster-emitter');
-
 module.exports = function(sequelize, DataTypes) {
   var Interval = sequelize.define('Interval', {
     name: {
@@ -16,17 +14,6 @@ module.exports = function(sequelize, DataTypes) {
     }
   }, {
     tableName: 'tools_intervals',
-    hooks: {
-      afterCreate: function(doc) {
-        emitter.to(['master']).emit('Interval.afterCreate', doc);
-      },
-      afterUpdate: function(doc) {
-        emitter.to(['master']).emit('Interval.afterUpdate', doc);
-      },
-      afterDestroy: function(doc) {
-        emitter.to(['master']).emit('Interval.afterDestroy', doc);
-      }
-    },
     associate: function(models) {
       Interval.hasMany(models.Interval, {
         as: 'SubIntervals',