diff --git a/ProjectLighthouse.Tests.WebsiteTests/ProjectLighthouse.Tests.WebsiteTests.csproj b/ProjectLighthouse.Tests.WebsiteTests/ProjectLighthouse.Tests.WebsiteTests.csproj index c4d6229e..ca3bb5f4 100644 --- a/ProjectLighthouse.Tests.WebsiteTests/ProjectLighthouse.Tests.WebsiteTests.csproj +++ b/ProjectLighthouse.Tests.WebsiteTests/ProjectLighthouse.Tests.WebsiteTests.csproj @@ -16,7 +16,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/ProjectLighthouse/Controllers/Website/Admin/AdminReportController.cs b/ProjectLighthouse/Controllers/Website/Admin/AdminReportController.cs index bc41b069..3568d169 100644 --- a/ProjectLighthouse/Controllers/Website/Admin/AdminReportController.cs +++ b/ProjectLighthouse/Controllers/Website/Admin/AdminReportController.cs @@ -52,4 +52,29 @@ public class AdminReportController : ControllerBase return this.Redirect("~/admin/reports/0"); } + + [HttpGet("dismiss")] + public async Task DismissReport([FromRoute] int id) + { + User? user = this.database.UserFromWebRequest(this.Request); + if (user == null || !user.IsAdmin) return this.StatusCode(403, ""); + + GriefReport? report = await this.database.Reports.FirstOrDefaultAsync(r => r.ReportId == id); + if (report == null) return this.NotFound(); + + if (System.IO.File.Exists(Path.Combine("png", $"{report.JpegHash}.png"))) + { + System.IO.File.Delete(Path.Combine("png", $"{report.JpegHash}.png")); + } + if (System.IO.File.Exists(Path.Combine("r", report.JpegHash))) + { + System.IO.File.Delete(Path.Combine("r", report.JpegHash)); + } + + this.database.Reports.Remove(report); + + await this.database.SaveChangesAsync(); + + return this.Redirect("~/admin/reports/0"); + } } \ No newline at end of file diff --git a/ProjectLighthouse/Pages/ReportsPage.cshtml b/ProjectLighthouse/Pages/ReportsPage.cshtml index 116debe3..bd8ea8f4 100644 --- a/ProjectLighthouse/Pages/ReportsPage.cshtml +++ b/ProjectLighthouse/Pages/ReportsPage.cshtml @@ -15,7 +15,9 @@ +
+ + @foreach (GriefReport report in Model.Reports) {
@@ -30,9 +33,16 @@ - Grief report picture + Grief report picture
-

Report submitted by @report.ReportingPlayer.Username

+

+ + Report submitted by + + @report.ReportingPlayer.Username + + +

Report contains @report.XmlPlayers.Length @(report.XmlPlayers.Length == 1 ? "player" : "players") @foreach (ReportPlayer player in report.XmlPlayers) { @@ -40,14 +50,32 @@ @player.Name } -
Report time: @(DateTimeOffset.FromUnixTimeMilliseconds(report.Timestamp).ToString("R"))
-
Report reason: @report.Type
-
Level ID: @report.LevelId
-
Level type: @report.LevelType
-
Level owner: @report.LevelOwner
-
Hover to see reported region
- - + +
+
+ Report time: @(DateTimeOffset.FromUnixTimeMilliseconds(report.Timestamp).ToString("R")) +
+
+ Report reason: @report.Type +
+
+ Level ID: @report.LevelId +
+
+ Level type: @report.LevelType +
+
+ Level owner: @report.LevelOwner +
+
+ +
+ + Dismiss + + + + Remove all related assets } +