Skip to content

Commit

Permalink
VIH-7403 vho call jvs into room that doesnt exist in db (#356)
Browse files Browse the repository at this point in the history
* allow vhos to call jvs endpoint

* fixed code smell

* allow endpoint not to have advocate if VHO is calling

* allow endpoint not to have advocate if VHO is calling

* vho call should work with rooms that have yet to be created. Room will be created by the transfer event handler

Co-authored-by: Levi <[email protected]>
  • Loading branch information
levibutler and Levi authored Mar 4, 2021
1 parent 2481c04 commit 34e2bb4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,19 +189,20 @@ public async Task should_return_ok_when_endpoint_is_linked_with_defence_advocate
[Test]
public async Task should_return_ok_when_vho_invites()
{
var endpointWithDefenceAdvocate = TestConference.GetEndpoints().First(x => string.IsNullOrWhiteSpace(x.DefenceAdvocate));
var room = new Room(TestConference.Id, "Label", VideoApi.Domain.Enums.VirtualCourtRoomType.Participant, false);
QueryHandlerMock.Setup(x => x.Handle<GetRoomByIdQuery, Room>(It.IsAny<GetRoomByIdQuery>())).ReturnsAsync(room);

// Arrange
var endpointWithoutDefenceAdvocate = TestConference.GetEndpoints().First(x => string.IsNullOrWhiteSpace(x.DefenceAdvocate));
var request = new EndpointConsultationRequest()
{
ConferenceId = TestConference.Id,
EndpointId = endpointWithDefenceAdvocate.Id,
EndpointId = endpointWithoutDefenceAdvocate.Id,
DefenceAdvocateId = Guid.Empty,
RoomLabel = "Label"
RoomLabel = "NewRoom_NotInDb"
};

// Act
var result = await Controller.StartConsultationWithEndpointAsync(request);

// Assert
result.Should().BeOfType<OkResult>();
}
}
Expand Down
10 changes: 8 additions & 2 deletions VideoApi/VideoApi/Controllers/ConsultationController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,14 @@ public async Task<IActionResult> StartConsultationWithEndpointAsync(EndpointCons
return NotFound($"Unable to find endpoint {request.EndpointId}");
}

if (isVhoRequest)
{
await _consultationService.EndpointTransferToRoomAsync(request.ConferenceId, endpoint.Id, request.RoomLabel);
return Ok();
}

var defenceAdvocate = conference.GetParticipants().SingleOrDefault(x => x.Id == request.DefenceAdvocateId);
if (!isVhoRequest && defenceAdvocate == null)
if (defenceAdvocate == null)
{
_logger.LogWarning("Unable to find defence advocate");
return NotFound($"Unable to find defence advocate {request.DefenceAdvocateId}");
Expand All @@ -143,7 +149,7 @@ public async Task<IActionResult> StartConsultationWithEndpointAsync(EndpointCons
return Unauthorized(message);
}

if (!isVhoRequest && !endpoint.DefenceAdvocate.Trim().Equals(defenceAdvocate.Username.Trim(), StringComparison.CurrentCultureIgnoreCase))
if (!endpoint.DefenceAdvocate.Trim().Equals(defenceAdvocate.Username.Trim(), StringComparison.CurrentCultureIgnoreCase))
{
const string message = "Defence advocate is not allowed to speak to requested endpoint";
_logger.LogWarning(message);
Expand Down

0 comments on commit 34e2bb4

Please sign in to comment.