Built motion from commit 1038d87.|0.0.141
[motion.git] / server / models / voice_recording.js
index 653a581..54bfb0a 100644 (file)
@@ -1 +1,88 @@
-var _0xa492=["\x65\x78\x70\x6F\x72\x74\x73","\x56\x6F\x69\x63\x65\x52\x65\x63\x6F\x72\x64\x69\x6E\x67","\x53\x54\x52\x49\x4E\x47","\x49\x4E\x54\x45\x47\x45\x52","\x76\x6F\x69\x63\x65\x5F\x72\x65\x63\x6F\x72\x64\x69\x6E\x67\x73","\x64\x65\x66\x69\x6E\x65"];module[_0xa492[0]]=function(_0x2308x1,_0x2308x2){var _0x2308x3=_0x2308x1[_0xa492[5]](_0xa492[1],{uniqueid:{type:_0x2308x2[_0xa492[2]],primaryKey:true},channel:{type:_0x2308x2[_0xa492[2]]},calleridnum:{type:_0x2308x2[_0xa492[2]]},calleridname:{type:_0x2308x2[_0xa492[2]]},connectedlinenum:{type:_0x2308x2[_0xa492[2]]},connectedlinename:{type:_0x2308x2[_0xa492[2]]},language:{type:_0x2308x2[_0xa492[2]]},accountcode:{type:_0x2308x2[_0xa492[2]]},context:{type:_0x2308x2[_0xa492[2]]},exten:{type:_0x2308x2[_0xa492[2]]},value:{type:_0x2308x2[_0xa492[2]]},rating:{type:_0x2308x2[_0xa492[3]],defaultValue:0,validate:{max:5,min:0}}},{tableName:_0xa492[4]});return _0x2308x3;};
\ No newline at end of file
+/* jshint indent: 2 */
+var moment = require('moment');
+
+module.exports = function(sequelize, DataTypes) {
+  var VoiceRecording = sequelize.define('VoiceRecording', {
+    uniqueid: {
+      type: DataTypes.STRING
+    },
+    channel: {
+      type: DataTypes.STRING,
+      set: function(channel) {
+        if (channel) {
+          this.setDataValue('channel', channel);
+          this.setDataValue('membername', channel.split(/\/|-/)[1]);
+        }
+      }
+    },
+    membername: {
+      type: DataTypes.STRING
+    },
+    calleridnum: {
+      type: DataTypes.STRING
+    },
+    calleridname: {
+      type: DataTypes.STRING
+    },
+    connectedlinenum: {
+      type: DataTypes.STRING
+    },
+    connectedlinename: {
+      type: DataTypes.STRING
+    },
+    language: {
+      type: DataTypes.STRING
+    },
+    accountcode: {
+      type: DataTypes.STRING
+    },
+    context: {
+      type: DataTypes.STRING
+    },
+    exten: {
+      type: DataTypes.STRING
+    },
+    value: {
+      type: DataTypes.STRING
+    },
+    type: {
+      type: DataTypes.STRING
+    },
+    rating: {
+      type: DataTypes.INTEGER,
+      validate: {
+        max: 5,
+        min: 0
+      }
+    },
+    queue: {
+      type: DataTypes.STRING
+    },
+    customerPhone: {
+      type: DataTypes.STRING
+    },
+    createdAt: {
+      type: DataTypes.DATE,
+      get: function() {
+        // 'this' allows you to access attributes of the instance
+        return moment(this.getDataValue('createdAt')).format("MM-DD-YYYY HH:mm").toString();
+      }
+    },
+    updatedAt: {
+      type: DataTypes.DATE,
+      get: function() {
+        // 'this' allows you to access attributes of the instance
+        return moment(this.getDataValue('updatedAt')).format("MM-DD-YYYY HH:mm").toString();
+      }
+    }
+  }, {
+    tableName: 'voice_recordings',
+    associate: function(models) {
+      // VoiceRecording.belongsTo(models.ReportCall, {
+      //   foreignKey: 'uniqueid'
+      // });
+    }
+  });
+
+  return VoiceRecording;
+};