Skip to content

Commit

Permalink
fix: don't try to send a push notification to a non existing identity
Browse files Browse the repository at this point in the history
  • Loading branch information
tnotheis committed Dec 20, 2024
1 parent a1ddbfd commit 174f7f1
Showing 1 changed file with 3 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using Backbone.BuildingBlocks.Application.Abstractions.Exceptions;
using Backbone.BuildingBlocks.Application.Abstractions.Infrastructure.EventBus;
using Backbone.BuildingBlocks.Application.PushNotifications;
using Backbone.Modules.Devices.Application.Infrastructure.Persistence.Repository;
Expand All @@ -24,13 +23,9 @@ public async Task Handle(ExternalEventCreatedDomainEvent @event)
if (@event.IsDeliveryBlocked)
return;

var identity = await _identitiesRepository.FindByAddress(@event.Owner, CancellationToken.None) ?? throw new NotFoundException(nameof(Identity));
var identity = await _identitiesRepository.FindByAddress(@event.Owner, CancellationToken.None);

if (identity.Status != IdentityStatus.ToBeDeleted)
await _pushSenderService.SendNotification(
new ExternalEventCreatedPushNotification(),
SendPushNotificationFilter.AllDevicesOf(@event.Owner),
CancellationToken.None
);
if (identity != null && identity.Status != IdentityStatus.ToBeDeleted)
await _pushSenderService.SendNotification(new ExternalEventCreatedPushNotification(), SendPushNotificationFilter.AllDevicesOf(@event.Owner), CancellationToken.None);
}
}

0 comments on commit 174f7f1

Please sign in to comment.