Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VIH-11273 Assign the conference role when an event comes in #2366

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion VideoWeb/VideoWeb.Common/VideoWeb.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</PackageReference>
<PackageReference Include="StackExchange.Redis" Version="2.8.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.5.2" />
<PackageReference Include="VideoApi.Client" Version="3.1.20" />
<PackageReference Include="VideoApi.Client" Version="3.1.23" />
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="8.0.2" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>());
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<string>());
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<string>());
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<ArgumentNullException>(() => request.SetRoleForParticipantEvent(null));
}

[Test]
public void SetRoleForParticipantEvent_ThrowsArgumentNullException_WhenConferenceIsNull()
{
var request = new ConferenceEventRequest { ParticipantId = Guid.NewGuid().ToString() };

Assert.Throws<ArgumentNullException>(() => request.SetRoleForParticipantEvent(null));
}

protected Conference BuildConferenceForTest()
private static Conference BuildConferenceForTest()
{
var conference = new Conference
{
Expand Down
2 changes: 1 addition & 1 deletion VideoWeb/VideoWeb.UnitTests/VideoWeb.UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<PackageReference Include="NUnit" Version="4.1.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="NBuilder" Version="6.1.0" />
<PackageReference Include="VideoApi.Client" Version="3.1.20" />
<PackageReference Include="VideoApi.Client" Version="3.1.23" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\VideoWeb.Common\VideoWeb.Common.csproj" />
Expand Down
10 changes: 5 additions & 5 deletions VideoWeb/VideoWeb.UnitTests/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down Expand Up @@ -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, )"
Expand All @@ -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": {
Expand Down
2 changes: 2 additions & 0 deletions VideoWeb/VideoWeb/Controllers/VideoEventsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ public async Task<IActionResult> 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();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
Expand Down Expand Up @@ -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;
}
}
}
2 changes: 1 addition & 1 deletion VideoWeb/VideoWeb/VideoWeb.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
</PackageReference>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.1" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.6.1" />
<PackageReference Include="VideoApi.Client" Version="3.1.20" />
<PackageReference Include="VideoApi.Client" Version="3.1.23" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.5" />
<PackageReference Include="Microsoft.AspNetCore.Http.Connections.Common" Version="8.0.5" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="8.0.5" />
Expand Down
8 changes: 4 additions & 4 deletions VideoWeb/VideoWeb/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down Expand Up @@ -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": {
Expand Down