3 const _ = require('lodash');
5 module.exports = function(sequelize, DataTypes) {
6 var MailAccount = sequelize.define('MailAccount', {
7 description: DataTypes.STRING,
12 type: DataTypes.STRING,
15 set: function(address) {
17 this.setDataValue('address', address.toLowerCase());
22 type: DataTypes.BOOLEAN,
26 type: DataTypes.INTEGER,
30 type: DataTypes.STRING
33 type: DataTypes.STRING
36 type: DataTypes.STRING
39 type: DataTypes.ENUM('GET', 'POST')
42 type: DataTypes.ENUM('GET', 'POST')
45 type: DataTypes.STRING,
47 return this.getDataValue('actions') ? JSON.parse(this.getDataValue('actions')) : [];
50 return this.setDataValue('actions', JSON.stringify(val));
54 type: DataTypes.STRING
57 type: DataTypes.ENUM('GET', 'POST')
62 if (this.getDataValue('signature')) {
63 return _.toString(this.getDataValue('signature'));
68 type: DataTypes.BOOLEAN,
72 type: DataTypes.BOOLEAN,
76 tableName: 'mail_accounts',
77 associate: function(models) {
79 MailAccount.belongsTo(models.List);
80 MailAccount.belongsTo(models.Template);
81 MailAccount.hasMany(models.MailRoom);
82 MailAccount.hasMany(models.MailDisposition);
83 MailAccount.hasMany(models.MailApplication);
84 MailAccount.hasOne(models.MailServerIn, {
88 MailAccount.hasOne(models.MailServerOut, {
94 MailAccount.addScope('default', {
99 model: models.MailServerIn,
100 attributes: ['id', 'host', 'port', 'username', 'password', 'ssl', 'delete', 'filter', 'state', 'mailbox', 'connTimeout', 'authTimeout', 'keepalive', 'source']
102 model: models.MailServerOut,
103 attributes: ['id', 'host', 'port', 'username', 'password', 'ssl', 'state', 'source', 'description']
105 model: models.MailApplication,
115 model: models.MailQueue