-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Feature/vih 4611 vho call event
- Loading branch information
Showing
25 changed files
with
717 additions
and
220 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
VideoAPI/Video.API/Validations/AdminConsultationRequestValidation.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System.Collections.Generic; | ||
using FluentValidation; | ||
using VideoApi.Contract.Requests; | ||
using VideoApi.Domain.Enums; | ||
|
||
namespace Video.API.Validations | ||
{ | ||
public class AdminConsultationRequestValidation : AbstractValidator<AdminConsultationRequest> | ||
{ | ||
public static readonly string NoConferenceIdErrorMessage = "ConferenceId is required"; | ||
public static readonly string NoParticipantIdErrorMessage = "ParticipantId is required"; | ||
public static readonly string NoAnswerErrorMessage = "Answer to request is required"; | ||
public static readonly string NotValidConsultationRoomMessage = "Room must be a consultation room"; | ||
|
||
public AdminConsultationRequestValidation() | ||
{ | ||
RuleFor(x => x.ConferenceId).NotEmpty().WithMessage(NoConferenceIdErrorMessage); | ||
RuleFor(x => x.ParticipantId).NotEmpty().WithMessage(NoParticipantIdErrorMessage); | ||
RuleFor(x => x.Answer).NotEqual(ConsultationAnswer.None).WithMessage(NoAnswerErrorMessage); | ||
RuleFor(x => x.ConsultationRoom).Custom((type, context) => | ||
{ | ||
var validRooms = new List<RoomType> {RoomType.ConsultationRoom1, RoomType.ConsultationRoom2}; | ||
if (!validRooms.Contains(type)) | ||
{ | ||
context.AddFailure("ConsultationRoom", NotValidConsultationRoomMessage); | ||
} | ||
}); | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
VideoAPI/VideoApi.Contract/Requests/AdminConsultationRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System; | ||
using System.ComponentModel.DataAnnotations; | ||
using VideoApi.Domain.Enums; | ||
|
||
namespace VideoApi.Contract.Requests | ||
{ | ||
/// <summary> | ||
/// Request a private consultation with another participant | ||
/// </summary> | ||
public class AdminConsultationRequest | ||
{ | ||
/// <summary> | ||
/// The conference UUID | ||
/// </summary> | ||
public Guid ConferenceId { get; set; } | ||
|
||
/// <summary> | ||
/// UUID of participant VH Officer attempted to call | ||
/// </summary> | ||
public Guid ParticipantId { get; set; } | ||
|
||
/// <summary> | ||
/// Consultation Room to use | ||
/// </summary> | ||
public RoomType ConsultationRoom { get; set; } | ||
|
||
/// <summary> | ||
/// Response to a consultation request (i.e. 'Accepted or Rejected') | ||
/// </summary> | ||
[EnumDataType(typeof(ConsultationAnswer))] | ||
public ConsultationAnswer? Answer { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ public enum EventType | |
MediaPermissionDenied, | ||
ParticipantJoining, | ||
SelfTestFailed, | ||
Suspend | ||
Suspend, | ||
VhoCall | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
VideoAPI/VideoApi.Events/Handlers/VhOfficerCallEventHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.SignalR; | ||
using VideoApi.DAL.Commands.Core; | ||
using VideoApi.DAL.Queries.Core; | ||
using VideoApi.Domain.Enums; | ||
using VideoApi.Events.Handlers.Core; | ||
using VideoApi.Events.Hub; | ||
using VideoApi.Events.Models; | ||
using VideoApi.Events.ServiceBus; | ||
|
||
namespace VideoApi.Events.Handlers | ||
{ | ||
public class VhOfficerCallEventHandler : EventHandlerBase | ||
{ | ||
public VhOfficerCallEventHandler(IQueryHandler queryHandler, ICommandHandler commandHandler, | ||
IServiceBusQueueClient serviceBusQueueClient, IHubContext<EventHub, IEventHubClient> hubContext) : base( | ||
queryHandler, commandHandler, serviceBusQueueClient, hubContext) | ||
{ | ||
} | ||
|
||
public override EventType EventType => EventType.VhoCall; | ||
|
||
protected override async Task PublishStatusAsync(CallbackEvent callbackEvent) | ||
{ | ||
var targetRoom = ValidationConsultationRoom(callbackEvent); | ||
await HubContext.Clients.Group(SourceParticipant.Username.ToLowerInvariant()) | ||
.AdminConsultationMessage(SourceConference.Id, targetRoom, | ||
SourceParticipant.Username.ToLowerInvariant()); | ||
} | ||
|
||
private RoomType ValidationConsultationRoom(CallbackEvent callbackEvent) | ||
{ | ||
if (!callbackEvent.TransferTo.HasValue || callbackEvent.TransferTo.Value != RoomType.ConsultationRoom1 | ||
&& callbackEvent.TransferTo.Value != RoomType.ConsultationRoom2) | ||
{ | ||
throw new ArgumentException("No consultation room provided"); | ||
} | ||
|
||
return callbackEvent.TransferTo.Value; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 0 additions & 105 deletions
105
VideoAPI/VideoApi.IntegrationTests/Api/Consultations.feature
This file was deleted.
Oops, something went wrong.
31 changes: 31 additions & 0 deletions
31
VideoAPI/VideoApi.IntegrationTests/Api/Consultations/AdminConsultations.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
Feature: Respond to Admin Consultations | ||
In order to manage private consultations with the VH Admin team | ||
As an API service | ||
I want to respond to private consultations with the VH Admin team | ||
|
||
Scenario: Respond to a VH Officer Consultation with an invalid request | ||
Given I have an invalid respond to admin consultation request | ||
When I send the request to the endpoint | ||
Then the response should have the status BadRequest and success status False | ||
And the error response message should also contain 'ConferenceId is required' | ||
And the error response message should also contain 'ParticipantId is required' | ||
And the error response message should also contain 'Room must be a consultation room' | ||
And the error response message should also contain 'Answer to request is required' | ||
|
||
Scenario: Respond to a VH Officer Consultation for a non-existent conference | ||
Given I have a conference | ||
Given I have a nonexistent respond to admin consultation request | ||
When I send the request to the endpoint | ||
Then the response should have the status NotFound and success status False | ||
|
||
Scenario: Respond to a VH Officer Consultation for a non-existent participant | ||
Given I have a conference | ||
Given I have a respond to admin consultation request with a non-existent participant | ||
When I send the request to the endpoint | ||
Then the response should have the status NotFound and success status False | ||
|
||
Scenario: Respond to a VH Officer Consultation successfully | ||
Given I have a conference | ||
And I have a valid respond to admin consultation request | ||
When I send the request to the endpoint | ||
Then the response should have the status NoContent and success status True |
Oops, something went wrong.