Built motion from commit 1038d87.|0.0.141
[motion.git] / server / models / mail_server_in.js
index 9f92813..301037d 100644 (file)
@@ -1,15 +1,14 @@
-/**
- * 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,
@@ -30,8 +29,35 @@ module.exports = function(sequelize, DataTypes) {
                        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'