mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-14 17:21:28 +00:00
Allow moderators to moderate story levels (#809)
* Allow moderators to view story levels on website Show comments to moderators on in-game story levels that show the levels id * Only show LH ID comment on the first page
This commit is contained in:
parent
6e92ddc89f
commit
14ebad07f3
5 changed files with 66 additions and 2 deletions
|
@ -0,0 +1,35 @@
|
|||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
||||
using LBPUnion.ProjectLighthouse.Types.Levels;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Servers.Website.Controllers.Moderator;
|
||||
|
||||
[ApiController]
|
||||
[Route("moderation")]
|
||||
public class ModerationPageController : ControllerBase
|
||||
{
|
||||
private readonly DatabaseContext database;
|
||||
|
||||
public ModerationPageController(DatabaseContext database)
|
||||
{
|
||||
this.database = database;
|
||||
}
|
||||
|
||||
[HttpPost("findStoryLevel")]
|
||||
public async Task<IActionResult> FindStorySlot([FromForm] int placeholderSlotId)
|
||||
{
|
||||
UserEntity? user = this.database.UserFromWebRequest(this.Request);
|
||||
if (user == null) return this.Redirect("~/login");
|
||||
|
||||
if (!user.IsModerator) return this.Redirect("~/");
|
||||
|
||||
int slotId = await this.database.Slots.Where(s => s.Type == SlotType.Developer)
|
||||
.Where(s => s.InternalSlotId == placeholderSlotId)
|
||||
.Select(s => s.SlotId)
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
return this.Redirect(slotId == 0 ? "~/" : $"~/slot/{slotId}");
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue