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));
59 if (this.getDataValue('signature')) {
60 return _.toString(this.getDataValue('signature'));
65 tableName: 'mail_accounts',
66 associate: function(models) {
68 MailAccount.belongsTo(models.List);
69 MailAccount.belongsTo(models.Template);
70 MailAccount.hasMany(models.MailRoom);
71 MailAccount.hasMany(models.MailDisposition);
72 MailAccount.hasMany(models.MailApplication);
73 MailAccount.hasOne(models.MailServerIn, {
77 MailAccount.hasOne(models.MailServerOut, {
83 MailAccount.addScope('default', {
85 model: models.MailServerIn,
86 attributes: ['id', 'host', 'port', 'username', 'password', 'ssl', 'delete', 'filter', 'state', 'mailbox', 'connTimeout', 'authTimeout', 'keepalive', 'source']
88 model: models.MailServerOut,
89 attributes: ['id', 'host', 'port', 'username', 'password', 'ssl', 'service', 'state', 'source']
91 model: models.MailApplication,
101 model: models.MailQueue