forked from pantsel/konga
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEmailTransport.js
141 lines (133 loc) · 3.76 KB
/
EmailTransport.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
'use strict';
var _ = require('lodash');
/**
* KongNode.js
*
* @description :: TODO: You might write a short summary of how this model works and what it represents here.
* @docs :: http://sailsjs.org/#!documentation/models
*/
var defaultModel = _.merge(_.cloneDeep(require('../base/Model')), {
tableName: "konga_email_transports",
autoPK: false,
attributes: {
id: {
type: 'integer',
primaryKey: true,
unique: true,
autoIncrement: true
},
name: {
type: 'string',
required: true,
unique: true
},
description: {
type: 'string'
},
schema: {
type: 'json'
},
settings: {
type: 'json'
},
active: {
type: 'boolean',
defaultsTo: false
}
},
seedData: [
{
"name": "smtp",
"description": "Send emails using the SMTP protocol",
"schema": [
{
name: "host",
description: "The SMTP host",
type: "text",
required: true
},
{
name: "port",
description: "The SMTP port",
type: "text",
required: true
},
{
name: "username",
model: "auth.user",
description: "The SMTP user username",
type: "text",
required: true
},
{
name: "password",
model: "auth.pass",
description: "The SMTP user password",
type: "text",
required: true
},
{
name: "secure",
model: "secure",
description: "Use secure connection",
type: "boolean"
}
],
"settings": {
host: '',
port: '',
auth: {
user: '',
pass: ''
},
secure : false
},
"active": true
},
{
"name": "sendmail",
"description": "Pipe messages to the sendmail command",
"settings": {
sendmail: true
}
},
{
"name": "mailgun",
"description": "Send emails through Mailgun’s Web API",
"schema": [
{
name: "api_key",
model: "auth.api_key",
description: "The API key that you got from www.mailgun.com/cp",
type: "text",
required: true
},
{
name: "domain",
model: "auth.domain",
description: "One of your domain names listed at your https://mailgun.com/app/domains",
type: "text",
required: true
}
],
"settings": {
auth: {
api_key: '',
domain: ''
}
}
}
]
});
var mongoModel = function () {
var obj = _.cloneDeep(defaultModel)
delete obj.autoPK
delete obj.attributes.id
return obj;
}
if(sails.config.models.connection == 'postgres' && process.env.DB_PG_SCHEMA) {
defaultModel.meta = {
schemaName: process.env.DB_PG_SCHEMA
}
}
module.exports = sails.config.models.connection == 'mongo' ? mongoModel() : defaultModel