Built motion from commit 2239aeb.|0.0.113
[motion.git] / server / models / sms_room.js
index b8e6f18..48ad3f0 100644 (file)
@@ -5,21 +5,38 @@ module.exports = function(sequelize, DataTypes) {
     from: {
       type: DataTypes.STRING,
       validate: {
-        is: /^[0-9]+$/
+        is: /^[\+]?[0-9]+$/
       }
     },
     status: {
-      type: DataTypes.ENUM('NEW', 'OPEN', 'CLOSED', 'UNMANAGED', 'CSQUARE'),
+      type: DataTypes.ENUM('NEW', 'OPEN', 'CLOSED', 'UNMANAGED'),
       defaultValue: 'NEW'
     },
     tags: {
       type: DataTypes.TEXT,
       get: function() {
-        return this.getDataValue('tags') ? this.getDataValue('tags').split(';') : [];
+        var tags;
+        if (this.getDataValue('tags')) {
+          tags = this.getDataValue('tags').split(';');
+          tags.pop();
+        } else {
+          tags = [];
+        }
+        return tags;
       },
       set: function(val) {
-        this.setDataValue('tags', val.join(';'));
+        this.setDataValue('tags', val && val.length ? val.join(';') + ';' : null);
       }
+    },
+    disposition: {
+      type: DataTypes.STRING
+    },
+    ParentId: {
+      type: DataTypes.INTEGER
+    },
+    voiceSource: {
+      type: DataTypes.BOOLEAN,
+      defaultValue: false
     }
   }, {
     tableName: 'sms_rooms',