1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 02:39:33 +02:00

Implement contact form on server side

This commit is contained in:
Chocobozzz 2019-01-09 15:14:29 +01:00
parent 8d00889b60
commit a4101923e6
No known key found for this signature in database
GPG key ID: 583A612D890159BE
32 changed files with 541 additions and 49 deletions

View file

@ -354,13 +354,32 @@ class Emailer {
return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload })
}
sendMail (to: string[], subject: string, text: string) {
addContactFormJob (fromEmail: string, fromName: string, body: string) {
const text = 'Hello dear admin,\n\n' +
fromName + ' sent you a message' +
'\n\n---------------------------------------\n\n' +
body +
'\n\n---------------------------------------\n\n' +
'Cheers,\n' +
'PeerTube.'
const emailPayload: EmailPayload = {
from: fromEmail,
to: [ CONFIG.ADMIN.EMAIL ],
subject: '[PeerTube] Contact form submitted',
text
}
return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload })
}
sendMail (to: string[], subject: string, text: string, from?: string) {
if (!this.enabled) {
throw new Error('Cannot send mail because SMTP is not configured.')
}
return this.transporter.sendMail({
from: CONFIG.SMTP.FROM_ADDRESS,
from: from || CONFIG.SMTP.FROM_ADDRESS,
to: to.join(','),
subject,
text