fix error sending notification when field is not defined

This commit is contained in:
Michael Schramm 2022-03-13 23:35:40 +01:00
parent 99fe3d2fe0
commit 30c2bc9c05
2 changed files with 8 additions and 2 deletions

View File

@ -26,6 +26,8 @@ Template for next version
### Fixed
- error sending notification when field is not defined (https://github.com/ohmyform/ohmyform/issues/161)
### Security
## [1.0.1] - 2022-03-01

View File

@ -25,12 +25,12 @@ export class SubmissionNotificationService {
try {
const to = this.getEmail(
submission,
notification.toField.id,
notification.toField?.id,
notification.toEmail
)
const from = this.getEmail(
submission,
notification.fromField.id,
notification.fromField?.id,
notification.fromEmail
)
@ -73,6 +73,10 @@ export class SubmissionNotificationService {
}
private getEmail(submission: SubmissionEntity, fieldId: number, fallback: string): string {
if (!fieldId) {
return fallback
}
const data = submission.fields.find(field => field.fieldId === fieldId)?.content
if (!data) {