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:
parent
3866f1a02f
commit
d3e56c0c4b
18 changed files with 281 additions and 24 deletions
|
@ -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.')
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue