Skip to content

Commit

Permalink
VIH-10812 do not auto transfer staff members into a hearing
Browse files Browse the repository at this point in the history
  • Loading branch information
shaed-parkar committed Jul 8, 2024
1 parent 41e52b3 commit bc1aee6
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 19 deletions.
3 changes: 0 additions & 3 deletions VideoApi/VideoApi.Contract/Requests/StartHearingRequest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System.Collections.Generic;

namespace VideoApi.Contract.Requests
{
public enum HearingLayout
Expand All @@ -15,7 +13,6 @@ public StartHearingRequest()
Layout = HearingLayout.Dynamic;
}
public HearingLayout? Layout { get; set; }
public IEnumerable<string> ParticipantsToForceTransfer { get; set; }
public bool? MuteGuests { get; set; }
public string TriggeredByHostId { get; set; }
}
Expand Down
3 changes: 2 additions & 1 deletion VideoApi/VideoApi.Domain/ParticipantBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ public void UpdateCurrentConsultationRoom(ConsultationRoom consultationRoom)

public bool CanAutoTransferToHearingRoom()
{
return UserRole != UserRole.QuickLinkParticipant && UserRole != UserRole.QuickLinkObserver && HearingRole != "Witness";
return UserRole != UserRole.QuickLinkParticipant && UserRole != UserRole.QuickLinkObserver &&
HearingRole != "Witness" && UserRole != UserRole.StaffMember;
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public async Task should_return_accepted_when_start_hearing_has_been_requested()
{
Layout = layout,
TriggeredByHostId = TestConference.Participants.Single(x => x.UserRole == VideoApi.Domain.Enums.UserRole.Judge).Id.ToString(),
ParticipantsToForceTransfer = participantIds,
MuteGuests = true
};
Mocker.Mock<IQueryHandler>()
Expand All @@ -51,12 +50,11 @@ public async Task should_return_accepted_when_start_hearing_with_muted_guests_ha
var conferenceId = TestConference.Id;
var layout = HearingLayout.OnePlus7;
var participantIds = TestConference.Participants.Select(x => x.Id.ToString());
var muteGuests = true;
var request = new Contract.Requests.StartHearingRequest
{
Layout = layout,
TriggeredByHostId = TestConference.Participants.Single(x => x.UserRole == VideoApi.Domain.Enums.UserRole.Judge).Id.ToString(),
ParticipantsToForceTransfer = participantIds,
MuteGuests = true
};
Mocker.Mock<IQueryHandler>()
.Setup(x => x.Handle<GetConferenceByIdQuery, VideoApi.Domain.Conference>(
Expand Down Expand Up @@ -128,12 +126,10 @@ public async Task should_contain_correct_participants_when_start_hearing_has_bee

var layout = HearingLayout.OnePlus7;
var participantIds = TestConference.Participants.Where(x => x.UserRole != VideoApi.Domain.Enums.UserRole.QuickLinkParticipant && x.HearingRole != "Witness").Select(x => x.Id.ToString());
var muteGuests = true;
var request = new Contract.Requests.StartHearingRequest
{
Layout = layout,
TriggeredByHostId = TestConference.Participants.Single(x => x.UserRole == VideoApi.Domain.Enums.UserRole.Judge).Id.ToString(),
ParticipantsToForceTransfer = participantIds,
MuteGuests = true
};

Expand All @@ -147,7 +143,7 @@ public async Task should_contain_correct_participants_when_start_hearing_has_bee
var typedResult = (AcceptedResult)result;
typedResult.Should().NotBeNull();
typedResult.StatusCode.Should().Be((int)HttpStatusCode.Accepted);
VideoPlatformServiceMock.Verify(x => x.StartHearingAsync(conferenceId, request.TriggeredByHostId, participantIds, Layout.ONE_PLUS_SEVEN, muteGuests), Times.Once);
VideoPlatformServiceMock.Verify(x => x.StartHearingAsync(conferenceId, request.TriggeredByHostId, participantIds, Layout.ONE_PLUS_SEVEN, true), Times.Once);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ public void Should_return_false_when_user_role_is_QuickLinkObserver()
var result = participant.CanAutoTransferToHearingRoom();
result.Should().BeFalse();
}

[Test]
public void Should_return_false_when_user_role_is_StaffMember()
{
var participant = new ParticipantBuilder().WithUserRole(UserRole.StaffMember).Build();
var result = participant.CanAutoTransferToHearingRoom();
result.Should().BeFalse();
}

[Test]
public void Should_return_false_when_user_role_is_Witness()
Expand Down
14 changes: 5 additions & 9 deletions VideoApi/VideoApi/Controllers/ConferenceManagementController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,11 @@ public async Task<IActionResult> StartVideoHearingAsync(Guid conferenceId, Start
var hearingLayout =
HearingLayoutMapper.MapLayoutToVideoHearingLayout(
request.Layout.GetValueOrDefault(HearingLayout.Dynamic));

// ***Remove this line when video web sends the triggered by host id attribute ****ALSO, do not expose ParticipantsToForceTransfer sa this is populated here
var triggeredByHostId = request.TriggeredByHostId ?? request.ParticipantsToForceTransfer?.Single();

var conference = await _queryHandler.Handle<GetConferenceByIdQuery, Conference>(new GetConferenceByIdQuery(conferenceId));
var participants = conference.Participants.Where(x => x.State is ParticipantState.Available or ParticipantState.InConsultation
&& x.CanAutoTransferToHearingRoom()).Select(x => x.Id.ToString()).ToList();

var endpoints = conference.Endpoints
.Where(x => x.State is EndpointState.Connected or EndpointState.InConsultation)
.Select(x => x.Id.ToString()).ToList();
Expand All @@ -73,25 +70,24 @@ public async Task<IActionResult> StartVideoHearingAsync(Guid conferenceId, Start

if (_featureToggles.VodafoneIntegrationEnabled())
{
await _videoPlatformService.StartHearingAsync(conferenceId, triggeredByHostId, allIdsToTransfer, hearingLayout, request.MuteGuests ?? true);
await _videoPlatformService.StartHearingAsync(conferenceId, request.TriggeredByHostId, allIdsToTransfer, hearingLayout, request.MuteGuests ?? true);
}
else
{
await _videoPlatformService.StartHearingAsync(conferenceId, triggeredByHostId, allIdsToTransfer, hearingLayout, request.MuteGuests ?? false);
await _videoPlatformService.StartHearingAsync(conferenceId, request.TriggeredByHostId, allIdsToTransfer, hearingLayout, request.MuteGuests ?? false);
}


return Accepted();
}
catch (SupplierApiException ex)
{
_logger.LogError(ex, "Error from supplier API. Unable to start video hearing");
if (ex.StatusCode == (int)HttpStatusCode.BadRequest)
{
return BadRequest(
$"Invalid list of participants provided for {nameof(request.ParticipantsToForceTransfer)}. {request.ParticipantsToForceTransfer}");
$"Invalid list of participants provided for participantsToForceTransfer");
}

_logger.LogError(ex, "Error from supplier API. Unable to start video hearing");
return StatusCode(ex.StatusCode, ex.Response);
}
}
Expand Down

0 comments on commit bc1aee6

Please sign in to comment.