-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: main
Are you sure you want to change the base?
Conversation
New endpoint to accept bark beetle reports and forward them via PostMark for reviewing
There was a problem hiding this 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', |
There was a problem hiding this comment.
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', |
There was a problem hiding this comment.
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> { |
There was a problem hiding this comment.
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.
Add endpoint to send bark beetle reports. No need to save them. They are only sent out for manual tracking via PostMark automatic emails.