-/**
- * Chat Website Model
- */
-
-var crypto = require('crypto');
+'use strict';
module.exports = function(sequelize, DataTypes) {
var MailServerIn = sequelize.define('MailServerIn', {
description: DataTypes.STRING,
host: DataTypes.STRING,
- username: DataTypes.STRING,
+ username: {
+ type: DataTypes.STRING,
+ unique: true
+ },
password: DataTypes.STRING,
port: DataTypes.INTEGER,
mailbox: DataTypes.STRING,
defaultValue: 'IMAP'
},
state: {
- type: DataTypes.ENUM('CONNECTED', 'DISCONNECTED', 'ERROR', 'UNKNOWN'),
+ type: DataTypes.ENUM('CONNECTING', 'CONNECTED', 'DISCONNECTED', 'ERROR', 'UNKNOWN'),
defaultValue: 'UNKNOWN'
+ },
+ source: {
+ type: DataTypes.STRING
+ },
+ connTimeout: {
+ type: DataTypes.INTEGER,
+ defaultValue: 10000,
+ get: function() {
+ return this.getDataValue('connTimeout') ? this.getDataValue('connTimeout') / 1000 : null;
+ },
+ set: function(val) {
+ this.setDataValue('connTimeout', val * 1000);
+ }
+ },
+ authTimeout: {
+ type: DataTypes.INTEGER,
+ defaultValue: 5000,
+ get: function() {
+ return this.getDataValue('authTimeout') ? this.getDataValue('authTimeout') / 1000 : null;
+ },
+ set: function(val) {
+ this.setDataValue('authTimeout', val * 1000);
+ }
+ },
+ keepalive: {
+ type: DataTypes.BOOLEAN,
+ defaultValue: true
}
}, {
tableName: 'mail_servers_in'