Skip to content

Commit

Permalink
Merge branch 'main' into nmshdb-136-deletion-of-messages-after-all-re…
Browse files Browse the repository at this point in the history
…cipients-have-been-anonymized
  • Loading branch information
mergify[bot] authored Sep 17, 2024
2 parents b5ad5b8 + b04878d commit 643d44e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,10 @@ Feature: GET /Relationships/CanCreate
When i1 sends a GET request to the /Relationships/CanCreate?peer={id} endpoint with id=i2.id
Then the response status code is 200 (OK)
And a Relationship can be established

Scenario: Cannot create Relationship if peer is to be deleted
Given Identities i1 and i2
And i2 is in status "ToBeDeleted"
When i1 sends a GET request to the /Relationships/CanCreate?peer={id} endpoint with id=i2.id
Then the response status code is 200 (OK)
And a Relationship can not be established
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,14 @@ public async Task<IActionResult> DecomposeRelationship([FromRoute] string id, Ca
[HttpGet("CanCreate")]
[ProducesResponseType(typeof(HttpResponseEnvelopeResult<CanEstablishRelationshipResponse>), StatusCodes.Status200OK)]
[ProducesError(StatusCodes.Status400BadRequest)]
public async Task<IActionResult> CanEstablishRelationship([FromQuery] string peer, CancellationToken cancellationToken)
public async Task<IActionResult> CanEstablishRelationship([FromQuery(Name = "peer")] string peerAddress, CancellationToken cancellationToken)
{
var response = await _mediator.Send(new CanEstablishRelationshipQuery { PeerAddress = peer }, cancellationToken);
var peerIdentity = await _mediator.Send(new GetIdentityQuery(peerAddress), cancellationToken);

var response = peerIdentity.Status is IdentityStatus.ToBeDeleted
? new CanEstablishRelationshipResponse { CanCreate = false }
: await _mediator.Send(new CanEstablishRelationshipQuery { PeerAddress = peerAddress }, cancellationToken);

return Ok(response);
}

Expand Down

0 comments on commit 643d44e

Please sign in to comment.