-
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.
Consumer API: Revoke a Relationship reactivation request (#600)
* chore: move entities to Aggregates folder * feat: creation of Relationship and remove Changes related stuff * test: split into two tests * feat: acceptance of creation * feat: reject creation * feat: revoke creation * test: split relationship tests into multiple files * feat: allow multiple relationships as long as there is only one active * chore: remove redundant parameter * refactor: make RelationshipTemplatesRepository.Find return null instead of throwing * feat: add Handler * feat: add and use expressions * chore: don't use AutoMapper and add more tests * feat: reject relationship * feat: AcceptRelationshipCommand * feat: RevokeRelationshipCommand * feat: add AuditLog to DTOs * feat: add CreationContent property to RelationshipDTO * feat: add additional properties to RelationshipCreatedIntegrationEvent and RelationshipStatusChangedIntegrationEvent * feat: handle new integration events in Synchronization module * chore: formatting * test: fix tests * feat: replace integration events in quotas module with new ones * feat: add migration * feat: add controller methods * chore: fix/ignore compiler warnings * refactor: cleanup error codes * feat: add insomnia workspace * feat: add openapi.yml * fix: add RelationshipMetadataDTO type and add creationContent property to RelationshipDTO * refactor: rename Content to CreationContent in request to create a relationship * chore: update InsomniaWorkspace and openapi.yml * chore: rename RelationshipStatus "Accepted" to "Active" * chore: fix merge conflicts * feat: implement domain part * feat: implement application part * feat: implement controller * chore: remove redundant whitespace * test: add domain and handler tests * feat: update domain errors * feat: trigger external event * chore: fix formatting * chore: update files prior to making PR ready for review * chore: fix formatting * feat: add AcceptanceContent * fix: avoid error on creation of RelationshipsOverview view when RelationshipChanges table does not exist * feat: (WIP!!): update Admin API RelationshipOverviews view * feat: add AcceptanceContent to DTO * fix: pass AcceptanceContent to AcceptRelationshipCommand * chore: use postgres in Admin CLI launchSettings.json * chore: fix formatting * chore: add _relationshipTemplateAllocations field * fix: update failing test * fix: update tests * fix: relationships overview migration * feat: update revamped relationships overview view with audit log * feat: implementing PR change requests * feat: implement PR change requests * chore: remove CreatedAt property * feat: implement PR change requests * chore: remove redundant Relationship statuses * fix: update condition * chore: update identifier * Merge branch 'release/v5' of github.com:nmshd/backbone into nmshdb-89-termination-of-a-relationship * chore: fix formatting * chore: update object property name * Merge branch 'release/v5' of github.com:nmshd/backbone into nmshdb-93-revocation-of-a-reactivation-of-a-relationship * feat: implement PR change requests * feat: order audit logs before accessing the last * fix: return helper method * chore: fix formatting * fix: consider the time of the reactivation within the given quota period * fix: remove unused relationship created type * feat: address PR change requests * feat: address PR change requests * chore: add named parameters to test methods * chore: fix formatting * fix: remove nullable reference type from CreatedBy prop, RelationshipAuditLogEntry --------- Co-authored-by: Timo Notheisen <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Timo Notheisen <[email protected]> Co-authored-by: Daniel Almeida <[email protected]> Co-authored-by: Hunor Tot-Bagi <[email protected]> Co-authored-by: Nikola Dmitrasinovic <[email protected]>
- Loading branch information
1 parent
13cae23
commit 6f90d49
Showing
32 changed files
with
402 additions
and
38 deletions.
There are no files selected for viewing
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
40 changes: 40 additions & 0 deletions
40
...elationships.Application/Relationships/Commands/RevokeRelationshipReactivation/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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using Backbone.BuildingBlocks.Application.Abstractions.Infrastructure.EventBus; | ||
using Backbone.BuildingBlocks.Application.Abstractions.Infrastructure.UserContext; | ||
using Backbone.DevelopmentKit.Identity.ValueObjects; | ||
using Backbone.Modules.Relationships.Application.Infrastructure.Persistence.Repository; | ||
using Backbone.Modules.Relationships.Domain.Aggregates.Relationships; | ||
using Backbone.Modules.Relationships.Domain.DomainEvents.Outgoing; | ||
using MediatR; | ||
|
||
namespace Backbone.Modules.Relationships.Application.Relationships.Commands.RevokeRelationshipReactivation; | ||
public class Handler : IRequestHandler<RevokeRelationshipReactivationCommand, RevokeRelationshipReactivationResponse> | ||
{ | ||
private readonly IRelationshipsRepository _relationshipsRepository; | ||
private readonly IEventBus _eventBus; | ||
private readonly IdentityAddress _activeIdentity; | ||
private readonly DeviceId _activeDevice; | ||
|
||
public Handler(IRelationshipsRepository relationshipsRepository, IUserContext userContext, IEventBus eventBus) | ||
{ | ||
_relationshipsRepository = relationshipsRepository; | ||
_eventBus = eventBus; | ||
_activeIdentity = userContext.GetAddress(); | ||
_activeDevice = userContext.GetDeviceId(); | ||
} | ||
|
||
public async Task<RevokeRelationshipReactivationResponse> Handle(RevokeRelationshipReactivationCommand request, CancellationToken cancellationToken) | ||
{ | ||
var relationshipId = RelationshipId.Parse(request.RelationshipId); | ||
var relationship = await _relationshipsRepository.FindRelationship(relationshipId, _activeIdentity, cancellationToken, track: true); | ||
|
||
relationship.RevokeReactivation(_activeIdentity, _activeDevice); | ||
|
||
await _relationshipsRepository.Update(relationship); | ||
|
||
var peer = relationship.To == _activeIdentity ? relationship.From : relationship.To; | ||
|
||
_eventBus.Publish(new RelationshipReactivationCompletedDomainEvent(relationship, peer)); | ||
|
||
return new RevokeRelationshipReactivationResponse(relationship); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...ionships/Commands/RevokeRelationshipReactivation/RevokeRelationshipReactivationCommand.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,7 @@ | ||
using MediatR; | ||
|
||
namespace Backbone.Modules.Relationships.Application.Relationships.Commands.RevokeRelationshipReactivation; | ||
public class RevokeRelationshipReactivationCommand : IRequest<RevokeRelationshipReactivationResponse> | ||
{ | ||
public required string RelationshipId { get; set; } | ||
} |
8 changes: 8 additions & 0 deletions
8
...onships/Commands/RevokeRelationshipReactivation/RevokeRelationshipReactivationResponse.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,8 @@ | ||
using Backbone.Modules.Relationships.Application.Relationships.DTOs; | ||
using Backbone.Modules.Relationships.Domain.Aggregates.Relationships; | ||
|
||
namespace Backbone.Modules.Relationships.Application.Relationships.Commands.RevokeRelationshipReactivation; | ||
public class RevokeRelationshipReactivationResponse : RelationshipMetadataDTO | ||
{ | ||
public RevokeRelationshipReactivationResponse(Relationship relationship) : base(relationship) { } | ||
} |
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
16 changes: 16 additions & 0 deletions
16
...elationships.Domain/DomainEvents/Outgoing/RelationshipReactivationCompletedDomainEvent.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,16 @@ | ||
using Backbone.BuildingBlocks.Domain.Events; | ||
using Backbone.DevelopmentKit.Identity.ValueObjects; | ||
using Backbone.Modules.Relationships.Domain.Aggregates.Relationships; | ||
|
||
namespace Backbone.Modules.Relationships.Domain.DomainEvents.Outgoing; | ||
public class RelationshipReactivationCompletedDomainEvent : DomainEvent | ||
{ | ||
public RelationshipReactivationCompletedDomainEvent(Relationship relationship, IdentityAddress peer) | ||
{ | ||
RelationshipId = relationship.Id; | ||
Peer = peer.Value; | ||
} | ||
|
||
public string RelationshipId { get; } | ||
public string Peer { get; } | ||
} |
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
Oops, something went wrong.