From b62952a9421f5ea6fa72eb050800fc0fee8c1be3 Mon Sep 17 00:00:00 2001 From: Ben Stein <115497763+sei-bstein@users.noreply.github.com> Date: Thu, 15 Jun 2023 11:45:10 -0400 Subject: [PATCH] Patch to 3.9.4 (#205) * Refactor - move SimpleEntity into Gameboard.Api.Features.Common. * Don't bootstrap JobsService in integration test env * Address an issue where Gameboard was incorrectly evaluating whether a challenge has a deployed gamespace after destroy. Resolves #182. * Server-side hardening for illegal mime type upload. Removed bare repositories. Updated recommended extensions. * Add improved file upload validation. Add editor config to suppress private member warnings. * Update unit tests * Remove server-side html escaping of user input (handled client side). * Resolved an issue that prevented assignees from being display in the support ticket list. * Remove unnecessary dependency injection from the app hub. * Fix build error in ticket service --- src/Gameboard.Api/Features/Hubs/AppHub.cs | 6 ++---- .../Features/Ticket/TicketService.cs | 20 ++++++++----------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/src/Gameboard.Api/Features/Hubs/AppHub.cs b/src/Gameboard.Api/Features/Hubs/AppHub.cs index 79a7750a..43afbc31 100644 --- a/src/Gameboard.Api/Features/Hubs/AppHub.cs +++ b/src/Gameboard.Api/Features/Hubs/AppHub.cs @@ -26,7 +26,6 @@ public class AppHub : Hub, IAppHubAction private readonly IGameService _gameService; private readonly IMapper _mapper; - private readonly IMediator _mediator; public AppHub ( @@ -41,7 +40,6 @@ IPlayerStore playerStore PlayerStore = playerStore; _gameService = gameService; _mapper = mapper; - _mediator = mediator; } public override Task OnConnectedAsync() @@ -97,7 +95,7 @@ await Clients.OthersInGroup(player.TeamId).PlayerEvent( public async Task JoinGame(string gameId) { if (string.IsNullOrWhiteSpace(gameId)) - throw new ArgumentNullException(); + throw new ArgumentNullException(nameof(gameId)); var game = await _gameService .BuildQuery() @@ -125,7 +123,7 @@ public async Task JoinGame(string gameId) public async Task LeaveChannel(string channelId) { if (string.IsNullOrWhiteSpace(channelId)) - throw new ArgumentNullException(); + throw new ArgumentNullException(nameof(channelId)); await Groups.RemoveFromGroupAsync(Context.ConnectionId, channelId); } diff --git a/src/Gameboard.Api/Features/Ticket/TicketService.cs b/src/Gameboard.Api/Features/Ticket/TicketService.cs index 87691e11..06ebf825 100644 --- a/src/Gameboard.Api/Features/Ticket/TicketService.cs +++ b/src/Gameboard.Api/Features/Ticket/TicketService.cs @@ -89,7 +89,7 @@ public async Task Create(NewTicket model, string actorId, bool sudo) // upload files var uploads = await _fileUploadService.Upload(Path.Combine(Options.SupportUploadsFolder, entity.Id), model.Uploads); - if (uploads.Count() > 0) + if (uploads.Any()) { var fileNames = uploads.Select(x => x.FileName).ToArray(); entity.Attachments = Mapper.Map(fileNames); @@ -200,8 +200,7 @@ public async Task> List(TicketSearchFilter model, str if (model.Take > 0) q = q.Take(model.Take); - var tickets = Mapper.Map>(await q.ToArrayAsync()); - return Transform(tickets); + return Transform(await Mapper.ProjectTo(q).ToArrayAsync()); } public async Task AddComment(NewTicketComment model, string actorId) @@ -375,16 +374,13 @@ private void AddActivity(Data.Ticket entity, string actorId, bool statusChanged, } } - private IEnumerable Transform(IEnumerable tickets) + private IEnumerable Transform(IEnumerable tickets) { - return tickets.Select(t => Transform(t)); - } - - private TicketSummary Transform(Ticket ticket) - { - var ticketSummary = Mapper.Map(ticket); - ticketSummary.FullKey = FullKey(ticket.Key); - return ticketSummary; + return tickets.Select(t => + { + t.FullKey = FullKey(t.Key); + return t; + }).ToArray(); } private Ticket TransformInPlace(Ticket ticket)