From 873d64e84bc220321771518c027077f4a12ee1e7 Mon Sep 17 00:00:00 2001 From: Christopher Kolstad Date: Mon, 30 Jun 2025 11:54:55 +0200 Subject: [PATCH] task: Added name and email of requester to track down spammers (#10235) As the title says. This adds name and email of requester to CR approval mails. This will hopefully have users complain to their coworkers rather than Unleash if they get too many mails. --- src/lib/services/email-service.ts | 17 ++++++++++------- .../requested-cr-approval.html.mustache | 2 +- .../requested-cr-approval.plain.mustache | 2 +- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/lib/services/email-service.ts b/src/lib/services/email-service.ts index 9c2f2b0259..f3776ea687 100644 --- a/src/lib/services/email-service.ts +++ b/src/lib/services/email-service.ts @@ -45,6 +45,13 @@ export interface IEmailEnvelope { headers?: Record; } +export interface ICrApprovalParameters { + changeRequestLink: string; + changeRequestTitle: string; + requesterName: string; + requesterEmail: string; +} + const RESET_MAIL_SUBJECT = 'Unleash - Reset your password'; const GETTING_STARTED_SUBJECT = 'Welcome to Unleash'; const PRODUCTIVITY_REPORT = 'Unleash - productivity report'; @@ -124,8 +131,7 @@ export class EmailService { async sendRequestedCRApprovalEmail( recipient: string, - changeRequestLink: string, - changeRequestTitle: string, + crApprovalParams: ICrApprovalParameters, ): Promise { if (this.configured()) { const year = new Date().getFullYear(); @@ -133,8 +139,7 @@ export class EmailService { 'requested-cr-approval', TemplateFormat.HTML, { - changeRequestLink, - changeRequestTitle, + ...crApprovalParams, year, }, ); @@ -142,8 +147,7 @@ export class EmailService { 'requested-cr-approval', TemplateFormat.PLAIN, { - changeRequestLink, - changeRequestTitle, + ...crApprovalParams, year, }, ); @@ -173,7 +177,6 @@ export class EmailService { this.logger.warn( 'No mailer is configured. Please read the docs on how to configure an email service', ); - this.logger.debug('Change request link: ', changeRequestLink); res({ from: this.sender, to: recipient, diff --git a/src/mailtemplates/requested-cr-approval/requested-cr-approval.html.mustache b/src/mailtemplates/requested-cr-approval/requested-cr-approval.html.mustache index 222f25a351..6f51cde264 100644 --- a/src/mailtemplates/requested-cr-approval/requested-cr-approval.html.mustache +++ b/src/mailtemplates/requested-cr-approval/requested-cr-approval.html.mustache @@ -340,7 +340,7 @@ diff --git a/src/mailtemplates/requested-cr-approval/requested-cr-approval.plain.mustache b/src/mailtemplates/requested-cr-approval/requested-cr-approval.plain.mustache index 6e74deb6ad..7f6ca0b7f7 100644 --- a/src/mailtemplates/requested-cr-approval/requested-cr-approval.plain.mustache +++ b/src/mailtemplates/requested-cr-approval/requested-cr-approval.plain.mustache @@ -1,3 +1,3 @@ -You have been added to review {{{ changeRequestTitle }}} +You have been added to review {{{ changeRequestTitle }}} by {{{ requesterName }}} ({{{ requesterEmail }}}) Follow the link: {{{ changeRequestLink }}} to review it.
-

You have been added to review {{{ changeRequestTitle }}}

+

You have been added to review {{{ changeRequestTitle }}} by {{{ requesterName }}} ({{{ requesterEmail }}})

Click {{{changeRequestLink}}} to review it