Built motion from commit 1038d87.|0.0.141
[motion.git] / server / models / chat_room.js
index 7c6be30..6c48356 100644 (file)
@@ -1,8 +1,4 @@
-/**
- * Chat Website Model
- */
-
-var crypto = require('crypto');
+'use strict';
 
 module.exports = function(sequelize, DataTypes) {
 
@@ -13,8 +9,8 @@ module.exports = function(sequelize, DataTypes) {
                        unique: 'token'
                },
                status: {
-                       type: DataTypes.ENUM('OPEN', 'CLOSED', 'ABANDON', 'UNMANAGED'),
-                       defaultValue: 'OPEN'
+                       type: DataTypes.ENUM('NEW', 'OPEN', 'CLOSED', 'ABANDON', 'UNMANAGED'),
+                       defaultValue: 'NEW'
                },
                rating: DataTypes.ENUM('good', 'bad'),
                ratingMessage: DataTypes.TEXT,
@@ -22,7 +18,33 @@ module.exports = function(sequelize, DataTypes) {
                ChatVisitorId: {
                        type: DataTypes.INTEGER,
                        unique: 'token'
-               }
+               },
+               waiting: {
+                       type: DataTypes.BOOLEAN,
+                       defaultValue: false
+               },
+               tags: {
+                       type: DataTypes.TEXT,
+                       get: function() {
+                               var tags;
+                               if (this.getDataValue('tags')) {
+                                       tags = this.getDataValue('tags').split(';');
+                                       tags.pop();
+                               } else {
+                                       tags = [];
+                               }
+                               return tags;
+                       },
+                       set: function(val) {
+                               this.setDataValue('tags', val && val.length ? val.join(';') + ';' : null);
+                       }
+               },
+               disposition: {
+                       type: DataTypes.STRING
+               },
+               openReason: DataTypes.STRING,
+               contact: DataTypes.STRING,
+               website: DataTypes.STRING
        }, {
                tableName: 'chat_rooms',
                associate: function(models) {