Built motion from commit c2984ba.|0.0.114
[motion.git] / server / models / chat_queue.js
index ba5899c..ac292ff 100644 (file)
@@ -1 +1,55 @@
-var _0x5afa=["\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\x61\x75\x6C\x74","\x55\x73\x65\x72","\x69\x64","\x6E\x61\x6D\x65","\x66\x75\x6C\x6C\x6E\x61\x6D\x65","\x65\x6D\x61\x69\x6C","\x6F\x6E\x6C\x69\x6E\x65","\x6C\x61\x73\x74\x4C\x6F\x67\x69\x6E\x41\x74","\x63\x68\x61\x74\x50\x61\x75\x73\x65","\x70\x61\x75\x73\x65\x54\x79\x70\x65","\x61\x64\x64\x53\x63\x6F\x70\x65","\x64\x65\x66\x69\x6E\x65"];_0x5afa[0];module[_0x5afa[1]]=function(_0x2925x1,_0x2925x2){var _0x2925x3=_0x2925x1[_0x5afa[21]](_0x5afa[2],{name:{type:_0x2925x2[_0x5afa[3]],unique:true,allowNull:false,validate:{notEmpty:true}},description:{type:_0x2925x2[_0x5afa[3]]},timeout:{type:_0x2925x2[_0x5afa[4]]},strategy:{type:_0x2925x2.ENUM(_0x5afa[5],_0x5afa[6])}},{tableName:_0x5afa[7],associate:function(_0x2925x4){_0x2925x3[_0x5afa[9]](_0x2925x4.User,{through:_0x2925x4[_0x5afa[8]]});_0x2925x3[_0x5afa[20]](_0x5afa[10],{include:[{model:_0x2925x4[_0x5afa[11]],attributes:[_0x5afa[12],_0x5afa[13],_0x5afa[14],_0x5afa[15],_0x5afa[16],_0x5afa[17],_0x5afa[18],_0x5afa[19]]}]})}});return _0x2925x3}
\ 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;
+};