5 module.exports = function(sequelize, DataTypes) {
7 var MailAccount = sequelize.define('MailAccount', {
8 description: DataTypes.STRING,
10 type: DataTypes.STRING
13 type: DataTypes.STRING,
16 set: function(address) {
18 this.setDataValue('address', address.toLowerCase());
23 type: DataTypes.BOOLEAN,
27 type: DataTypes.INTEGER,
31 type: DataTypes.STRING
34 type: DataTypes.STRING
37 type: DataTypes.STRING
40 type: DataTypes.ENUM('GET', 'POST')
43 type: DataTypes.ENUM('GET', 'POST')
46 type: DataTypes.STRING,
48 return this.getDataValue('actions') ? JSON.parse(this.getDataValue('actions')) : [];
51 return this.setDataValue('actions', JSON.stringify(val));
55 tableName: 'mail_accounts',
56 associate: function(models) {
58 MailAccount.belongsTo(models.List);
59 MailAccount.belongsTo(models.Template);
60 MailAccount.hasMany(models.MailRoom);
61 MailAccount.hasMany(models.MailDisposition);
62 MailAccount.hasMany(models.MailApplication);
63 MailAccount.hasOne(models.MailServerIn, {
67 MailAccount.hasOne(models.MailServerOut, {
73 MailAccount.addScope('default', {
75 model: models.MailServerIn,
76 attributes: ['id', 'host', 'port', 'username', 'password', 'ssl', 'delete', 'filter', 'state', 'mailbox', 'connTimeout', 'authTimeout', 'keepalive', 'source']
78 model: models.MailServerOut,
79 attributes: ['id', 'host', 'port', 'username', 'password', 'ssl', 'service', 'state', 'source']
81 model: models.MailApplication,
91 model: models.MailQueue