Built motion from commit d415888.|0.0.73
[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                 source: {
40                         type: DataTypes.STRING
41                 },
42                 connTimeout: {
43                         type: DataTypes.INTEGER,
44                         defaultValue: 10000,
45                         get: function() {
46                                 return this.getDataValue('connTimeout') ? this.getDataValue('connTimeout') / 1000 : null;
47                         },
48                         set: function(val) {
49                                 this.setDataValue('connTimeout', val * 1000);
50                         }
51                 },
52                 authTimeout: {
53                         type: DataTypes.INTEGER,
54                         defaultValue: 5000,
55                         get: function() {
56                                 return this.getDataValue('authTimeout') ? this.getDataValue('authTimeout') / 1000 : null;
57                         },
58                         set: function(val) {
59                                 this.setDataValue('authTimeout', val * 1000);
60                         }
61                 },
62                 keepalive: {
63                         type: DataTypes.BOOLEAN,
64                         defaultValue: true
65                 }
66         }, {
67                 tableName: 'mail_servers_in'
68         });
69
70         return MailServerIn;
71 };