From 500c9dba4c4e4412b5450efc8406ee7235c1c905 Mon Sep 17 00:00:00 2001 From: esantangelo <enzo020895@gmail.com> Date: Sat, 5 Dec 2020 14:23:27 -0300 Subject: [PATCH] fix videoconference --- Tsi1.Api/Tsi1.Api/SignalR/VideoHub.cs | 20 ++++++------------- .../Interfaces/IActivityService.cs | 2 +- .../Services/ActivityService.cs | 11 +++++++++- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/Tsi1.Api/Tsi1.Api/SignalR/VideoHub.cs b/Tsi1.Api/Tsi1.Api/SignalR/VideoHub.cs index 4744e3c..8f22055 100644 --- a/Tsi1.Api/Tsi1.Api/SignalR/VideoHub.cs +++ b/Tsi1.Api/Tsi1.Api/SignalR/VideoHub.cs @@ -26,25 +26,17 @@ namespace Tsi1.Api.SignalR await Clients.Caller.SendAsync(Context.ConnectionId); } - [Authorize(Roles = UserTypes.Professor)] - public async Task CreateRoom(int activityId) + public async Task Join(int activityId, string offer) { - var result = await _activityService.ActivityValidation(activityId); + var userId = int.Parse(Context.User.Claims.FirstOrDefault(x => x.Type == "Id").Value); - if (result.HasError) + var validation = await _activityService.ActivityValidation(activityId, userId); + + if (validation.HasError) { - throw new HubException(result.Message); + throw new HubException(validation.Message); } - await Groups.AddToGroupAsync(Context.ConnectionId, activityId.ToString()); - - await Clients.Caller.SendAsync("CreateRoom", activityId); - } - - public async Task Join(int activityId, string offer) - { - var userId = int.Parse(Context.User.Claims.FirstOrDefault(x => x.Type == "Id").Value); - var result = await _activityService.AttendVirtualClass(activityId, userId); if (result.HasError) diff --git a/Tsi1.Api/Tsi1.BusinessLayer/Interfaces/IActivityService.cs b/Tsi1.Api/Tsi1.BusinessLayer/Interfaces/IActivityService.cs index 2dafbb7..43e11ae 100644 --- a/Tsi1.Api/Tsi1.BusinessLayer/Interfaces/IActivityService.cs +++ b/Tsi1.Api/Tsi1.BusinessLayer/Interfaces/IActivityService.cs @@ -15,7 +15,7 @@ namespace Tsi1.BusinessLayer.Interfaces Task<ServiceResult<int>> Modify(int activityId, ActivityModifyDto activityDto, int userId); Task<ServiceResult<int>> Delete(int activityId, int userId); - Task<ServiceResult<int>> ActivityValidation(int activityId); + Task<ServiceResult<int>> ActivityValidation(int activityId, int userId); Task<ServiceResult<GradeDto>> AddOrModifyGrade(GradeDto gradeDto, int userId); Task<ServiceResult<int>> DeleteGrade(int myUserId, int activityId, int userId); Task<ServiceResult<List<GradeDto>>> GetMyGrades(int activityId, int userId); diff --git a/Tsi1.Api/Tsi1.BusinessLayer/Services/ActivityService.cs b/Tsi1.Api/Tsi1.BusinessLayer/Services/ActivityService.cs index 706d49f..fca3edd 100644 --- a/Tsi1.Api/Tsi1.BusinessLayer/Services/ActivityService.cs +++ b/Tsi1.Api/Tsi1.BusinessLayer/Services/ActivityService.cs @@ -52,7 +52,7 @@ namespace Tsi1.BusinessLayer.Services return result; } - public async Task<ServiceResult<int>> ActivityValidation(int activityId) + public async Task<ServiceResult<int>> ActivityValidation(int activityId, int userId) { var result = new ServiceResult<int>(); @@ -62,6 +62,15 @@ namespace Tsi1.BusinessLayer.Services { result.HasError = true; result.AddMessage(string.Format(ErrorMessages.ActivityDoesNotExist, activityId)); + return result; + } + + var validation = await this.UserTypeValidation(activity.CourseId, userId); + + if (validation.HasError) + { + result.HasError = true; + result.AddMessage(validation.Message); } return result; -- GitLab