Built motion from commit 82438f7.|0.0.115
[motion.git] / server / models / mail_message.js
index 0b59abf..7601332 100644 (file)
@@ -1 +1,94 @@
-var _0x3e5e=["\x63\x72\x79\x70\x74\x6F","\x65\x78\x70\x6F\x72\x74\x73","\x4D\x61\x69\x6C\x4D\x65\x73\x73\x61\x67\x65","\x53\x54\x52\x49\x4E\x47","\x66\x72\x6F\x6D","\x67\x65\x74\x44\x61\x74\x61\x56\x61\x6C\x75\x65","\x3B","\x73\x70\x6C\x69\x74","\x6A\x6F\x69\x6E","\x73\x65\x74\x44\x61\x74\x61\x56\x61\x6C\x75\x65","\x74\x6F","\x63\x63","\x62\x63\x63","\x54\x45\x58\x54","\x53\x45\x4E\x54","\x53\x45\x4E\x44\x49\x4E\x47","\x52\x45\x43\x45\x49\x56\x45\x44","\x46\x41\x49\x4C\x45\x44","\x6D\x61\x69\x6C\x5F\x6D\x65\x73\x73\x61\x67\x65\x73","\x62\x65\x6C\x6F\x6E\x67\x73\x54\x6F","\x46\x72\x6F\x6D","\x54\x6F","\x6D\x61\x69\x6C\x5F\x6D\x65\x73\x73\x61\x67\x65\x5F\x68\x61\x73\x5F\x74\x6F","\x63\x61\x73\x63\x61\x64\x65","\x62\x65\x6C\x6F\x6E\x67\x73\x54\x6F\x4D\x61\x6E\x79","\x43\x63","\x6D\x61\x69\x6C\x5F\x6D\x65\x73\x73\x61\x67\x65\x5F\x68\x61\x73\x5F\x63\x63","\x42\x63\x63","\x6D\x61\x69\x6C\x5F\x6D\x65\x73\x73\x61\x67\x65\x5F\x68\x61\x73\x5F\x62\x63\x63","\x68\x61\x73\x4D\x61\x6E\x79","\x64\x65\x66\x69\x6E\x65"];var crypto=require(_0x3e5e[0]);module[_0x3e5e[1]]=function(_0xf1b7x2,_0xf1b7x3){var _0xf1b7x4=_0xf1b7x2[_0x3e5e[30]](_0x3e5e[2],{messageId:_0xf1b7x3[_0x3e5e[3]],inReplyTo:_0xf1b7x3[_0x3e5e[3]],subject:_0xf1b7x3[_0x3e5e[3]],from:{type:_0xf1b7x3[_0x3e5e[3]],get:function(){return this[_0x3e5e[5]](_0x3e5e[4])?this[_0x3e5e[5]](_0x3e5e[4])[_0x3e5e[7]](_0x3e5e[6]):[]},set:function(_0xf1b7x5){this[_0x3e5e[9]](_0x3e5e[4],_0xf1b7x5[_0x3e5e[8]](_0x3e5e[6]))}},to:{type:_0xf1b7x3[_0x3e5e[3]],get:function(){return this[_0x3e5e[5]](_0x3e5e[10])?this[_0x3e5e[5]](_0x3e5e[10])[_0x3e5e[7]](_0x3e5e[6]):[]},set:function(_0xf1b7x5){this[_0x3e5e[9]](_0x3e5e[10],_0xf1b7x5[_0x3e5e[8]](_0x3e5e[6]))}},cc:{type:_0xf1b7x3[_0x3e5e[3]],get:function(){return this[_0x3e5e[5]](_0x3e5e[11])?this[_0x3e5e[5]](_0x3e5e[11])[_0x3e5e[7]](_0x3e5e[6]):[]},set:function(_0xf1b7x5){this[_0x3e5e[9]](_0x3e5e[11],_0xf1b7x5[_0x3e5e[8]](_0x3e5e[6]))}},bcc:{type:_0xf1b7x3[_0x3e5e[3]],get:function(){return this[_0x3e5e[5]](_0x3e5e[12])?this[_0x3e5e[5]](_0x3e5e[12])[_0x3e5e[7]](_0x3e5e[6]):[]},set:function(_0xf1b7x5){this[_0x3e5e[9]](_0x3e5e[12],_0xf1b7x5[_0x3e5e[8]](_0x3e5e[6]))}},attachment:_0xf1b7x3[_0x3e5e[13]],html:_0xf1b7x3[_0x3e5e[13]],text:_0xf1b7x3[_0x3e5e[13]],reason:_0xf1b7x3[_0x3e5e[13]],status:{type:_0xf1b7x3.ENUM(_0x3e5e[14],_0x3e5e[15],_0x3e5e[16],_0x3e5e[17]),defaultValue:_0x3e5e[15]}},{tableName:_0x3e5e[18],associate:function(_0xf1b7x6){_0xf1b7x4[_0x3e5e[19]](_0xf1b7x6.MailRoom);_0xf1b7x4[_0x3e5e[19]](_0xf1b7x6.ContactEmail,{as:_0x3e5e[20]});_0xf1b7x4[_0x3e5e[24]](_0xf1b7x6.ContactEmail,{as:_0x3e5e[21],through:_0x3e5e[22],onDelete:_0x3e5e[23]});_0xf1b7x4[_0x3e5e[24]](_0xf1b7x6.ContactEmail,{as:_0x3e5e[25],through:_0x3e5e[26],onDelete:_0x3e5e[23]});_0xf1b7x4[_0x3e5e[24]](_0xf1b7x6.ContactEmail,{as:_0x3e5e[27],through:_0x3e5e[28],onDelete:_0x3e5e[23]});_0xf1b7x4[_0x3e5e[29]](_0xf1b7x6.MailAttachment)}});return _0xf1b7x4}
\ No newline at end of file
+/**
+ * Chat Website Model
+ */
+
+var _ = require('lodash');
+
+module.exports = function(sequelize, DataTypes) {
+
+       var MailMessage = sequelize.define('MailMessage', {
+               messageId: DataTypes.STRING,
+               inReplyTo: DataTypes.STRING,
+               subject: DataTypes.STRING,
+               from: {
+                       type: DataTypes.STRING,
+                       get: function() {
+                               return this.getDataValue('from') ? this.getDataValue('from').split(';') : [];
+                       },
+                       set: function(val) {
+                               this.setDataValue('from', val.join(';'));
+                       }
+               },
+               to: {
+                       type: DataTypes.TEXT,
+                       get: function() {
+                               return this.getDataValue('to') ? this.getDataValue('to').split(';') : [];
+                       },
+                       set: function(val) {
+                               this.setDataValue('to', val.join(';'));
+                       }
+               },
+               cc: {
+                       type: DataTypes.TEXT,
+                       get: function() {
+                               return this.getDataValue('cc') ? this.getDataValue('cc').split(';') : [];
+                       },
+                       set: function(val) {
+                               this.setDataValue('cc', val.join(';'));
+                       }
+               },
+               bcc: {
+                       type: DataTypes.TEXT,
+                       get: function() {
+                               return this.getDataValue('bcc') ? this.getDataValue('bcc').split(';') : [];
+                       },
+                       set: function(val) {
+                               this.setDataValue('bcc', val.join(';'));
+                       }
+               },
+               fromId: {
+                       type: DataTypes.INTEGER
+               },
+               attachment: DataTypes.TEXT,
+               text: {
+                       type: DataTypes.BLOB,
+                       get: function() {
+                               if (this.getDataValue('text')) {
+                                       return _.toString(this.getDataValue('text'));
+                               }
+                       }
+               },
+               html: {
+                       type: DataTypes.BLOB,
+                       get: function() {
+                               if (this.getDataValue('html')) {
+                                       if (this.getDataValue('html')) {
+                                               return _.toString(this.getDataValue('html'));
+                                       }
+                               }
+                       },
+               },
+               reason: DataTypes.TEXT,
+               status: {
+                       type: DataTypes.ENUM('sending', 'sent', 'received', 'failed', 'note'),
+                       defaultValue: 'sending'
+               },
+               retry: {
+                       type: DataTypes.INTEGER,
+                       defaultValue: 0
+               },
+               voiceSource: DataTypes.STRING
+       }, {
+               tableName: 'mail_messages',
+               paranoid: true,
+               associate: function(models) {
+                       MailMessage.hasMany(models.MailAttachment);
+                       MailMessage.belongsTo(models.User);
+                       MailMessage.belongsTo(models.MailRoom, {
+                               onDelete: 'cascade'
+                       });
+               }
+       });
+
+       return MailMessage;
+};