Built motion from commit 95b01fa.|0.0.70
[motion.git] / server / models / mail_server_in.js
1 /**
2  * Chat Website Model
3  */
4
5 var crypto = require('crypto');
6
7 module.exports = function(sequelize, DataTypes) {
8
9         var MailServerIn = sequelize.define('MailServerIn', {
10                 description: DataTypes.STRING,
11                 host: DataTypes.STRING,
12                 username: {
13                         type: DataTypes.STRING,
14                         unique: true
15                 },
16                 password: DataTypes.STRING,
17                 port: DataTypes.INTEGER,
18                 mailbox: DataTypes.STRING,
19                 ssl: {
20                         type: DataTypes.BOOLEAN,
21                         defaultValue: false
22                 },
23                 delete: {
24                         type: DataTypes.BOOLEAN,
25                         defaultValue: false
26                 },
27                 filter: {
28                         type: DataTypes.ENUM('UNSEEN'),
29                         defaultValue: 'UNSEEN'
30                 },
31                 protocol: {
32                         type: DataTypes.ENUM('IMAP', 'POP3'),
33                         defaultValue: 'IMAP'
34                 },
35                 state: {
36                         type: DataTypes.ENUM('CONNECTED', 'DISCONNECTED', 'ERROR', 'UNKNOWN'),
37                         defaultValue: 'UNKNOWN'
38                 },
39                 connTimeout: {
40                         type: DataTypes.INTEGER,
41                         defaultValue: 10000,
42                         get: function() {
43                                 return this.getDataValue('connTimeout') ? this.getDataValue('connTimeout') / 1000 : null;
44                         },
45                         set: function(val) {
46                                 this.setDataValue('connTimeout', val * 1000);
47                         }
48                 },
49                 authTimeout: {
50                         type: DataTypes.INTEGER,
51                         defaultValue: 5000,
52                         get: function() {
53                                 return this.getDataValue('authTimeout') ? this.getDataValue('authTimeout') / 1000 : null;
54                         },
55                         set: function(val) {
56                                 this.setDataValue('authTimeout', val * 1000);
57                         }
58                 },
59                 keepalive: {
60                         type: DataTypes.BOOLEAN,
61                         defaultValue: true
62                 }
63         }, {
64                 tableName: 'mail_servers_in'
65         });
66
67         return MailServerIn;
68 };