Explorar o código

Added category support for sendgrid (#15970)

* Added category support for sendgrid

* use category only for confirmation code

GitOrigin-RevId: 1b93d8d0ac3699b9ad9f633f62b6471d163a2fba
Domagoj Kriskovic %!s(int64=2) %!d(string=hai) anos
pai
achega
b9834b0cbd

+ 6 - 0
services/web/app/src/Features/Email/EmailSender.js

@@ -94,6 +94,12 @@ async function sendEmail(options) {
     if (EMAIL_SETTINGS.textEncoding != null) {
       sendMailOptions.textEncoding = EMAIL_SETTINGS.textEncoding
     }
+    if (options.category) {
+      // category support for sendgrid
+      sendMailOptions.headers = {
+        'X-SMTPAPI': JSON.stringify({ category: options.category }),
+      }
+    }
     await client.sendMail(sendMailOptions)
   } catch (err) {
     throw new OError('error sending message').withCause(err)

+ 1 - 0
services/web/app/src/Features/User/UserEmailsConfirmationHandler.js

@@ -60,6 +60,7 @@ async function sendConfirmationCode(email) {
   await EmailHandler.promises.sendEmail('confirmCode', {
     to: email,
     confirmCode,
+    category: ['ConfirmEmail'],
   })
 
   return {