5 var _ = require('lodash');
7 module.exports = function(sequelize, DataTypes) {
9 var MailAccount = sequelize.define('MailAccount', {
10 description: DataTypes.STRING,
12 type: DataTypes.STRING
15 type: DataTypes.STRING,
18 set: function(address) {
20 this.setDataValue('address', address.toLowerCase());
25 type: DataTypes.BOOLEAN,
29 type: DataTypes.INTEGER,
33 type: DataTypes.STRING
36 type: DataTypes.STRING
39 type: DataTypes.STRING
42 type: DataTypes.ENUM('GET', 'POST')
45 type: DataTypes.ENUM('GET', 'POST')
48 type: DataTypes.STRING,
50 return this.getDataValue('actions') ? JSON.parse(this.getDataValue('actions')) : [];
53 return this.setDataValue('actions', JSON.stringify(val));
57 type: DataTypes.STRING
60 type: DataTypes.ENUM('GET', 'POST')
65 if (this.getDataValue('signature')) {
66 return _.toString(this.getDataValue('signature'));
71 type: DataTypes.BOOLEAN,
75 type: DataTypes.BOOLEAN,
79 tableName: 'mail_accounts',
80 associate: function(models) {
82 MailAccount.belongsTo(models.List);
83 MailAccount.belongsTo(models.Template);
84 MailAccount.hasMany(models.MailRoom);
85 MailAccount.hasMany(models.MailDisposition);
86 MailAccount.hasMany(models.MailApplication);
87 MailAccount.hasOne(models.MailServerIn, {
91 MailAccount.hasOne(models.MailServerOut, {
97 MailAccount.addScope('default', {
102 model: models.MailServerIn,
103 attributes: ['id', 'host', 'port', 'username', 'password', 'ssl', 'delete', 'filter', 'state', 'mailbox', 'connTimeout', 'authTimeout', 'keepalive', 'source']
105 model: models.MailServerOut,
106 attributes: ['id', 'host', 'port', 'username', 'password', 'ssl', 'state', 'source', 'description']
108 model: models.MailApplication,
118 model: models.MailQueue