Litte SQL optimzation in videos list
[oweals/peertube.git] / server / lib / emailer.ts
index bd3d4f252eb120132bb01dd27cd5cb1655c7b59e..7484524a4542880e016e43d149a3ac0e830a5524 100644 (file)
@@ -369,7 +369,7 @@ class Emailer {
   addPasswordResetEmailJob (to: string, resetPasswordUrl: string) {
     const text = `Hi dear user,\n\n` +
       `A reset password procedure for your account ${to} has been requested on ${WEBSERVER.HOST} ` +
-      `Please follow this link to reset it: ${resetPasswordUrl}\n\n` +
+      `Please follow this link to reset it: ${resetPasswordUrl}  (the link will expire within 1 hour)\n\n` +
       `If you are not the person who initiated this request, please ignore this email.\n\n` +
       `Cheers,\n` +
       `${CONFIG.EMAIL.BODY.SIGNATURE}`
@@ -441,7 +441,7 @@ class Emailer {
     return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload })
   }
 
-  sendMail (options: EmailPayload) {
+  async sendMail (options: EmailPayload) {
     if (!Emailer.isEnabled()) {
       throw new Error('Cannot send mail because SMTP is not configured.')
     }
@@ -450,13 +450,15 @@ class Emailer {
       ? options.fromDisplayName
       : WEBSERVER.HOST
 
-    return this.transporter.sendMail({
-      from: `"${fromDisplayName}" <${CONFIG.SMTP.FROM_ADDRESS}>`,
-      replyTo: options.replyTo,
-      to: options.to.join(','),
-      subject: options.subject,
-      text: options.text
-    })
+    for (const to of options.to) {
+      await this.transporter.sendMail({
+        from: `"${fromDisplayName}" <${CONFIG.SMTP.FROM_ADDRESS}>`,
+        replyTo: options.replyTo,
+        to,
+        subject: options.subject,
+        text: options.text
+      })
+    }
   }
 
   private dieOnConnectionFailure (err?: Error) {