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

Bark beetle report #10

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft

Bark beetle report #10

wants to merge 4 commits into from

Conversation

Ignas-rgb
Copy link
Contributor

Add endpoint to send bark beetle reports. No need to save them. They are only sent out for manual tracking via PostMark automatic emails.

New endpoint to accept bark beetle reports and forward them via PostMark for reviewing
@Ignas-rgb Ignas-rgb requested a review from vycius March 27, 2024 14:17
src/report/postmark.service.ts Dismissed Show dismissed Hide dismissed
src/report/postmark.service.ts Dismissed Show dismissed Hide dismissed
Copy link
Member

@vycius vycius left a comment

Choose a reason for hiding this comment

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

It's relatively easy to abuse this feature and inundate email servers, potentially sending millions of emails through Postmark by making multiple calls to this endpoint. Keep this possibility in mind while implementing and using this feature. Otherwise, the code appears good.

attachments.push({
Name: 'nuotrauka' + i + '.jpg',
Content: encodedImageContent,
ContentType: 'image/jpeg',
Copy link
Member

Choose a reason for hiding this comment

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

The image won't always be 'image/jpeg'. I would recommended to detect the file type and extension dynamically using a magic number approach. Utilize libraries like file-type (https://www.npmjs.com/package/file-type) or equivalent for detection.

return this.postmarkService.sendBarkBeetleReport(
createReportDto,
images,
'benas.svedas@aad.am.lt',
Copy link
Member

Choose a reason for hiding this comment

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

I would recommend to move email to environment variables.

sendBarkBeetleReport(
@Body() createReportDto: CreateReportDto,
@UploadedFiles() images: Array<Express.Multer.File>,
): Promise<MessageSendingResponse> {
Copy link
Member

Choose a reason for hiding this comment

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

Not sure if it's really good to return such response to public. It might contain some confidential information.

@Ignas-rgb Ignas-rgb marked this pull request as draft June 5, 2024 15:59
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