Built motion from commit d3d6ca497.|1.0.32
[motion.git] / server / models / user.js
index 8af4f03..1866eea 100644 (file)
@@ -410,7 +410,7 @@ module.exports = function(sequelize, DataTypes) {
     allow: {
       type: DataTypes.STRING,
       allowNull: true,
-      defaultValue: 'alaw;ulaw;gsm'
+      defaultValue: 'ulaw;gsm'
     },
     autoframing: {
       type: DataTypes.ENUM('yes', 'no'),
@@ -746,9 +746,31 @@ module.exports = function(sequelize, DataTypes) {
     phoneBarShowOmniDesktop: {
       type: DataTypes.BOOLEAN,
       defaultValue: true
+    },
+    phoneBarRingInUse: {
+      type: DataTypes.BOOLEAN,
+      defaultValue: false
+    },
+    phoneBarDnd: {
+      type: DataTypes.BOOLEAN,
+      defaultValue: true
+    },
+    phoneBarUnansweredCallBadge: {
+      type: DataTypes.BOOLEAN,
+      defaultValue: true
+    },
+    phonebarEnableDtmfTone: {
+      type: DataTypes.BOOLEAN,
+      defaultValue: false
+    },
+    phonebarAutoAnswerDelay: {
+      type: DataTypes.INTEGER,
+      defaultValue: 0
     }
   }, {
     tableName: 'users',
+    charset: 'utf8',
+    collate: 'utf8_bin',
     instanceMethods: {
       /**
        * Authenticate - check if the passwords are the same
@@ -804,12 +826,12 @@ module.exports = function(sequelize, DataTypes) {
         through: models.UserHasModule,
         required: false
       });
+      User.belongsToMany(models.MailRoom, {
+        through: models.UserHasMailRoom,
+      });
       User.belongsToMany(models.Channel, {
         through: 'user_has_channels'
       });
-      User.belongsToMany(models.MailRoom, {
-        through: 'user_has_mail_rooms'
-      });
       User.belongsToMany(models.SmsRoom, {
         through: 'user_has_sms_rooms'
       });
@@ -1003,7 +1025,14 @@ module.exports = function(sequelize, DataTypes) {
           'showWebBar',
           'callgroup',
           'pickupgroup',
-          'phoneBarShowOmniDesktop'
+          'phoneBarShowOmniDesktop',
+          'phoneBarRingInUse',
+          'phoneBarDnd',
+          'phoneBarUnansweredCallBadge',
+          'phone',
+          'mobile',
+          'phonebarEnableDtmfTone',
+          'phonebarAutoAnswerDelay'
         ]
       });
       User.addScope('telephone', {
@@ -1085,13 +1114,18 @@ module.exports = function(sequelize, DataTypes) {
         }
         return scope;
       });
-      User.addScope('checkQueueStatus', function(query) {//to be executed before checkOnlineStatus
+      User.addScope('checkQueueStatus', function(query) { //to be executed before checkOnlineStatus
         var scope = {
           where: {}
         };
         if (query.queueStatus) {
-          scope.where.queueStatus = query.queueStatus;
-          query.online = 'true';
+          if (query.queueStatus === 'paused') {
+            scope.where.voicePause = true;
+          } else {
+            scope.where.queueStatus = query.queueStatus;
+            scope.where.voicePause = false;
+            query.online = 'true';
+          }
           delete query.queueStatus;
         }
         return scope;
@@ -1113,33 +1147,24 @@ module.exports = function(sequelize, DataTypes) {
             'phoneBarRemoteControl',
             'phoneBarRemoteControlPort',
             'loginInPause',
-            'showWebBar'
+            'showWebBar',
+            'phonebarEnableDtmfTone',
+            'phonebarAutoAnswerDelay'
           ],
           include: [{
             model: models.Module,
+            attributes: ['id', 'path'],
             include: [{
               model: models.Module,
+              attributes: ['id', 'path'],
               as: 'SubModules',
               required: false,
               include: [{
-                all: true
+                model: models.Module,
+                attributes: ['id', 'path'],
+                as: 'SubModules'
               }]
             }]
-          }, {
-            model: models.VoiceQueue,
-            as: 'PVoiceQueues'
-          }, {
-            model: models.ChatQueue,
-            as: 'PChatQueues'
-          }, {
-            model: models.MailQueue,
-            as: 'PMailQueues'
-          }, {
-            model: models.FaxQueue,
-            as: 'PFaxQueues'
-          }, {
-            model: models.SmsQueue,
-            as: 'PSmsQueues'
           }]
         };
         return scope;