aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-01-10 11:12:41 +0100
committerChocobozzz <me@florianbigard.com>2019-01-10 11:32:38 +0100
commitd3e56c0c4b307c99e83fbafb7f2c5884cbc20055 (patch)
tree39976ee10a49fa2b9d7eb87437f59c872e7db0b8 /server/lib
parent3866f1a02f73665541468fbadcc3cd2cc459aef2 (diff)
downloadPeerTube-d3e56c0c4b307c99e83fbafb7f2c5884cbc20055.tar.gz
PeerTube-d3e56c0c4b307c99e83fbafb7f2c5884cbc20055.tar.zst
PeerTube-d3e56c0c4b307c99e83fbafb7f2c5884cbc20055.zip
Implement contact form in the client
Diffstat (limited to 'server/lib')
-rw-r--r--server/lib/emailer.ts11
1 files changed, 4 insertions, 7 deletions
diff --git a/server/lib/emailer.ts b/server/lib/emailer.ts
index 9b1c5122f..f384a254e 100644
--- a/server/lib/emailer.ts
+++ b/server/lib/emailer.ts
@@ -18,7 +18,6 @@ class Emailer {
18 private static instance: Emailer 18 private static instance: Emailer
19 private initialized = false 19 private initialized = false
20 private transporter: Transporter 20 private transporter: Transporter
21 private enabled = false
22 21
23 private constructor () {} 22 private constructor () {}
24 23
@@ -27,7 +26,7 @@ class Emailer {
27 if (this.initialized === true) return 26 if (this.initialized === true) return
28 this.initialized = true 27 this.initialized = true
29 28
30 if (CONFIG.SMTP.HOSTNAME && CONFIG.SMTP.PORT) { 29 if (Emailer.isEnabled()) {
31 logger.info('Using %s:%s as SMTP server.', CONFIG.SMTP.HOSTNAME, CONFIG.SMTP.PORT) 30 logger.info('Using %s:%s as SMTP server.', CONFIG.SMTP.HOSTNAME, CONFIG.SMTP.PORT)
32 31
33 let tls 32 let tls
@@ -55,8 +54,6 @@ class Emailer {
55 tls, 54 tls,
56 auth 55 auth
57 }) 56 })
58
59 this.enabled = true
60 } else { 57 } else {
61 if (!isTestInstance()) { 58 if (!isTestInstance()) {
62 logger.error('Cannot use SMTP server because of lack of configuration. PeerTube will not be able to send mails!') 59 logger.error('Cannot use SMTP server because of lack of configuration. PeerTube will not be able to send mails!')
@@ -64,8 +61,8 @@ class Emailer {
64 } 61 }
65 } 62 }
66 63
67 isEnabled () { 64 static isEnabled () {
68 return this.enabled 65 return !!CONFIG.SMTP.HOSTNAME && !!CONFIG.SMTP.PORT
69 } 66 }
70 67
71 async checkConnectionOrDie () { 68 async checkConnectionOrDie () {
@@ -374,7 +371,7 @@ class Emailer {
374 } 371 }
375 372
376 sendMail (to: string[], subject: string, text: string, from?: string) { 373 sendMail (to: string[], subject: string, text: string, from?: string) {
377 if (!this.enabled) { 374 if (!Emailer.isEnabled()) {
378 throw new Error('Cannot send mail because SMTP is not configured.') 375 throw new Error('Cannot send mail because SMTP is not configured.')
379 } 376 }
380 377