mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-29 00:18:39 +00:00
Refactor serialization system (#702)
* Initial work for serialization refactor * Experiment with new naming conventions * Mostly implement user and slot serialization. Still needs to be fine tuned to match original implementation Many things are left in a broken state like website features/api endpoints/lbp3 categories * Fix release building * Migrate scores, reviews, and more to new serialization system. Many things are still broken but progress is steadily being made * Fix Api responses and migrate serialization for most types * Make serialization better and fix bugs Fix recursive PrepareSerialization when recursive item is set during root item's PrepareSerialization, items, should be properly indexed in order but it's only tested to 1 level of recursion * Fix review serialization * Fix user serialization producing malformed SQL query * Remove DefaultIfEmpty query * MariaDB doesn't like double nested queries * Fix LBP1 tag counter * Implement lbp3 categories and add better deserialization handling * Implement expression tree caching to speed up reflection and write new serializer tests * Remove Game column from UserEntity and rename DatabaseContextModelSnapshot.cs back to DatabaseModelSnapshot.cs * Make UserEntity username not required * Fix recursive serialization of lists and add relevant unit tests * Actually commit the migration * Fix LocationTests to use new deserialization class * Fix comments not serializing the right author username * Replace all occurrences of StatusCode with their respective ASP.NET named result instead of StatusCode(403) everything is now in the form of Forbid() * Fix SlotBase.ConvertToEntity and LocationTests * Fix compilation error * Give Location a default value in GameUserSlot and GameUser * Reimplement stubbed website functions * Convert grief reports to new serialization system * Update DatabaseModelSnapshot and bump dotnet tool version * Remove unused directives * Fix broken type reference * Fix rated comments on website * Don't include banned users in website comments * Optimize score submission * Fix slot id calculating in in-game comment posting * Move serialization interfaces to types folder and add more documentation * Allow uploading of versus scores
This commit is contained in:
parent
307b2135a3
commit
329ab66043
248 changed files with 4993 additions and 2896 deletions
|
@ -22,10 +22,10 @@ public class AdminReportController : ControllerBase
|
|||
[HttpGet("remove")]
|
||||
public async Task<IActionResult> DeleteReport([FromRoute] int id)
|
||||
{
|
||||
User? user = this.database.UserFromWebRequest(this.Request);
|
||||
if (user == null || !user.IsAdmin) return this.StatusCode(403, "");
|
||||
UserEntity? user = this.database.UserFromWebRequest(this.Request);
|
||||
if (user == null || !user.IsAdmin) return this.Forbid();
|
||||
|
||||
GriefReport? report = await this.database.Reports.FirstOrDefaultAsync(r => r.ReportId == id);
|
||||
GriefReportEntity? report = await this.database.Reports.FirstOrDefaultAsync(r => r.ReportId == id);
|
||||
if (report == null) return this.NotFound();
|
||||
|
||||
List<string> hashes = new()
|
||||
|
@ -49,10 +49,10 @@ public class AdminReportController : ControllerBase
|
|||
[HttpGet("dismiss")]
|
||||
public async Task<IActionResult> DismissReport([FromRoute] int id)
|
||||
{
|
||||
User? user = this.database.UserFromWebRequest(this.Request);
|
||||
if (user == null || !user.IsModerator) return this.StatusCode(403, "");
|
||||
UserEntity? user = this.database.UserFromWebRequest(this.Request);
|
||||
if (user == null || !user.IsModerator) return this.Forbid();
|
||||
|
||||
GriefReport? report = await this.database.Reports.FirstOrDefaultAsync(r => r.ReportId == id);
|
||||
GriefReportEntity? report = await this.database.Reports.FirstOrDefaultAsync(r => r.ReportId == id);
|
||||
if (report == null) return this.NotFound();
|
||||
|
||||
FileHelper.DeleteResource(report.JpegHash);
|
||||
|
|
|
@ -28,10 +28,10 @@ public class AdminUserController : ControllerBase
|
|||
/// </summary>
|
||||
[HttpGet("wipePlanets")]
|
||||
public async Task<IActionResult> WipePlanets([FromRoute] int id) {
|
||||
User? user = this.database.UserFromWebRequest(this.Request);
|
||||
UserEntity? user = this.database.UserFromWebRequest(this.Request);
|
||||
if (user == null || !user.IsModerator) return this.NotFound();
|
||||
|
||||
User? targetedUser = await this.database.Users.FirstOrDefaultAsync(u => u.UserId == id);
|
||||
UserEntity? targetedUser = await this.database.Users.FirstOrDefaultAsync(u => u.UserId == id);
|
||||
if (targetedUser == null) return this.NotFound();
|
||||
|
||||
string[] hashes = {
|
||||
|
@ -47,7 +47,7 @@ public class AdminUserController : ControllerBase
|
|||
if (string.IsNullOrWhiteSpace(hash)) continue;
|
||||
|
||||
// Find users with a matching hash
|
||||
List<User> users = await this.database.Users
|
||||
List<UserEntity> users = await this.database.Users
|
||||
.Where(u => u.PlanetHashLBP2 == hash ||
|
||||
u.PlanetHashLBP3 == hash ||
|
||||
u.PlanetHashLBPVita == hash)
|
||||
|
@ -57,7 +57,7 @@ public class AdminUserController : ControllerBase
|
|||
System.Diagnostics.Debug.Assert(users.Count != 0);
|
||||
|
||||
// Reset each users' hash.
|
||||
foreach (User userWithPlanet in users)
|
||||
foreach (UserEntity userWithPlanet in users)
|
||||
{
|
||||
userWithPlanet.PlanetHashLBP2 = "";
|
||||
userWithPlanet.PlanetHashLBP3 = "";
|
||||
|
@ -92,10 +92,10 @@ public class AdminUserController : ControllerBase
|
|||
[HttpPost("/admin/user/{id:int}/setPermissionLevel")]
|
||||
public async Task<IActionResult> SetUserPermissionLevel([FromRoute] int id, [FromForm] PermissionLevel role)
|
||||
{
|
||||
User? user = this.database.UserFromWebRequest(this.Request);
|
||||
UserEntity? user = this.database.UserFromWebRequest(this.Request);
|
||||
if (user == null || !user.IsAdmin) return this.NotFound();
|
||||
|
||||
User? targetedUser = await this.database.Users.FirstOrDefaultAsync(u => u.UserId == id);
|
||||
UserEntity? targetedUser = await this.database.Users.FirstOrDefaultAsync(u => u.UserId == id);
|
||||
if (targetedUser == null) return this.NotFound();
|
||||
|
||||
if (role != PermissionLevel.Banned)
|
||||
|
|
|
@ -22,7 +22,7 @@ public class AuthenticationController : ControllerBase
|
|||
[HttpGet("unlink/{platform}")]
|
||||
public async Task<IActionResult> UnlinkPlatform(string platform)
|
||||
{
|
||||
User? user = this.database.UserFromWebRequest(this.Request);
|
||||
UserEntity? user = this.database.UserFromWebRequest(this.Request);
|
||||
if (user == null) return this.Redirect("~/login");
|
||||
|
||||
Platform[] invalidTokens;
|
||||
|
@ -48,10 +48,10 @@ public class AuthenticationController : ControllerBase
|
|||
[HttpGet("approve/{id:int}")]
|
||||
public async Task<IActionResult> Approve(int id)
|
||||
{
|
||||
User? user = this.database.UserFromWebRequest(this.Request);
|
||||
UserEntity? user = this.database.UserFromWebRequest(this.Request);
|
||||
if (user == null) return this.Redirect("/login");
|
||||
|
||||
PlatformLinkAttempt? linkAttempt = await this.database.PlatformLinkAttempts
|
||||
PlatformLinkAttemptEntity? linkAttempt = await this.database.PlatformLinkAttempts
|
||||
.FirstOrDefaultAsync(l => l.PlatformLinkAttemptId == id);
|
||||
if (linkAttempt == null) return this.NotFound();
|
||||
|
||||
|
@ -76,10 +76,10 @@ public class AuthenticationController : ControllerBase
|
|||
[HttpGet("deny/{id:int}")]
|
||||
public async Task<IActionResult> Deny(int id)
|
||||
{
|
||||
User? user = this.database.UserFromWebRequest(this.Request);
|
||||
UserEntity? user = this.database.UserFromWebRequest(this.Request);
|
||||
if (user == null) return this.Redirect("/login");
|
||||
|
||||
PlatformLinkAttempt? linkAttempt = await this.database.PlatformLinkAttempts
|
||||
PlatformLinkAttemptEntity? linkAttempt = await this.database.PlatformLinkAttempts
|
||||
.FirstOrDefaultAsync(l => l.PlatformLinkAttemptId == id);
|
||||
if (linkAttempt == null) return this.NotFound();
|
||||
|
||||
|
|
|
@ -20,10 +20,10 @@ public class ModerationCaseController : ControllerBase
|
|||
[HttpGet("dismiss")]
|
||||
public async Task<IActionResult> DismissCase([FromRoute] int id)
|
||||
{
|
||||
User? user = this.database.UserFromWebRequest(this.Request);
|
||||
if (user == null || !user.IsModerator) return this.StatusCode(403, "");
|
||||
UserEntity? user = this.database.UserFromWebRequest(this.Request);
|
||||
if (user == null || !user.IsModerator) return this.Forbid();
|
||||
|
||||
ModerationCase? @case = await this.database.Cases.FirstOrDefaultAsync(c => c.CaseId == id);
|
||||
ModerationCaseEntity? @case = await this.database.Cases.FirstOrDefaultAsync(c => c.CaseId == id);
|
||||
if (@case == null) return this.NotFound();
|
||||
|
||||
@case.DismissedAt = DateTime.Now;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Level;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
||||
using LBPUnion.ProjectLighthouse.Types.Serialization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
|
@ -17,9 +18,9 @@ public class ModerationRemovalController : ControllerBase
|
|||
this.database = database;
|
||||
}
|
||||
|
||||
private async Task<IActionResult> Delete<T>(DbSet<T> dbSet, int id, string? callbackUrl, Func<User, int, Task<T?>> getHandler) where T: class
|
||||
private async Task<IActionResult> Delete<T>(DbSet<T> dbSet, int id, string? callbackUrl, Func<UserEntity, int, Task<T?>> getHandler) where T: class
|
||||
{
|
||||
User? user = this.database.UserFromWebRequest(this.Request);
|
||||
UserEntity? user = this.database.UserFromWebRequest(this.Request);
|
||||
if (user == null) return this.Redirect("~/login");
|
||||
|
||||
T? item = await getHandler(user, id);
|
||||
|
@ -34,9 +35,9 @@ public class ModerationRemovalController : ControllerBase
|
|||
[HttpGet("deleteScore/{scoreId:int}")]
|
||||
public async Task<IActionResult> DeleteScore(int scoreId, [FromQuery] string? callbackUrl)
|
||||
{
|
||||
return await this.Delete<Score>(this.database.Scores, scoreId, callbackUrl, async (user, id) =>
|
||||
return await this.Delete<ScoreEntity>(this.database.Scores, scoreId, callbackUrl, async (user, id) =>
|
||||
{
|
||||
Score? score = await this.database.Scores.Include(s => s.Slot).FirstOrDefaultAsync(s => s.ScoreId == id);
|
||||
ScoreEntity? score = await this.database.Scores.Include(s => s.Slot).FirstOrDefaultAsync(s => s.ScoreId == id);
|
||||
if (score == null) return null;
|
||||
|
||||
return user.IsModerator ? score : null;
|
||||
|
@ -46,10 +47,10 @@ public class ModerationRemovalController : ControllerBase
|
|||
[HttpGet("deleteComment/{commentId:int}")]
|
||||
public async Task<IActionResult> DeleteComment(int commentId, [FromQuery] string? callbackUrl)
|
||||
{
|
||||
User? user = this.database.UserFromWebRequest(this.Request);
|
||||
UserEntity? user = this.database.UserFromWebRequest(this.Request);
|
||||
if (user == null) return this.Redirect("~/login");
|
||||
|
||||
Comment? comment = await this.database.Comments.FirstOrDefaultAsync(c => c.CommentId == commentId);
|
||||
CommentEntity? comment = await this.database.Comments.FirstOrDefaultAsync(c => c.CommentId == commentId);
|
||||
if (comment == null) return this.Redirect("~/404");
|
||||
|
||||
if (comment.Deleted) return this.Redirect(callbackUrl ?? "~/");
|
||||
|
@ -82,10 +83,10 @@ public class ModerationRemovalController : ControllerBase
|
|||
[HttpGet("deleteReview/{reviewId:int}")]
|
||||
public async Task<IActionResult> DeleteReview(int reviewId, [FromQuery] string? callbackUrl)
|
||||
{
|
||||
User? user = this.database.UserFromWebRequest(this.Request);
|
||||
UserEntity? user = this.database.UserFromWebRequest(this.Request);
|
||||
if (user == null) return this.Redirect("~/login");
|
||||
|
||||
Review? review = await this.database.Reviews.Include(r => r.Slot).FirstOrDefaultAsync(c => c.ReviewId == reviewId);
|
||||
ReviewEntity? review = await this.database.Reviews.Include(r => r.Slot).FirstOrDefaultAsync(c => c.ReviewId == reviewId);
|
||||
if (review == null) return this.Redirect("~/404");
|
||||
|
||||
if (review.Deleted) return this.Redirect(callbackUrl ?? "~/");
|
||||
|
@ -103,9 +104,9 @@ public class ModerationRemovalController : ControllerBase
|
|||
[HttpGet("deletePhoto/{photoId:int}")]
|
||||
public async Task<IActionResult> DeletePhoto(int photoId, [FromQuery] string? callbackUrl)
|
||||
{
|
||||
return await this.Delete<Photo>(this.database.Photos, photoId, callbackUrl, async (user, id) =>
|
||||
return await this.Delete<PhotoEntity>(this.database.Photos, photoId, callbackUrl, async (user, id) =>
|
||||
{
|
||||
Photo? photo = await this.database.Photos.Include(p => p.Slot).FirstOrDefaultAsync(p => p.PhotoId == id);
|
||||
PhotoEntity? photo = await this.database.Photos.Include(p => p.Slot).FirstOrDefaultAsync(p => p.PhotoId == id);
|
||||
if (photo == null) return null;
|
||||
|
||||
if (!user.IsModerator && photo.CreatorId != user.UserId) return null;
|
||||
|
|
|
@ -23,10 +23,10 @@ public class ModerationSlotController : ControllerBase
|
|||
[HttpGet("teamPick")]
|
||||
public async Task<IActionResult> TeamPick([FromRoute] int id)
|
||||
{
|
||||
User? user = this.database.UserFromWebRequest(this.Request);
|
||||
if (user == null || !user.IsModerator) return this.StatusCode(403, "");
|
||||
UserEntity? user = this.database.UserFromWebRequest(this.Request);
|
||||
if (user == null || !user.IsModerator) return this.Forbid();
|
||||
|
||||
Slot? slot = await this.database.Slots.Include(s => s.Creator).FirstOrDefaultAsync(s => s.SlotId == id);
|
||||
SlotEntity? slot = await this.database.Slots.Include(s => s.Creator).FirstOrDefaultAsync(s => s.SlotId == id);
|
||||
if (slot == null) return this.NotFound();
|
||||
|
||||
slot.TeamPick = true;
|
||||
|
@ -42,10 +42,10 @@ public class ModerationSlotController : ControllerBase
|
|||
[HttpGet("removeTeamPick")]
|
||||
public async Task<IActionResult> RemoveTeamPick([FromRoute] int id)
|
||||
{
|
||||
User? user = this.database.UserFromWebRequest(this.Request);
|
||||
if (user == null || !user.IsModerator) return this.StatusCode(403, "");
|
||||
UserEntity? user = this.database.UserFromWebRequest(this.Request);
|
||||
if (user == null || !user.IsModerator) return this.Forbid();
|
||||
|
||||
Slot? slot = await this.database.Slots.FirstOrDefaultAsync(s => s.SlotId == id);
|
||||
SlotEntity? slot = await this.database.Slots.FirstOrDefaultAsync(s => s.SlotId == id);
|
||||
if (slot == null) return this.NotFound();
|
||||
|
||||
slot.TeamPick = false;
|
||||
|
@ -58,10 +58,10 @@ public class ModerationSlotController : ControllerBase
|
|||
[HttpGet("delete")]
|
||||
public async Task<IActionResult> DeleteLevel([FromRoute] int id)
|
||||
{
|
||||
User? user = this.database.UserFromWebRequest(this.Request);
|
||||
if (user == null || !user.IsModerator) return this.StatusCode(403, "");
|
||||
UserEntity? user = this.database.UserFromWebRequest(this.Request);
|
||||
if (user == null || !user.IsModerator) return this.Forbid();
|
||||
|
||||
Slot? slot = await this.database.Slots.FirstOrDefaultAsync(s => s.SlotId == id);
|
||||
SlotEntity? slot = await this.database.Slots.FirstOrDefaultAsync(s => s.SlotId == id);
|
||||
if (slot == null) return this.Ok();
|
||||
|
||||
await this.database.RemoveSlot(slot);
|
||||
|
|
|
@ -30,10 +30,10 @@ public class SlotPageController : ControllerBase
|
|||
[HttpGet("unpublish")]
|
||||
public async Task<IActionResult> UnpublishSlot([FromRoute] int id)
|
||||
{
|
||||
WebToken? token = this.database.WebTokenFromRequest(this.Request);
|
||||
WebTokenEntity? token = this.database.WebTokenFromRequest(this.Request);
|
||||
if (token == null) return this.Redirect("~/login");
|
||||
|
||||
Slot? targetSlot = await this.database.Slots.FirstOrDefaultAsync(s => s.SlotId == id);
|
||||
SlotEntity? targetSlot = await this.database.Slots.FirstOrDefaultAsync(s => s.SlotId == id);
|
||||
if (targetSlot == null) return this.Redirect("~/slots/0");
|
||||
|
||||
if (targetSlot.CreatorId != token.UserId) return this.Redirect("~/slot/" + id);
|
||||
|
@ -48,7 +48,7 @@ public class SlotPageController : ControllerBase
|
|||
[HttpGet("rateComment")]
|
||||
public async Task<IActionResult> RateComment([FromRoute] int id, [FromQuery] int commentId, [FromQuery] int rating)
|
||||
{
|
||||
WebToken? token = this.database.WebTokenFromRequest(this.Request);
|
||||
WebTokenEntity? token = this.database.WebTokenFromRequest(this.Request);
|
||||
if (token == null) return this.Redirect("~/login");
|
||||
|
||||
await this.database.RateComment(token.UserId, commentId, rating);
|
||||
|
@ -59,7 +59,7 @@ public class SlotPageController : ControllerBase
|
|||
[HttpPost("postComment")]
|
||||
public async Task<IActionResult> PostComment([FromRoute] int id, [FromForm] string? msg)
|
||||
{
|
||||
WebToken? token = this.database.WebTokenFromRequest(this.Request);
|
||||
WebTokenEntity? token = this.database.WebTokenFromRequest(this.Request);
|
||||
if (token == null) return this.Redirect("~/login");
|
||||
|
||||
if (msg == null)
|
||||
|
@ -90,10 +90,10 @@ public class SlotPageController : ControllerBase
|
|||
{
|
||||
if (string.IsNullOrEmpty(callbackUrl)) callbackUrl = "~/slot/" + id;
|
||||
|
||||
WebToken? token = this.database.WebTokenFromRequest(this.Request);
|
||||
WebTokenEntity? token = this.database.WebTokenFromRequest(this.Request);
|
||||
if (token == null) return this.Redirect("~/login");
|
||||
|
||||
Slot? heartedSlot = await this.database.Slots.FirstOrDefaultAsync(s => s.SlotId == id);
|
||||
SlotEntity? heartedSlot = await this.database.Slots.FirstOrDefaultAsync(s => s.SlotId == id);
|
||||
if (heartedSlot == null) return this.NotFound();
|
||||
|
||||
await this.database.HeartLevel(token.UserId, heartedSlot);
|
||||
|
@ -106,10 +106,10 @@ public class SlotPageController : ControllerBase
|
|||
{
|
||||
if (string.IsNullOrEmpty(callbackUrl)) callbackUrl = "~/slot/" + id;
|
||||
|
||||
WebToken? token = this.database.WebTokenFromRequest(this.Request);
|
||||
WebTokenEntity? token = this.database.WebTokenFromRequest(this.Request);
|
||||
if (token == null) return this.Redirect("~/login");
|
||||
|
||||
Slot? heartedSlot = await this.database.Slots.FirstOrDefaultAsync(s => s.SlotId == id);
|
||||
SlotEntity? heartedSlot = await this.database.Slots.FirstOrDefaultAsync(s => s.SlotId == id);
|
||||
if (heartedSlot == null) return this.NotFound();
|
||||
|
||||
await this.database.UnheartLevel(token.UserId, heartedSlot);
|
||||
|
@ -122,10 +122,10 @@ public class SlotPageController : ControllerBase
|
|||
{
|
||||
if (string.IsNullOrEmpty(callbackUrl)) callbackUrl = "~/slot/" + id;
|
||||
|
||||
WebToken? token = this.database.WebTokenFromRequest(this.Request);
|
||||
WebTokenEntity? token = this.database.WebTokenFromRequest(this.Request);
|
||||
if (token == null) return this.Redirect("~/login");
|
||||
|
||||
Slot? queuedSlot = await this.database.Slots.FirstOrDefaultAsync(s => s.SlotId == id);
|
||||
SlotEntity? queuedSlot = await this.database.Slots.FirstOrDefaultAsync(s => s.SlotId == id);
|
||||
if (queuedSlot == null) return this.NotFound();
|
||||
|
||||
await this.database.QueueLevel(token.UserId, queuedSlot);
|
||||
|
@ -138,10 +138,10 @@ public class SlotPageController : ControllerBase
|
|||
{
|
||||
if (string.IsNullOrEmpty(callbackUrl)) callbackUrl = "~/slot/" + id;
|
||||
|
||||
WebToken? token = this.database.WebTokenFromRequest(this.Request);
|
||||
WebTokenEntity? token = this.database.WebTokenFromRequest(this.Request);
|
||||
if (token == null) return this.Redirect("~/login");
|
||||
|
||||
Slot? queuedSlot = await this.database.Slots.FirstOrDefaultAsync(s => s.SlotId == id);
|
||||
SlotEntity? queuedSlot = await this.database.Slots.FirstOrDefaultAsync(s => s.SlotId == id);
|
||||
if (queuedSlot == null) return this.NotFound();
|
||||
|
||||
await this.database.UnqueueLevel(token.UserId, queuedSlot);
|
||||
|
|
|
@ -24,7 +24,7 @@ public class UserPageController : ControllerBase
|
|||
[HttpGet("rateComment")]
|
||||
public async Task<IActionResult> RateComment([FromRoute] int id, [FromQuery] int? commentId, [FromQuery] int? rating)
|
||||
{
|
||||
WebToken? token = this.database.WebTokenFromRequest(this.Request);
|
||||
WebTokenEntity? token = this.database.WebTokenFromRequest(this.Request);
|
||||
if (token == null) return this.Redirect("~/login");
|
||||
|
||||
await this.database.RateComment(token.UserId, commentId.GetValueOrDefault(), rating.GetValueOrDefault());
|
||||
|
@ -35,7 +35,7 @@ public class UserPageController : ControllerBase
|
|||
[HttpPost("postComment")]
|
||||
public async Task<IActionResult> PostComment([FromRoute] int id, [FromForm] string? msg)
|
||||
{
|
||||
WebToken? token = this.database.WebTokenFromRequest(this.Request);
|
||||
WebTokenEntity? token = this.database.WebTokenFromRequest(this.Request);
|
||||
if (token == null) return this.Redirect("~/login");
|
||||
|
||||
if (msg == null)
|
||||
|
@ -64,10 +64,10 @@ public class UserPageController : ControllerBase
|
|||
[HttpGet("heart")]
|
||||
public async Task<IActionResult> HeartUser([FromRoute] int id)
|
||||
{
|
||||
WebToken? token = this.database.WebTokenFromRequest(this.Request);
|
||||
WebTokenEntity? token = this.database.WebTokenFromRequest(this.Request);
|
||||
if (token == null) return this.Redirect("~/login");
|
||||
|
||||
User? heartedUser = await this.database.Users.FirstOrDefaultAsync(u => u.UserId == id);
|
||||
UserEntity? heartedUser = await this.database.Users.FirstOrDefaultAsync(u => u.UserId == id);
|
||||
if (heartedUser == null) return this.NotFound();
|
||||
|
||||
await this.database.HeartUser(token.UserId, heartedUser);
|
||||
|
@ -78,10 +78,10 @@ public class UserPageController : ControllerBase
|
|||
[HttpGet("unheart")]
|
||||
public async Task<IActionResult> UnheartUser([FromRoute] int id)
|
||||
{
|
||||
WebToken? token = this.database.WebTokenFromRequest(this.Request);
|
||||
WebTokenEntity? token = this.database.WebTokenFromRequest(this.Request);
|
||||
if (token == null) return this.Redirect("~/login");
|
||||
|
||||
User? heartedUser = await this.database.Users.FirstOrDefaultAsync(u => u.UserId == id);
|
||||
UserEntity? heartedUser = await this.database.Users.FirstOrDefaultAsync(u => u.UserId == id);
|
||||
if (heartedUser == null) return this.NotFound();
|
||||
|
||||
await this.database.UnheartUser(token.UserId, heartedUser);
|
||||
|
@ -92,10 +92,10 @@ public class UserPageController : ControllerBase
|
|||
[HttpGet("block")]
|
||||
public async Task<IActionResult> BlockUser([FromRoute] int id)
|
||||
{
|
||||
WebToken? token = this.database.WebTokenFromRequest(this.Request);
|
||||
WebTokenEntity? token = this.database.WebTokenFromRequest(this.Request);
|
||||
if (token == null) return this.Redirect("~/login");
|
||||
|
||||
User? blockedUser = await this.database.Users.FirstOrDefaultAsync(u => u.UserId == id);
|
||||
UserEntity? blockedUser = await this.database.Users.FirstOrDefaultAsync(u => u.UserId == id);
|
||||
if (blockedUser == null) return this.NotFound();
|
||||
|
||||
await this.database.BlockUser(token.UserId, blockedUser);
|
||||
|
@ -106,10 +106,10 @@ public class UserPageController : ControllerBase
|
|||
[HttpGet("unblock")]
|
||||
public async Task<IActionResult> UnblockUser([FromRoute] int id)
|
||||
{
|
||||
WebToken? token = this.database.WebTokenFromRequest(this.Request);
|
||||
WebTokenEntity? token = this.database.WebTokenFromRequest(this.Request);
|
||||
if (token == null) return this.Redirect("~/login");
|
||||
|
||||
User? blockedUser = await this.database.Users.FirstOrDefaultAsync(u => u.UserId == id);
|
||||
UserEntity? blockedUser = await this.database.Users.FirstOrDefaultAsync(u => u.UserId == id);
|
||||
if (blockedUser == null) return this.NotFound();
|
||||
|
||||
await this.database.UnblockUser(token.UserId, blockedUser);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue