-var _0xc34a=["\x65\x78\x70\x6F\x72\x74\x73","\x4D\x61\x69\x6C\x41\x63\x63\x6F\x75\x6E\x74","\x53\x54\x52\x49\x4E\x47","\x6D\x61\x69\x6C\x5F\x61\x63\x63\x6F\x75\x6E\x74\x73","\x68\x61\x73\x4D\x61\x6E\x79","\x63\x61\x73\x63\x61\x64\x65","\x68\x61\x73\x4F\x6E\x65","\x64\x65\x66\x69\x6E\x65"];module[_0xc34a[0]]=function(_0xf887x1,_0xf887x2){var _0xf887x3=_0xf887x1[_0xc34a[7]](_0xc34a[1],{description:_0xf887x2[_0xc34a[2]],name:{type:_0xf887x2[_0xc34a[2]],unique:true},address:_0xf887x2[_0xc34a[2]]},{tableName:_0xc34a[3],associate:function(_0xf887x4){_0xf887x3[_0xc34a[4]](_0xf887x4.MailRoom);_0xf887x3[_0xc34a[4]](_0xf887x4.MailTemplate);_0xf887x3[_0xc34a[4]](_0xf887x4.MailApplication);_0xf887x3[_0xc34a[6]](_0xf887x4.MailServerIn,{onDelete:_0xc34a[5],hooks:true});_0xf887x3[_0xc34a[6]](_0xf887x4.MailServerOut,{onDelete:_0xc34a[5],hooks:true});}});return _0xf887x3;};
\ No newline at end of file
+/**
+ * Chat Website Model
+ */
+
+module.exports = function(sequelize, DataTypes) {
+
+ var MailAccount = sequelize.define('MailAccount', {
+ description: DataTypes.STRING,
+ name: {
+ type: DataTypes.STRING
+ },
+ address: {
+ type: DataTypes.STRING,
+ unique: true,
+ isEmail: true,
+ set: function(address) {
+ if (address) {
+ this.setDataValue('address', address.toLowerCase());
+ }
+ },
+ },
+ fidelity: {
+ type: DataTypes.BOOLEAN,
+ defaultValue: false
+ },
+ timeout: {
+ type: DataTypes.INTEGER,
+ defaultValue: 0
+ },
+ whiteLabel: {
+ type: DataTypes.STRING
+ },
+ acceptUrl: {
+ type: DataTypes.STRING
+ },
+ rejectUrl: {
+ type: DataTypes.STRING
+ },
+ acceptMethod: {
+ type: DataTypes.ENUM('GET', 'POST')
+ },
+ rejectMethod: {
+ 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: 'mail_accounts',
+ associate: function(models) {
+ // RELATIONS
+ MailAccount.belongsTo(models.List);
+ MailAccount.belongsTo(models.Template);
+ MailAccount.hasMany(models.MailRoom);
+ MailAccount.hasMany(models.MailDisposition);
+ MailAccount.hasMany(models.MailApplication);
+ MailAccount.hasOne(models.MailServerIn, {
+ onDelete: 'cascade',
+ hooks: true
+ });
+ MailAccount.hasOne(models.MailServerOut, {
+ onDelete: 'cascade',
+ hooks: true
+ });
+
+ // SCOPES
+ MailAccount.addScope('default', {
+ include: [{
+ model: models.MailServerIn,
+ attributes: ['id', 'host', 'port', 'username', 'password', 'ssl', 'delete', 'filter', 'state', 'mailbox', 'connTimeout', 'authTimeout', 'keepalive', 'source']
+ }, {
+ model: models.MailServerOut,
+ attributes: ['id', 'host', 'port', 'username', 'password', 'ssl', 'service', 'state', 'source']
+ }, {
+ model: models.MailApplication,
+ include: [{
+ model: models.User,
+ attributes: ['id',
+ 'name',
+ 'email',
+ 'internal',
+ 'fullname'
+ ]
+ }, {
+ model: models.MailQueue
+ }]
+ }]
+ });
+ }
+ });
+
+ return MailAccount;
+};