Built motion from commit 0dbf6b8.|0.0.131
[motion.git] / server / models / sms_account.js
index 18a06b1..7e38044 100644 (file)
@@ -43,8 +43,34 @@ module.exports = function(sequelize, DataTypes) {
     },
     password: {
       type: DataTypes.STRING
+    },
+    acceptUrl: {
+      type: DataTypes.STRING
+    },
+    rejectUrl: {
+      type: DataTypes.STRING
+    },
+    acceptMethod: {
+      type: DataTypes.ENUM('GET', 'POST')
+    },
+    rejectMethod: {
+      type: DataTypes.ENUM('GET', 'POST')
+    },
+    closeUrl: {
+      type: DataTypes.STRING
+    },
+    closeMethod: {
+      type: DataTypes.ENUM('GET', 'POST')
+    },
+    actions: {
+      type: DataTypes.STRING,
+      get: function() {
+        return this.getDataValue('actions') ? JSON.parse(this.getDataValue('actions')) : [];
+      },
+      set: function(val) {
+        return this.setDataValue('actions', JSON.stringify(val));
+      }
     }
-
   }, {
     tableName: 'sms_accounts',
     associate: function(models) {
@@ -56,6 +82,22 @@ module.exports = function(sequelize, DataTypes) {
       // SCOPES
       SmsAccount.hasMany(models.SmsDisposition);
       SmsAccount.belongsTo(models.List);
+      SmsAccount.addScope('default', {
+        include: [{
+          model: models.SmsApplication,
+          include: [{
+            model: models.User,
+            attributes: ['id',
+              'name',
+              'email',
+              'internal',
+              'fullname'
+            ]
+          }, {
+            model: models.SmsQueue
+          }]
+        }]
+      });
     }
   });
   return SmsAccount;