-
Notifications
You must be signed in to change notification settings - Fork 4
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
feat: backend preparation for sending email forms #1458
Conversation
a71a4b5
to
d090d79
Compare
d090d79
to
5a310eb
Compare
9f24cd0
to
5970cac
Compare
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.
Some of these are up for discussion.
nest-forms-backend/src/utils/subservices/email-forms.subservice.ts
Outdated
Show resolved
Hide resolved
alertError( | ||
`ERROR onQueueConsumption: UnprocessableEntityException - ${FormsErrorsResponseEnum.FORM_DEFINITION_NOT_SUPPORTED_TYPE} ${form.formDefinitionSlug}.`, | ||
this.logger, | ||
) | ||
return new Nack(false) | ||
} | ||
|
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 logger debug below could probably be rephrased and used before line 116
it would also be nice to wrap the logic below this into function such as handleEmailForm
(handle slovenskSkForm ?)
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.
Actually it has to be used after the email check, if used before then Email forms would also throw errors.
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 meant this log
this.logger.debug(
`All files are in final state, sending message to nases for formId: ${data.formId}`,
)
am I missing something. I don't see that line throwing errors if moved earlier, and I guess the idea behind that log is that file check is done at that point and the queue procedes withg sending. It just needs rephrasing the 'nases' part
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.
Ahh I understand. I have rephrased it and moved few lines back.
nest-forms-backend/src/utils/subservices/email-forms.subservice.ts
Outdated
Show resolved
Hide resolved
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.
Please address the couple comments & LGTM 👍
Originally wanted to do more with isUserVerified, but we can move that forward along with some more cleanup, will leave you a slack message.
alertError( | ||
`Sending confirmation email to ${toEmail} for form ${formId} failed.`, | ||
this.logger, | ||
JSON.stringify(error), | ||
) |
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.
we likely want an alert even when toEmail is not defined - so that we notice if this happens a lot / happens when it should not
if ( | ||
!formDefinition.allowSendingByUnverifiedUsers && | ||
!this.isUserVerified(user) | ||
) { | ||
throw this.throwerErrorGuard.ForbiddenException( | ||
NasesErrorsEnum.SEND_UNVERIFIED, | ||
NasesErrorsResponseEnum.SEND_UNVERIFIED, | ||
) | ||
} | ||
|
||
if ( | ||
!this.formsHelper.userCanSendForm( | ||
form, | ||
formDefinition.allowSendingByUnverifiedUsers ?? false, | ||
userInfo, | ||
user?.sub, | ||
) | ||
) { | ||
throw this.throwerErrorGuard.ForbiddenException( | ||
NasesErrorsEnum.FORBIDDEN_SEND, | ||
NasesErrorsResponseEnum.FORBIDDEN_SEND, | ||
) | ||
} | ||
|
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.
these two must come before form vallidation - it's a minor (security) concern, but without these checks first you could get validation data for a form you don't own, which may contain user data
Test build pipeline info 🚀 🔜 forms-shared together with nest-forms-backend and next as those needs to be rebuild when forms-shared are changed |
Adds a backend support for handling email forms:
So far there are some TODOs: