diff --git a/VideoWeb/VideoWeb.Common/VideoWeb.Common.csproj b/VideoWeb/VideoWeb.Common/VideoWeb.Common.csproj index 61e5e921fb..b5fc832806 100644 --- a/VideoWeb/VideoWeb.Common/VideoWeb.Common.csproj +++ b/VideoWeb/VideoWeb.Common/VideoWeb.Common.csproj @@ -16,7 +16,7 @@ - + diff --git a/VideoWeb/VideoWeb.UnitTests/Extensions/ConferenceEventRequestExtensionsTests.cs b/VideoWeb/VideoWeb.UnitTests/Extensions/ConferenceEventRequestExtensionsTests.cs index f06ba66686..4407f7a2f6 100644 --- a/VideoWeb/VideoWeb.UnitTests/Extensions/ConferenceEventRequestExtensionsTests.cs +++ b/VideoWeb/VideoWeb.UnitTests/Extensions/ConferenceEventRequestExtensionsTests.cs @@ -49,8 +49,60 @@ public void should_map_transfer_event_to_participant_room_transfer_event() var result = request.CreateEventsForParticipantsInRoom(_testConference, civilianRoom.Id); result.All(r => r.EventType == EventType.RoomParticipantTransfer).Should().BeTrue(); } + + [Test] + public void SetRoleForParticipantEvent_SetsGuestRole_WhenIndividualParticipantIsNonScreened() + { + _testConference.Participants.ForEach(p => p.ProtectFrom = new List()); + var participant = _testConference.Participants.Find(x => x.Role == Role.Individual); + var request = new ConferenceEventRequest { ParticipantId = participant.Id.ToString() }; + + request.SetRoleForParticipantEvent(_testConference); + + request.ConferenceRole.Should().Be(ConferenceRole.Guest); + } + + [Test] + public void SetRoleForParticipantEvent_SetsHostRole_WhenHostParticipantIsNonScreened() + { + _testConference.Participants.ForEach(p => p.ProtectFrom = new List()); + var participant = _testConference.Participants.Find(x => x.Role == Role.Judge); + var request = new ConferenceEventRequest { ParticipantId = participant.Id.ToString() }; + + request.SetRoleForParticipantEvent(_testConference); + + request.ConferenceRole.Should().Be(ConferenceRole.Host); + } + + [Test] + public void SetRoleForParticipantEvent_SetsGuestRole_WhenHostParticipantIsScreened() + { + _testConference.Participants.ForEach(p => p.ProtectFrom = new List()); + var participant = _testConference.Participants.Find(x => x.Role == Role.Individual); + participant.ProtectFrom.Add(_testConference.Endpoints[0].ExternalReferenceId); + var request = new ConferenceEventRequest { ParticipantId = participant.Id.ToString() }; + + request.SetRoleForParticipantEvent(_testConference); + + request.ConferenceRole.Should().Be(ConferenceRole.Guest); + } + + [Test] + public void SetRoleForParticipantEvent_DoNothing_WhenHostParticipantIsNotProvided() + { + var request = new ConferenceEventRequest { ParticipantId = null }; + Assert.Throws(() => request.SetRoleForParticipantEvent(null)); + } + + [Test] + public void SetRoleForParticipantEvent_ThrowsArgumentNullException_WhenConferenceIsNull() + { + var request = new ConferenceEventRequest { ParticipantId = Guid.NewGuid().ToString() }; + + Assert.Throws(() => request.SetRoleForParticipantEvent(null)); + } - protected Conference BuildConferenceForTest() + private static Conference BuildConferenceForTest() { var conference = new Conference { diff --git a/VideoWeb/VideoWeb.UnitTests/VideoWeb.UnitTests.csproj b/VideoWeb/VideoWeb.UnitTests/VideoWeb.UnitTests.csproj index 93c42b9ab9..82528dc37d 100644 --- a/VideoWeb/VideoWeb.UnitTests/VideoWeb.UnitTests.csproj +++ b/VideoWeb/VideoWeb.UnitTests/VideoWeb.UnitTests.csproj @@ -21,7 +21,7 @@ - + diff --git a/VideoWeb/VideoWeb.UnitTests/packages.lock.json b/VideoWeb/VideoWeb.UnitTests/packages.lock.json index 6bdf64c471..2723946e93 100644 --- a/VideoWeb/VideoWeb.UnitTests/packages.lock.json +++ b/VideoWeb/VideoWeb.UnitTests/packages.lock.json @@ -82,9 +82,9 @@ }, "VideoApi.Client": { "type": "Direct", - "requested": "[3.1.20, )", - "resolved": "3.1.20", - "contentHash": "F4mIw+tO/b3ikAqd00kEE10j9NYtwuMdzjyImcerjIt+ajC6fOCGjTWzSz0907IiLEu8lJXPuKqm0Neap6dVCw==", + "requested": "[3.1.23, )", + "resolved": "3.1.23", + "contentHash": "nMwN0YZkBT8ZViHQ6RHYI03iJ4hNL8pDmwrC2iub/pAXqz0r2qeA/eSw/SBgr+quy+GGaTWcTeWxR+uqf5qdLg==", "dependencies": { "System.Text.Json": "8.0.5" } @@ -2124,7 +2124,7 @@ "Scrutor": "[4.2.2, )", "Swashbuckle.AspNetCore": "[6.6.1, )", "Swashbuckle.AspNetCore.Annotations": "[6.6.1, )", - "VideoApi.Client": "[3.1.20, )", + "VideoApi.Client": "[3.1.23, )", "VideoWeb.Common": "[1.0.0, )", "VideoWeb.Contract": "[1.0.0, )", "VideoWeb.EventHub": "[1.0.0, )" @@ -2142,7 +2142,7 @@ "Microsoft.Identity.Client": "[4.61.3, )", "StackExchange.Redis": "[2.8.0, )", "System.IdentityModel.Tokens.Jwt": "[7.5.2, )", - "VideoApi.Client": "[3.1.20, )" + "VideoApi.Client": "[3.1.23, )" } }, "videoweb.contract": { diff --git a/VideoWeb/VideoWeb/Controllers/VideoEventsController.cs b/VideoWeb/VideoWeb/Controllers/VideoEventsController.cs index 192654d4f3..6f8ace6a28 100644 --- a/VideoWeb/VideoWeb/Controllers/VideoEventsController.cs +++ b/VideoWeb/VideoWeb/Controllers/VideoEventsController.cs @@ -54,6 +54,8 @@ public async Task SendHearingEventAsync(ConferenceEventRequest re request.ParticipantId = null; events = request.CreateEventsForParticipantsInRoom(conference, roomId); } + // Assign conference roles based on screening rules utilised by the Supplier API + request.SetRoleForParticipantEvent(conference); var callbackEvents = events.Select(e => TransformAndMapRequest(e, conference)).ToList(); diff --git a/VideoWeb/VideoWeb/Extensions/ConferenceEventRequestExtensions.cs b/VideoWeb/VideoWeb/Extensions/ConferenceEventRequestExtensions.cs index fad2944276..5788a61e7a 100644 --- a/VideoWeb/VideoWeb/Extensions/ConferenceEventRequestExtensions.cs +++ b/VideoWeb/VideoWeb/Extensions/ConferenceEventRequestExtensions.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Linq; using Newtonsoft.Json; @@ -97,5 +98,15 @@ public static ConferenceEventRequest UpdateEventTypeForVideoApi(this ConferenceE return videoApiRequest; } + + public static void SetRoleForParticipantEvent(this ConferenceEventRequest request, Conference conference) + { + ArgumentNullException.ThrowIfNull(conference); + if (string.IsNullOrWhiteSpace(request.ParticipantId)) return; + var role = conference.GetNonScreenedParticipantsAndEndpoints().Contains(Guid.Parse(request.ParticipantId)) + ? ConferenceRole.Host + : ConferenceRole.Guest; + request.ConferenceRole = role; + } } } diff --git a/VideoWeb/VideoWeb/VideoWeb.csproj b/VideoWeb/VideoWeb/VideoWeb.csproj index fc4a3588f9..8b28fc8874 100644 --- a/VideoWeb/VideoWeb/VideoWeb.csproj +++ b/VideoWeb/VideoWeb/VideoWeb.csproj @@ -47,7 +47,7 @@ - + diff --git a/VideoWeb/VideoWeb/packages.lock.json b/VideoWeb/VideoWeb/packages.lock.json index 602ca1572a..a5576469fd 100644 --- a/VideoWeb/VideoWeb/packages.lock.json +++ b/VideoWeb/VideoWeb/packages.lock.json @@ -208,9 +208,9 @@ }, "VideoApi.Client": { "type": "Direct", - "requested": "[3.1.20, )", - "resolved": "3.1.20", - "contentHash": "F4mIw+tO/b3ikAqd00kEE10j9NYtwuMdzjyImcerjIt+ajC6fOCGjTWzSz0907IiLEu8lJXPuKqm0Neap6dVCw==", + "requested": "[3.1.23, )", + "resolved": "3.1.23", + "contentHash": "nMwN0YZkBT8ZViHQ6RHYI03iJ4hNL8pDmwrC2iub/pAXqz0r2qeA/eSw/SBgr+quy+GGaTWcTeWxR+uqf5qdLg==", "dependencies": { "System.Text.Json": "8.0.5" } @@ -1640,7 +1640,7 @@ "Microsoft.Identity.Client": "[4.61.3, )", "StackExchange.Redis": "[2.8.0, )", "System.IdentityModel.Tokens.Jwt": "[7.5.2, )", - "VideoApi.Client": "[3.1.20, )" + "VideoApi.Client": "[3.1.23, )" } }, "videoweb.contract": {