Skip to content

Commit 6c32a8d

Browse files
authored
Merge pull request #93 from Dialogue-Bot/DIAL-42-implement-test-your-bot
feat: update bot mail
2 parents 28a8c82 + 7cc2358 commit 6c32a8d

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

server/src/dtos/bot-mail.dto.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@ export class BotMailDto {
1010
@IsNotEmpty()
1111
subject: string
1212

13-
@IsString()
14-
@IsNotEmpty()
15-
@IsString()
16-
from: string
17-
1813
@IsString()
1914
@IsNotEmpty()
2015
template: string

server/src/queues/mail.queue.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@ export class SendMailQueue extends Queue {
1313
})
1414
}
1515

16+
/**
17+
* Adds a job to the mail queue.
18+
*
19+
* @param {object} options - The options for the job.
20+
* @param {boolean} [options.isPreventSpam=true] - Flag indicating whether to prevent spam.
21+
* @param {object} data - The data for the job.
22+
* @returns {Promise<object>} - The added job.
23+
* @throws {HttpException} - Throws a 429 error if the user is sending emails too frequently.
24+
*/
1625
async addJob({
1726
isPreventSpam = true,
1827
...data

server/src/services/bot-mail.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export class BotMailService {
1414
) {}
1515

1616
async sendMail(fields: BotMailDto) {
17-
const { from, subject, template, to, contactId } = fields
17+
const { subject, template, to, contactId } = fields
1818

1919
const channel = await this.channelService.findOneByContactId(contactId)
2020

@@ -34,7 +34,7 @@ export class BotMailService {
3434
const { email, password } = userSetting.email
3535

3636
await this.sendMailQueue.addJob({
37-
from,
37+
from: email,
3838
to,
3939
props: {} as any,
4040
subject,

0 commit comments

Comments
 (0)