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:
Josh 2023-06-26 18:52:15 -05:00 committed by GitHub
parent 6e92ddc89f
commit 14ebad07f3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 66 additions and 2 deletions

View file

@ -50,8 +50,13 @@ public class CommentController : ControllerBase
{
GameTokenEntity token = this.GetToken();
UserEntity? user = await this.database.UserFromGameToken(token);
if (user == null) return this.Unauthorized();
if ((slotId == 0 || SlotHelper.IsTypeInvalid(slotType)) == (username == null)) return this.BadRequest();
int originalSlotId = slotId;
if (slotType == "developer") slotId = await SlotHelper.GetPlaceholderSlotId(this.database, slotId, SlotType.Developer);
int targetId;
@ -89,6 +94,17 @@ public class CommentController : ControllerBase
.ApplyPagination(pageData)
.ToListAsync()).ToSerializableList(c => GameComment.CreateFromEntity(c, token.UserId));
if (type == CommentType.Level && slotType == "developer" && user.IsModerator && pageData.PageStart == 1)
{
comments.Insert(0, new GameComment
{
CommentId = 0,
Timestamp = 0,
AuthorUsername = "LH",
Message = $"Slot ID: {targetId}, Story level ID: {originalSlotId}",
});
}
return this.Ok(new CommentListResponse(comments));
}