Built motion from commit 8dae768.|0.0.121
[motion.git] / server / models / mail_message.js
index f71ad58..9e4f3c7 100644 (file)
@@ -2,7 +2,7 @@
  * Chat Website Model
  */
 
-var crypto = require('crypto');
+var _ = require('lodash');
 
 module.exports = function(sequelize, DataTypes) {
 
@@ -20,7 +20,7 @@ module.exports = function(sequelize, DataTypes) {
                        }
                },
                to: {
-                       type: DataTypes.STRING,
+                       type: DataTypes.TEXT,
                        get: function() {
                                return this.getDataValue('to') ? this.getDataValue('to').split(';') : [];
                        },
@@ -29,7 +29,7 @@ module.exports = function(sequelize, DataTypes) {
                        }
                },
                cc: {
-                       type: DataTypes.STRING,
+                       type: DataTypes.TEXT,
                        get: function() {
                                return this.getDataValue('cc') ? this.getDataValue('cc').split(';') : [];
                        },
@@ -38,7 +38,7 @@ module.exports = function(sequelize, DataTypes) {
                        }
                },
                bcc: {
-                       type: DataTypes.STRING,
+                       type: DataTypes.TEXT,
                        get: function() {
                                return this.getDataValue('bcc') ? this.getDataValue('bcc').split(';') : [];
                        },
@@ -46,12 +46,15 @@ module.exports = function(sequelize, DataTypes) {
                                this.setDataValue('bcc', val.join(';'));
                        }
                },
+               fromId: {
+                       type: DataTypes.INTEGER
+               },
                attachment: DataTypes.TEXT,
                text: {
                        type: DataTypes.BLOB,
                        get: function() {
                                if (this.getDataValue('text')) {
-                                       return this.getDataValue('text').toString();
+                                       return _.toString(this.getDataValue('text'));
                                }
                        }
                },
@@ -59,15 +62,22 @@ module.exports = function(sequelize, DataTypes) {
                        type: DataTypes.BLOB,
                        get: function() {
                                if (this.getDataValue('html')) {
-                                       return this.getDataValue('html').toString();
+                                       if (this.getDataValue('html')) {
+                                               return _.toString(this.getDataValue('html'));
+                                       }
                                }
-                       }
+                       },
                },
                reason: DataTypes.TEXT,
                status: {
-                       type: DataTypes.ENUM('SENT', 'SENDING', 'RECEIVED', 'FAILED', 'NOTE'),
+                       type: DataTypes.ENUM('SENDING', 'SENT', 'RECEIVED', 'FAILED', 'NOTE'),
                        defaultValue: 'SENDING'
-               }
+               },
+               retry: {
+                       type: DataTypes.INTEGER,
+                       defaultValue: 0
+               },
+               voiceSource: DataTypes.STRING
        }, {
                tableName: 'mail_messages',
                paranoid: true,