Built motion from commit 503e72f.|0.0.143
[motion.git] / server / models / user.js
index 91ccfe1..409fdd9 100644 (file)
@@ -48,8 +48,7 @@ module.exports = function(sequelize, DataTypes) {
       set: function(password) {
         this.salt = this.makeSalt();
         this.setDataValue('password', this.encryptPassword(password));
-        this.setDataValue('md5secret', this.md5Password(this.name +
-          ':asterisk:' + password));
+        this.setDataValue('md5secret', this.md5Password(this.name + ':asterisk:' + password));
       }
     },
     provider: {
@@ -119,12 +118,10 @@ module.exports = function(sequelize, DataTypes) {
         this.setDataValue('voicePause', voicePause);
         if (voicePause) {
           this.setDataValue('queueStatus', 'paused');
-          this.setDataValue('queueStatusAt', moment().format(
-            "YYYY-MM-DD HH:mm:ss"));
+          this.setDataValue('queueStatusAt', moment().format("YYYY-MM-DD HH:mm:ss"));
         } else {
           this.setDataValue('queueStatus', 'complete');
-          this.setDataValue('queueStatusAt', moment().format(
-            "YYYY-MM-DD HH:mm:ss"));
+          this.setDataValue('queueStatusAt', moment().format("YYYY-MM-DD HH:mm:ss"));
         }
       }
     },
@@ -144,6 +141,10 @@ module.exports = function(sequelize, DataTypes) {
       type: DataTypes.BOOLEAN,
       defaultValue: false
     },
+    openchannelPause: {
+      type: DataTypes.BOOLEAN,
+      defaultValue: false
+    },
     pauseType: {
       type: DataTypes.STRING,
       defaultValue: 'Default Pause'
@@ -167,6 +168,10 @@ module.exports = function(sequelize, DataTypes) {
       type: DataTypes.INTEGER,
       defaultValue: 0
     },
+    openchannelCapacity: {
+      type: DataTypes.INTEGER,
+      defaultValue: 0
+    },
     phoneBarAutoAnswer: {
       type: DataTypes.BOOLEAN,
       defaultValue: false
@@ -224,7 +229,7 @@ module.exports = function(sequelize, DataTypes) {
     },
     phoneBarExpires: {
       type: DataTypes.INTEGER(5),
-      defaultValue: 3600
+      defaultValue: 120
     },
     phoneBarNameServer: {
       type: DataTypes.STRING,
@@ -270,6 +275,11 @@ module.exports = function(sequelize, DataTypes) {
       type: DataTypes.STRING,
       allowNull: true,
     },
+    host: {
+      type: DataTypes.STRING,
+      allowNull: true,
+      defaultValue: 'dynamic'
+    },
     ipaddr: { //REALTIME ASTERISK
       type: DataTypes.STRING,
       allowNull: true,
@@ -394,15 +404,15 @@ module.exports = function(sequelize, DataTypes) {
       type: DataTypes.STRING,
       allowNull: true
     },
-    allow: {
+    disallow: {
       type: DataTypes.STRING,
       allowNull: true,
-      defaultValue: 'alaw;ulaw;gsm'
+      defaultValue: 'all'
     },
-    disallow: {
+    allow: {
       type: DataTypes.STRING,
       allowNull: true,
-      defaultValue: null
+      defaultValue: 'alaw;ulaw;gsm'
     },
     autoframing: {
       type: DataTypes.ENUM('yes', 'no'),
@@ -535,11 +545,6 @@ module.exports = function(sequelize, DataTypes) {
       type: DataTypes.STRING,
       allowNull: true,
     },
-    host: {
-      type: DataTypes.STRING,
-      allowNull: true,
-      defaultValue: 'dynamic'
-    },
     qualify: {
       type: DataTypes.ENUM('yes', 'no'),
       allowNull: true,
@@ -691,7 +696,7 @@ module.exports = function(sequelize, DataTypes) {
     call_limit: {
       type: DataTypes.INTEGER(11),
       allowNull: true,
-      defaultValue: null
+      defaultValue: 10
     },
     registertrying: { //Send a 100 Trying when the device registers.
       type: DataTypes.ENUM('yes', 'no'),
@@ -722,6 +727,20 @@ module.exports = function(sequelize, DataTypes) {
       allowNull: true,
       defaultValue: 'no'
     },
+    loginInPause: {
+      type: DataTypes.BOOLEAN,
+      defaultValue: false
+    },
+    resetPasswordToken: {
+      type: DataTypes.STRING
+    },
+    resetPasswordExpires: {
+      type: DataTypes.DATE
+    },
+    phoneBarEnableRecording: {
+      type: DataTypes.BOOLEAN,
+      defaultValue: false
+    }
   }, {
     tableName: 'users',
     instanceMethods: {
@@ -788,6 +807,9 @@ module.exports = function(sequelize, DataTypes) {
       User.belongsToMany(models.SmsRoom, {
         through: 'user_has_sms_rooms'
       });
+      User.belongsToMany(models.OpenchannelRoom, {
+        through: 'user_has_openchannel_rooms'
+      });
       User.belongsToMany(models.FaxRoom, {
         through: 'user_has_fax_rooms'
       });
@@ -814,7 +836,14 @@ module.exports = function(sequelize, DataTypes) {
         through: models.UserHasSmsQueuePermit,
         as: 'PSmsQueues'
       });
-
+      User.belongsToMany(models.OpenchannelQueue, {
+        through: models.UserHasOpenchannelQueue,
+        required: false
+      });
+      User.belongsToMany(models.OpenchannelQueue, {
+        through: models.UserHasOpenchannelQueuePermit,
+        as: 'POpenchannelQueues'
+      });
       User.belongsToMany(models.MailQueue, {
         through: models.UserHasMailQueuePermit,
         as: 'PMailQueues'
@@ -900,7 +929,7 @@ module.exports = function(sequelize, DataTypes) {
           'fullcontact',
           'port',
           'lastms',
-          'description'
+          'description',
         ]
       });
       User.addScope('agent', {
@@ -924,6 +953,7 @@ module.exports = function(sequelize, DataTypes) {
           'mailCapacity',
           'faxCapacity',
           'smsCapacity',
+          'openchannelCapacity',
           'online',
           'lastLoginAt',
           'phoneBarAutoAnswer',
@@ -938,12 +968,14 @@ module.exports = function(sequelize, DataTypes) {
           'phoneBarExpires',
           'phoneBarRemoteControl',
           'phoneBarRemoteControlPort',
+          'phoneBarEnableRecording',
           'chanspy',
           'voicePause',
           'mailPause',
           'faxPause',
           'chatPause',
           'smsPause',
+          'openchannelPause',
           'pauseType',
           'lastPauseAt',
           'status',
@@ -956,7 +988,8 @@ module.exports = function(sequelize, DataTypes) {
           'fullcontact',
           'port',
           'lastms',
-          'description'
+          'description',
+          'loginInPause'
         ]
       });
       User.addScope('telephone', {
@@ -966,7 +999,7 @@ module.exports = function(sequelize, DataTypes) {
       });
       User.addScope('queues', {
         include: [models.VoiceQueue, models.ChatQueue, models.MailQueue,
-          models.FaxQueue, models.SmsQueue
+          models.FaxQueue, models.SmsQueue, models.OpenchannelQueue
         ]
       });
 
@@ -994,6 +1027,10 @@ module.exports = function(sequelize, DataTypes) {
           scope.where.smsPause = (query.smsPause === 'true') ?
             true : false;
           delete query.smsPause;
+        } else if (query.openchannelPause) {
+          scope.where.openchannelPause = (query.openchannelPause === 'true') ?
+            true : false;
+          delete query.openchannelPause;
         }
         return scope;
       });