Skip to content
This repository has been archived by the owner on Dec 2, 2023. It is now read-only.

Commit

Permalink
fix error sending notification when field is not defined
Browse files Browse the repository at this point in the history
  • Loading branch information
wodka committed Mar 13, 2022
1 parent 99fe3d2 commit 30c2bc9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions src/service/submission/submission.notification.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 30c2bc9

Please sign in to comment.