1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-04 10:19:35 +02:00

Implement contact form in the client

This commit is contained in:
Chocobozzz 2019-01-10 11:12:41 +01:00
parent 3866f1a02f
commit d3e56c0c4b
No known key found for this signature in database
GPG key ID: 583A612D890159BE
18 changed files with 281 additions and 24 deletions

View file

@ -18,7 +18,6 @@ class Emailer {
private static instance: Emailer
private initialized = false
private transporter: Transporter
private enabled = false
private constructor () {}
@ -27,7 +26,7 @@ class Emailer {
if (this.initialized === true) return
this.initialized = true
if (CONFIG.SMTP.HOSTNAME && CONFIG.SMTP.PORT) {
if (Emailer.isEnabled()) {
logger.info('Using %s:%s as SMTP server.', CONFIG.SMTP.HOSTNAME, CONFIG.SMTP.PORT)
let tls
@ -55,8 +54,6 @@ class Emailer {
tls,
auth
})
this.enabled = true
} else {
if (!isTestInstance()) {
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 {
}
}
isEnabled () {
return this.enabled
static isEnabled () {
return !!CONFIG.SMTP.HOSTNAME && !!CONFIG.SMTP.PORT
}
async checkConnectionOrDie () {
@ -374,7 +371,7 @@ class Emailer {
}
sendMail (to: string[], subject: string, text: string, from?: string) {
if (!this.enabled) {
if (!Emailer.isEnabled()) {
throw new Error('Cannot send mail because SMTP is not configured.')
}