mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-29 00:18:39 +00:00
Add grief report webhook, add ability to link to individual reports
This commit is contained in:
parent
2dcf8dd390
commit
6ca81e0421
9 changed files with 317 additions and 212 deletions
42
ProjectLighthouse.Servers.Website/Pages/ReportPage.cshtml.cs
Normal file
42
ProjectLighthouse.Servers.Website/Pages/ReportPage.cshtml.cs
Normal file
|
@ -0,0 +1,42 @@
|
|||
using System.Text.Json;
|
||||
using LBPUnion.ProjectLighthouse.Administration.Reports;
|
||||
using LBPUnion.ProjectLighthouse.PlayerData.Profiles;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages;
|
||||
|
||||
public class ReportPage : BaseLayout
|
||||
{
|
||||
public ReportPage(Database database) : base(database)
|
||||
{}
|
||||
|
||||
public GriefReport Report;
|
||||
|
||||
public async Task<IActionResult> OnGet([FromRoute] int reportId)
|
||||
{
|
||||
User? user = this.Database.UserFromWebRequest(this.Request);
|
||||
if (user == null) return this.Redirect("~/login");
|
||||
if (!user.IsAdmin) return this.NotFound();
|
||||
|
||||
GriefReport? report = await this.Database.Reports
|
||||
.Include(r => r.ReportingPlayer)
|
||||
.FirstOrDefaultAsync(r => r.ReportId == reportId);
|
||||
if (report == null) return this.NotFound();
|
||||
|
||||
report.XmlPlayers = (ReportPlayer[])JsonSerializer.Deserialize(report.Players,
|
||||
typeof(ReportPlayer[]))!;
|
||||
|
||||
report.XmlBounds = new Marqee
|
||||
{
|
||||
Rect = (Rectangle)JsonSerializer.Deserialize(report.Bounds,
|
||||
typeof(Rectangle))!,
|
||||
};
|
||||
|
||||
this.Report = report;
|
||||
|
||||
return this.Page();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue