mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-05 21:01:28 +00:00
Lots of bug fixes and performance improvements (#410)
* Many bug fixes and performance enhancements * Fix warnings and speed up photos with me * Finish refactoring user serialization * Finish refactoring user serialization Use GameTokens instead of User when possible Prevent negative page sizes * Fix debug compilation * Add gzip compression to example nginx config * Remove deflate changes * Add UsernameFromWebToken Co-authored-by: Jayden <jvyden@jvyden.xyz>
This commit is contained in:
parent
8dbd0e63ff
commit
d23a264b8a
43 changed files with 625 additions and 505 deletions
|
@ -2,7 +2,7 @@
|
|||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Levels;
|
||||
using LBPUnion.ProjectLighthouse.Logging;
|
||||
using LBPUnion.ProjectLighthouse.PlayerData.Profiles;
|
||||
using LBPUnion.ProjectLighthouse.PlayerData;
|
||||
using LBPUnion.ProjectLighthouse.Types;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
@ -28,10 +28,10 @@ public class SlotPageController : ControllerBase
|
|||
[HttpGet("rateComment")]
|
||||
public async Task<IActionResult> RateComment([FromRoute] int id, [FromQuery] int commentId, [FromQuery] int rating)
|
||||
{
|
||||
User? user = this.database.UserFromWebRequest(this.Request);
|
||||
if (user == null) return this.Redirect("~/login");
|
||||
WebToken? token = this.database.WebTokenFromRequest(this.Request);
|
||||
if (token == null) return this.Redirect("~/login");
|
||||
|
||||
await this.database.RateComment(user, commentId, rating);
|
||||
await this.database.RateComment(token.UserId, commentId, rating);
|
||||
|
||||
return this.Redirect($"~/slot/{id}#{commentId}");
|
||||
}
|
||||
|
@ -39,19 +39,19 @@ public class SlotPageController : ControllerBase
|
|||
[HttpPost("postComment")]
|
||||
public async Task<IActionResult> PostComment([FromRoute] int id, [FromForm] string? msg)
|
||||
{
|
||||
User? user = this.database.UserFromWebRequest(this.Request);
|
||||
if (user == null) return this.Redirect("~/login");
|
||||
WebToken? token = this.database.WebTokenFromRequest(this.Request);
|
||||
if (token == null) return this.Redirect("~/login");
|
||||
|
||||
if (msg == null)
|
||||
{
|
||||
Logger.Error($"Refusing to post comment from {user.UserId} on user {id}, {nameof(msg)} is null", LogArea.Comments);
|
||||
Logger.Error($"Refusing to post comment from {token.UserId} on user {id}, {nameof(msg)} is null", LogArea.Comments);
|
||||
return this.Redirect("~/slot/" + id);
|
||||
}
|
||||
|
||||
msg = SanitizationHelper.SanitizeString(msg);
|
||||
|
||||
await this.database.PostComment(user, id, CommentType.Level, msg);
|
||||
Logger.Success($"Posted comment from {user.UserId}: \"{msg}\" on user {id}", LogArea.Comments);
|
||||
await this.database.PostComment(token.UserId, id, CommentType.Level, msg);
|
||||
Logger.Success($"Posted comment from {token.UserId}: \"{msg}\" on user {id}", LogArea.Comments);
|
||||
|
||||
return this.Redirect("~/slot/" + id);
|
||||
}
|
||||
|
@ -61,13 +61,13 @@ public class SlotPageController : ControllerBase
|
|||
{
|
||||
if (string.IsNullOrEmpty(callbackUrl)) callbackUrl = "~/slot/" + id;
|
||||
|
||||
User? user = this.database.UserFromWebRequest(this.Request);
|
||||
if (user == null) return this.Redirect("~/login");
|
||||
WebToken? token = this.database.WebTokenFromRequest(this.Request);
|
||||
if (token == null) return this.Redirect("~/login");
|
||||
|
||||
Slot? heartedSlot = await this.database.Slots.FirstOrDefaultAsync(s => s.SlotId == id);
|
||||
if (heartedSlot == null) return this.NotFound();
|
||||
|
||||
await this.database.HeartLevel(user, heartedSlot);
|
||||
await this.database.HeartLevel(token.UserId, heartedSlot);
|
||||
|
||||
return this.Redirect(callbackUrl);
|
||||
}
|
||||
|
@ -77,13 +77,13 @@ public class SlotPageController : ControllerBase
|
|||
{
|
||||
if (string.IsNullOrEmpty(callbackUrl)) callbackUrl = "~/slot/" + id;
|
||||
|
||||
User? user = this.database.UserFromWebRequest(this.Request);
|
||||
if (user == null) return this.Redirect("~/login");
|
||||
WebToken? token = this.database.WebTokenFromRequest(this.Request);
|
||||
if (token == null) return this.Redirect("~/login");
|
||||
|
||||
Slot? heartedSlot = await this.database.Slots.FirstOrDefaultAsync(s => s.SlotId == id);
|
||||
if (heartedSlot == null) return this.NotFound();
|
||||
|
||||
await this.database.UnheartLevel(user, heartedSlot);
|
||||
await this.database.UnheartLevel(token.UserId, heartedSlot);
|
||||
|
||||
return this.Redirect(callbackUrl);
|
||||
}
|
||||
|
@ -93,13 +93,13 @@ public class SlotPageController : ControllerBase
|
|||
{
|
||||
if (string.IsNullOrEmpty(callbackUrl)) callbackUrl = "~/slot/" + id;
|
||||
|
||||
User? user = this.database.UserFromWebRequest(this.Request);
|
||||
if (user == null) return this.Redirect("~/login");
|
||||
WebToken? token = this.database.WebTokenFromRequest(this.Request);
|
||||
if (token == null) return this.Redirect("~/login");
|
||||
|
||||
Slot? queuedSlot = await this.database.Slots.FirstOrDefaultAsync(s => s.SlotId == id);
|
||||
if (queuedSlot == null) return this.NotFound();
|
||||
|
||||
await this.database.QueueLevel(user, queuedSlot);
|
||||
await this.database.QueueLevel(token.UserId, queuedSlot);
|
||||
|
||||
return this.Redirect(callbackUrl);
|
||||
}
|
||||
|
@ -109,13 +109,13 @@ public class SlotPageController : ControllerBase
|
|||
{
|
||||
if (string.IsNullOrEmpty(callbackUrl)) callbackUrl = "~/slot/" + id;
|
||||
|
||||
User? user = this.database.UserFromWebRequest(this.Request);
|
||||
if (user == null) return this.Redirect("~/login");
|
||||
WebToken? token = this.database.WebTokenFromRequest(this.Request);
|
||||
if (token == null) return this.Redirect("~/login");
|
||||
|
||||
Slot? queuedSlot = await this.database.Slots.FirstOrDefaultAsync(s => s.SlotId == id);
|
||||
if (queuedSlot == null) return this.NotFound();
|
||||
|
||||
await this.database.UnqueueLevel(user, queuedSlot);
|
||||
await this.database.UnqueueLevel(token.UserId, queuedSlot);
|
||||
|
||||
return this.Redirect(callbackUrl);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue