Built motion from commit 67e5df37.|2.0.66
[motion2.git] / server / config / seedDB / mailAccounts.js
1 'use strict';
2
3 var db = require('../../mysqldb').db;
4 var logger = require('../logger')('app');
5
6 exports.create = function() {
7     var account;
8     return db.MailAccount
9         .findOrCreate({
10             where: {
11                 service: true
12             },
13             defaults: {
14                 name: 'Service Mail',
15                 key: 'SERV',
16                 email: 'email@xcally.com',
17                 service: true,
18                 description: 'service motion account auto generated',
19                 active: false,
20                 ListId: 1
21             }
22         })
23         .spread(function(entity, created) {
24             if (created) {
25                 logger.info('service motion account auto generated');
26             }
27
28             account = entity;
29
30             return db.MailServerOut.findOrCreate({
31                 where: {
32                     MailAccountId: account.id
33                 },
34                 defaults: {
35                     host: '127.0.0.1',
36                     user: 'username',
37                     pass: 'password',
38                     port: 25,
39                     secure: false,
40                     authentication: false,
41                     MailAccountId: account.id,
42                     description: 'service motion smtp auto generated'
43                 }
44             });
45         })
46         .spread(function(entity, created) {
47             if (created) {
48                 logger.info('service motion smtp auto generated');
49             }
50
51             return db.MailServerIn.findOrCreate({
52                 where: {
53                     MailAccountId: account.id
54                 },
55                 defaults: {
56                     host: '127.0.0.1',
57                     user: 'username',
58                     password: 'password',
59                     port: 993,
60                     MailAccountId: account.id,
61                     description: 'service motion imap auto generated'
62                 }
63             });
64         })
65         .spread(function(entity, created) {
66             if (created) {
67                 logger.info('service motion imap auto generated');
68             }
69         })
70         .catch(function(err) {
71             logger.error('Can\'t create Mail Accounts');
72         });
73 };