Skip to content

Commit 97bc9f1

Browse files
SevenWaysDPvirgilchiriac
authored andcommitted
BC-11237 - set 'from' field as required in Mail interface and configure fromEmailAddress in HelpdeskConfig (#6077)
1 parent c0d9823 commit 97bc9f1

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

apps/server/src/infra/mail/mail.interface.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export interface Mail {
4040

4141
recipients: string[];
4242

43-
from?: string;
43+
from: string;
4444

4545
cc?: string[];
4646

apps/server/src/infra/mail/mail.service.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ describe('MailService', () => {
4747
const data: Mail = {
4848
mail: { plainTextContent: 'content', subject: 'Test' },
4949
recipients: ['test@schul-cloud.org'],
50+
from: 'noreply@dbildungscloud.de',
5051
};
5152

5253
const amqpConnectionSpy = jest.spyOn(amqpConnection, 'publish');
@@ -64,6 +65,7 @@ describe('MailService', () => {
6465
cc: ['test@example.com', 'test5@schul-cloud.org', 'test6@schul-cloud.org'],
6566
bcc: ['test7@schul-cloud.org', 'test@example2.com', 'test8@schul-cloud.org'],
6667
replyTo: ['test@example3.com', 'test9@schul-cloud.org', 'test10@schul-cloud.org'],
68+
from: 'noreply@dbildungscloud.de',
6769
};
6870

6971
const amqpConnectionSpy = jest.spyOn(amqpConnection, 'publish');

apps/server/src/modules/helpdesk/domain/service/helpdesk.service.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export class HelpdeskService {
2323
files?: Express.Multer.File[]
2424
): Promise<void> {
2525
const plainTextContent = TextFormatter.createProblemText(problem, userContext, userDevice);
26-
await this.sendEmail(
26+
await this.userSendEmailToSupport(
2727
[this.config.problemEmailAddress],
2828
problem.replyEmail,
2929
problem.subject,
@@ -39,10 +39,16 @@ export class HelpdeskService {
3939
files?: Express.Multer.File[]
4040
): Promise<void> {
4141
const plainTextContent = TextFormatter.createWishText(wish, userContext, userDevice);
42-
await this.sendEmail([this.config.wishEmailAddress], wish.replyEmail, wish.subject, plainTextContent, files);
42+
await this.userSendEmailToSupport(
43+
[this.config.wishEmailAddress],
44+
wish.replyEmail,
45+
wish.subject,
46+
plainTextContent,
47+
files
48+
);
4349
}
4450

45-
private async sendEmail(
51+
private async userSendEmailToSupport(
4652
recipients: string[],
4753
replyTo: string,
4854
subject: string,
@@ -58,6 +64,7 @@ export class HelpdeskService {
5864
attachments,
5965
},
6066
replyTo: [replyTo],
67+
from: this.config.fromEmailAddress,
6168
};
6269

6370
if (this.config.shouldSendEmail) {

apps/server/src/modules/helpdesk/helpdesk-config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,8 @@ export class HelpdeskConfig {
1717
@StringToBoolean()
1818
@IsBoolean()
1919
public shouldSendEmail = false;
20+
21+
@ConfigProperty('SMTP_SENDER')
22+
@IsEmail()
23+
public fromEmailAddress = 'noreply@dbildungscloud.de';
2024
}

0 commit comments

Comments
 (0)