Built motion from commit c2984ba.|0.0.114
[motion.git] / server / models / chat_queue.js
index b2b709a..ac292ff 100644 (file)
@@ -1 +1,55 @@
-var _0x68ac=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x65\x78\x70\x6F\x72\x74\x73","\x43\x68\x61\x74\x51\x75\x65\x75\x65","\x53\x54\x52\x49\x4E\x47","\x49\x4E\x54\x45\x47\x45\x52","\x72\x72\x6D\x65\x6D\x6F\x72\x79","\x62\x65\x65\x70\x61\x6C\x6C","\x63\x68\x61\x74\x5F\x71\x75\x65\x75\x65\x73","\x55\x73\x65\x72\x48\x61\x73\x43\x68\x61\x74\x51\x75\x65\x75\x65","\x62\x65\x6C\x6F\x6E\x67\x73\x54\x6F\x4D\x61\x6E\x79","\x64\x65\x66\x69\x6E\x65"];_0x68ac[0];module[_0x68ac[1]]=function(_0xa1c5x1,_0xa1c5x2){var _0xa1c5x3=_0xa1c5x1[_0x68ac[10]](_0x68ac[2],{name:{type:_0xa1c5x2[_0x68ac[3]],unique:true},description:{type:_0xa1c5x2[_0x68ac[3]]},timeout:{type:_0xa1c5x2[_0x68ac[4]]},strategy:{type:_0xa1c5x2.ENUM(_0x68ac[5],_0x68ac[6])}},{tableName:_0x68ac[7],associate:function(_0xa1c5x4){_0xa1c5x3[_0x68ac[9]](_0xa1c5x4.User,{through:_0xa1c5x4[_0x68ac[8]]})}});return _0xa1c5x3;};
\ No newline at end of file
+'use strict';
+
+module.exports = function(sequelize, DataTypes) {
+
+  var ChatQueue = sequelize.define('ChatQueue', {
+    name: {
+      type: DataTypes.STRING,
+      unique: true,
+      allowNull: false,
+      validate: {
+        notEmpty: true,
+        is: /^[A-Za-z0-9\.\_]+$/i
+      }
+    },
+    description: {
+      type: DataTypes.STRING,
+    },
+    timeout: {
+      type: DataTypes.INTEGER,
+      validate: {
+        min: 1
+      }
+    },
+    strategy: {
+      type: DataTypes.ENUM('rrmemory', 'beepall', 'roundrobin')
+    },
+    lastAgent: {
+      type: DataTypes.INTEGER,
+      defaultValue: 0
+    },
+  }, {
+    tableName: 'chat_queues',
+    associate: function(models) {
+      // hasMany relations
+      ChatQueue.belongsToMany(models.User, {
+        through: models.UserHasChatQueue
+      });
+
+      ChatQueue.belongsToMany(models.User, {
+        through: models.UserHasChatQueuePermit,
+        as: 'PChatQueues'
+      });
+
+      //SCOPES
+      ChatQueue.addScope('default', {
+        include: [{
+          model: models.User,
+          attributes: ['id', 'name', 'fullname', 'email', 'online', 'lastLoginAt', 'chatPause', 'pauseType']
+        }]
+      });
+    }
+  });
+
+  return ChatQueue;
+};