From 0482d2be1be87ee53d6c79051bddc9cfea8d7642 Mon Sep 17 00:00:00 2001 From: Stephanie Buadu <47737608+acn-sbuad@users.noreply.github.com> Date: Wed, 24 Apr 2024 15:48:07 +0200 Subject: [PATCH] ensure null does not give address point (#501) --- .../Services/ContactPointService.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Altinn.Notifications.Core/Services/ContactPointService.cs b/src/Altinn.Notifications.Core/Services/ContactPointService.cs index dfb19be9..2786ec69 100644 --- a/src/Altinn.Notifications.Core/Services/ContactPointService.cs +++ b/src/Altinn.Notifications.Core/Services/ContactPointService.cs @@ -28,7 +28,11 @@ await AugmentRecipients( recipients, (recipient, userContactPoints) => { - recipient.AddressInfo.Add(new EmailAddressPoint(userContactPoints.Email)); + if (!string.IsNullOrEmpty(userContactPoints.Email)) + { + recipient.AddressInfo.Add(new EmailAddressPoint(userContactPoints.Email)); + } + return recipient; }); } @@ -40,7 +44,11 @@ await AugmentRecipients( recipients, (recipient, userContactPoints) => { - recipient.AddressInfo.Add(new SmsAddressPoint(userContactPoints.MobileNumber)); + if (!string.IsNullOrEmpty(userContactPoints.MobileNumber)) + { + recipient.AddressInfo.Add(new SmsAddressPoint(userContactPoints.MobileNumber)); + } + return recipient; }); }