Built motion from commit 0dbf6b8.|0.0.131
[motion.git] / server / models / openchannel_account.js
index 763dd4b..c630854 100644 (file)
@@ -17,15 +17,6 @@ module.exports = function(sequelize, DataTypes) {
       type: DataTypes.INTEGER,
       defaultValue: 0
     },
-    // phone: {
-    //   // type: DataTypes.INTEGER,
-    //   // unique: true
-    //   type: DataTypes.STRING,
-    //   unique: true,
-    //   validate: {
-    //     is: /^[0-9]+$/
-    //   }
-    // },
     acceptUrl: {
       type: DataTypes.STRING
     },
@@ -44,6 +35,12 @@ module.exports = function(sequelize, DataTypes) {
     replyMethod: {
       type: DataTypes.ENUM('GET', 'POST')
     },
+    closeUrl: {
+      type: DataTypes.STRING
+    },
+    closeMethod: {
+      type: DataTypes.ENUM('GET', 'POST')
+    },
     actions: {
       type: DataTypes.STRING,
       get: function() {
@@ -52,10 +49,6 @@ module.exports = function(sequelize, DataTypes) {
       set: function(val) {
         return this.setDataValue('actions', JSON.stringify(val));
       }
-    },
-    reply: {
-      type: DataTypes.BOOLEAN,
-      defaultValue: false
     }
   }, {
     tableName: 'openchannel_accounts',
@@ -68,6 +61,22 @@ module.exports = function(sequelize, DataTypes) {
       // SCOPES
       OpenchannelAccount.hasMany(models.OpenchannelDisposition);
       OpenchannelAccount.belongsTo(models.List);
+      OpenchannelAccount.addScope('default', {
+        include: [{
+          model: models.OpenchannelApplication,
+          include: [{
+            model: models.User,
+            attributes: ['id',
+              'name',
+              'email',
+              'internal',
+              'fullname'
+            ]
+          }, {
+            model: models.OpenchannelQueue
+          }]
+        }]
+      });
     }
   });
   return OpenchannelAccount;