Built motion from commit c2984ba.|0.0.114
[motion.git] / server / models / chat_queue.js
index 04a2289..ac292ff 100644 (file)
@@ -1 +1,55 @@
-var _0xfc5a=["\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"];_0xfc5a[0];module[_0xfc5a[1]]=function(_0x85c0x1,_0x85c0x2){var _0x85c0x3=_0x85c0x1[_0xfc5a[10]](_0xfc5a[2],{name:{type:_0x85c0x2[_0xfc5a[3]],unique:true},description:{type:_0x85c0x2[_0xfc5a[3]]},timeout:{type:_0x85c0x2[_0xfc5a[4]]},strategy:{type:_0x85c0x2.ENUM(_0xfc5a[5],_0xfc5a[6])}},{tableName:_0xfc5a[7],associate:function(_0x85c0x4){_0x85c0x3[_0xfc5a[9]](_0x85c0x4.User,{through:_0x85c0x4[_0xfc5a[8]]})}});return _0x85c0x3;};
\ 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;
+};