-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ConsumerAPI: Refactor IPushService (#374)
* refactor: split IPushService into Registration and Sender services * refactor: move IPushNotificationSender to BuildingBlocks.Application * refactor: update IPushNotificationSender registrations * Revert "refactor: update IPushNotificationSender registrations" This reverts commit 4ae5c11. * fix: renamed variables in the DeleteDeviceRegistration handler * refactor: update IPushNotificationSender registrations
- Loading branch information
Showing
13 changed files
with
55 additions
and
36 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
BuildingBlocks/src/BuildingBlocks.Application/PushNotifications/IPushNotificationSender.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using Backbone.DevelopmentKit.Identity.ValueObjects; | ||
|
||
namespace Backbone.BuildingBlocks.Application.PushNotifications; | ||
|
||
public interface IPushNotificationSender | ||
{ | ||
Task SendNotification(IdentityAddress recipient, object notification, CancellationToken cancellationToken); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
...vents/Incoming/DatawalletModificationCreated/DatawalletModifiedIntegrationEventHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
using Backbone.BuildingBlocks.Application.Abstractions.Infrastructure.EventBus; | ||
using Backbone.Modules.Devices.Application.Infrastructure.PushNotifications; | ||
using Backbone.BuildingBlocks.Application.PushNotifications; | ||
using Backbone.Modules.Devices.Application.Infrastructure.PushNotifications.Datawallet; | ||
|
||
namespace Backbone.Modules.Devices.Application.IntegrationEvents.Incoming.DatawalletModificationCreated; | ||
|
||
public class DatawalletModifiedIntegrationEventHandler : IIntegrationEventHandler<DatawalletModifiedIntegrationEvent> | ||
{ | ||
private readonly IPushService _pushService; | ||
private readonly IPushNotificationSender _pushSenderService; | ||
|
||
public DatawalletModifiedIntegrationEventHandler(IPushService pushService) | ||
public DatawalletModifiedIntegrationEventHandler(IPushNotificationSender pushSenderService) | ||
{ | ||
_pushService = pushService; | ||
_pushSenderService = pushSenderService; | ||
} | ||
|
||
public async Task Handle(DatawalletModifiedIntegrationEvent integrationEvent) | ||
{ | ||
await _pushService.SendNotification(integrationEvent.Identity, new DatawalletModificationsCreatedPushNotification(integrationEvent.ModifiedByDevice), CancellationToken.None); | ||
await _pushSenderService.SendNotification(integrationEvent.Identity, new DatawalletModificationsCreatedPushNotification(integrationEvent.ModifiedByDevice), CancellationToken.None); | ||
} | ||
} |
10 changes: 5 additions & 5 deletions
10
...rationEvents/Incoming/ExternalEventCreated/ExternalEventCreatedIntegrationEventHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
using Backbone.BuildingBlocks.Application.Abstractions.Infrastructure.EventBus; | ||
using Backbone.Modules.Devices.Application.Infrastructure.PushNotifications; | ||
using Backbone.BuildingBlocks.Application.PushNotifications; | ||
using Backbone.Modules.Devices.Application.Infrastructure.PushNotifications.ExternalEvents; | ||
|
||
namespace Backbone.Modules.Devices.Application.IntegrationEvents.Incoming.ExternalEventCreated; | ||
|
||
public class ExternalEventCreatedIntegrationEventHandler : IIntegrationEventHandler<ExternalEventCreatedIntegrationEvent> | ||
{ | ||
private readonly IPushService _pushService; | ||
private readonly IPushNotificationSender _pushSenderService; | ||
|
||
public ExternalEventCreatedIntegrationEventHandler(IPushService pushService) | ||
public ExternalEventCreatedIntegrationEventHandler(IPushNotificationSender pushSenderService) | ||
{ | ||
_pushService = pushService; | ||
_pushSenderService = pushSenderService; | ||
} | ||
|
||
public async Task Handle(ExternalEventCreatedIntegrationEvent @event) | ||
{ | ||
await _pushService.SendNotification(@event.Owner, new ExternalEventCreatedPushNotification(), CancellationToken.None); | ||
await _pushSenderService.SendNotification(@event.Owner, new ExternalEventCreatedPushNotification(), CancellationToken.None); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
...evices/src/Devices.Application/PushNotifications/Commands/SendTestNotification/Handler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
using Backbone.BuildingBlocks.Application.Abstractions.Infrastructure.UserContext; | ||
using Backbone.BuildingBlocks.Application.PushNotifications; | ||
using Backbone.DevelopmentKit.Identity.ValueObjects; | ||
using Backbone.Modules.Devices.Application.Infrastructure.PushNotifications; | ||
using MediatR; | ||
|
||
namespace Backbone.Modules.Devices.Application.PushNotifications.Commands.SendTestNotification; | ||
|
||
public class Handler : IRequestHandler<SendTestNotificationCommand, Unit> | ||
{ | ||
private readonly IdentityAddress _activeIdentity; | ||
private readonly IPushService _pushService; | ||
private readonly IPushNotificationSender _pushSenderService; | ||
|
||
public Handler(IUserContext userContext, IPushService pushService) | ||
public Handler(IUserContext userContext, IPushNotificationSender pushSenderService) | ||
{ | ||
_pushService = pushService; | ||
_pushSenderService = pushSenderService; | ||
_activeIdentity = userContext.GetAddress(); | ||
} | ||
|
||
public async Task<Unit> Handle(SendTestNotificationCommand request, CancellationToken cancellationToken) | ||
{ | ||
await _pushService.SendNotification(_activeIdentity, request.Data, cancellationToken); | ||
await _pushSenderService.SendNotification(_activeIdentity, request.Data, cancellationToken); | ||
return Unit.Value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 3 additions & 2 deletions
5
Modules/Devices/src/Devices.Infrastructure/PushNotifications/Dummy/DummyPushService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters