Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Email send task #665

Merged
merged 16 commits into from
Sep 27, 2024
Merged

Email send task #665

merged 16 commits into from
Sep 27, 2024

Conversation

Martbul
Copy link
Contributor

@Martbul Martbul commented Sep 2, 2024

No description provided.

Copy link

github-actions bot commented Sep 2, 2024

✅ Tests will run for this PR. Once they succeed it can be merged.

Copy link
Member

@sashko9807 sashko9807 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some conflicts to be fixed as well

@Injectable()
export class CampaignApplicationService {
private readonly bucketName: string = 'campaignapplication-files'
constructor(
private prisma: PrismaService,
private organizerService: OrganizerService,
private s3: S3Service,
private sendEmail: EmailService,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please rename to sendEmail to emailService

person: Person,
) {
const userEmail = { to: [person.email] as EmailData[] }
const adminEmail = { to: ['campaign_coordinators@podkrepi.bg'] as EmailData[] }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would probably be better to put campaign_coordinators@podkrepi.bg into env, as it might be used in other places in the future. Something like CAMPAIGN_COORDINATOR_EMAIL would do I suppose


await this.sendEmail.sendFromTemplate(mailAdmin, adminEmail, {
bypassUnsubscribeManagement: { enable: true },
})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any reason to await sending the emails, since they are not urgent for the response, and are allowed to happen with some delay. Though if there is any valid reason you can do it concurrently with Promise.allSettled, instead of doing it sequential, since neither of the promises are depended by the result of the another one.
Example:

const userEmailPromise = this.sendEmail.sendFromTemplate(mailOrganizer, userEmail, {
        bypassUnsubscribeManagement: { enable: true },
      })
const adminEmailPromise = this.sendEmail.sendFromTemplate(mailAdmin, adminEmail, {
        bypassUnsubscribeManagement: { enable: true },
      })
await Promise.allSettled([userEmailPromise, adminEmailPromise])

@sashko9807 sashko9807 added the run tests Allows running the tests workflows for forked repos label Sep 26, 2024
@github-actions github-actions bot removed the run tests Allows running the tests workflows for forked repos label Sep 26, 2024
@sashko9807 sashko9807 merged commit 1bcb946 into podkrepi-bg:master Sep 27, 2024
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants