Revert PRs #646 and #647

This commit is contained in:
Slendy 2023-01-26 19:45:20 -06:00
commit e061987165
No known key found for this signature in database
GPG key ID: 7288D68361B91428
5 changed files with 63 additions and 95 deletions

View file

@ -1,5 +0,0 @@
image: gitpod/workspace-dotnet
vscode:
extensions:
- muhammad-sammy.csharp

View file

@ -4,8 +4,8 @@
@{ @{
Layout = "Layouts/BaseLayout"; Layout = "Layouts/BaseLayout";
Model.Title = "Not Found"; Model.Title = "Not Found";
Model.Description = "The requested page or resource could not be found."; Model.Description = "The page was not found.";
} }
<p>@Model.Description</p> <p>@Model.Description</p>
<p>You may need to sign in to view this page.</p> <p>This may be due to a lack of permission such as not being signed in, or maybe the page just isn't there.</p>

View file

@ -1,4 +1,4 @@
@using System.Web @using System.Web
@using System.IO @using System.IO
@using LBPUnion.ProjectLighthouse.Localization @using LBPUnion.ProjectLighthouse.Localization
@using LBPUnion.ProjectLighthouse.PlayerData.Profiles @using LBPUnion.ProjectLighthouse.PlayerData.Profiles
@ -16,27 +16,19 @@
{ {
<p>There are no comments.</p> <p>There are no comments.</p>
} }
else if (Model.ProfileUser.IsBanned)
{
<p>Comments are disabled because the user is banned.</p>
}
else if (!Model.CommentsEnabled) else if (!Model.CommentsEnabled)
{ {
<b> <b>
<i>Comments are disabled.</i> <i>Comments are disabled.</i>
</b> </b>
} }
else if (Model.Comments.Count >= 50)
{
<p>There are more than 50 comments. Displaying the newest ones.</p>
}
else else
{ {
int count = Model.Comments.Count; int count = Model.Comments.Count;
<p>There @(count == 1 ? "is" : "are") @count comment@(count == 1 ? "" : "s").</p> <p>There @(count == 1 ? "is" : "are") @count comment@(count == 1 ? "" : "s").</p>
} }
@if (!Model.ProfileUser.IsBanned && Model.CommentsEnabled && Model.User != null) @if (Model.CommentsEnabled && Model.User != null)
{ {
<div class="ui divider"></div> <div class="ui divider"></div>
<form class="ui reply form" action="@Url.RouteUrl(ViewContext.RouteData.Values)/postComment" method="post"> <form class="ui reply form" action="@Url.RouteUrl(ViewContext.RouteData.Values)/postComment" method="post">
@ -51,67 +43,64 @@
} }
} }
@if (!Model.ProfileUser.IsBanned) @for(int i = 0; i < Model.Comments.Count; i++)
{ {
@for(int i = 0; i < Model.Comments.Count; i++) Comment comment = Model.Comments[i];
{ DateTimeOffset timestamp = DateTimeOffset.FromUnixTimeSeconds(comment.Timestamp / 1000).ToLocalTime();
Comment comment = Model.Comments[i]; StringWriter messageWriter = new();
DateTimeOffset timestamp = DateTimeOffset.FromUnixTimeSeconds(comment.Timestamp / 1000).ToLocalTime(); HttpUtility.HtmlDecode(comment.getComment(), messageWriter);
StringWriter messageWriter = new();
HttpUtility.HtmlDecode(comment.getComment(), messageWriter);
string decodedMessage = messageWriter.ToString(); string decodedMessage = messageWriter.ToString();
string? url = Url.RouteUrl(ViewContext.RouteData.Values); string? url = Url.RouteUrl(ViewContext.RouteData.Values);
if (url == null) continue; if (url == null) continue;
int rating = comment.ThumbsUp - comment.ThumbsDown; int rating = comment.ThumbsUp - comment.ThumbsDown;
<div style="display: flex" id="@comment.CommentId"> <div style="display: flex" id="@comment.CommentId">
@{ @{
string style = ""; string style = "";
if (Model.User?.UserId == comment.PosterUserId) if (Model.User?.UserId == comment.PosterUserId)
{ {
style = "pointer-events: none"; style = "pointer-events: none";
}
} }
<div class="voting" style="@(style)"> }
<a href="@url/rateComment?commentId=@(comment.CommentId)&rating=@(comment.YourThumb == 1 ? 0 : 1)"> <div class="voting" style="@(style)">
<i class="fitted @(comment.YourThumb == 1 ? "green" : "grey") arrow up link icon" style="display: block"></i> <a href="@url/rateComment?commentId=@(comment.CommentId)&rating=@(comment.YourThumb == 1 ? 0 : 1)">
</a> <i class="fitted @(comment.YourThumb == 1 ? "green" : "grey") arrow up link icon" style="display: block"></i>
<span style="text-align: center; margin: auto; @(rating < 0 ? "margin-left: -5px" : "")">@(rating)</span> </a>
<a href="@url/rateComment?commentId=@(comment.CommentId)&rating=@(comment.YourThumb == -1 ? 0 : -1)"> <span style="text-align: center; margin: auto; @(rating < 0 ? "margin-left: -5px" : "")">@(rating)</span>
<i class="fitted @(comment.YourThumb == -1 ? "red" : "grey") arrow down link icon" style="display: block"></i> <a href="@url/rateComment?commentId=@(comment.CommentId)&rating=@(comment.YourThumb == -1 ? 0 : -1)">
</a> <i class="fitted @(comment.YourThumb == -1 ? "red" : "grey") arrow down link icon" style="display: block"></i>
</div> </a>
<div class="comment">
<b>@await comment.Poster.ToLink(Html, ViewData, language): </b>
@if (comment.Deleted)
{
<i>
<span>@decodedMessage</span>
</i>
}
else
{
<span>@decodedMessage</span>
}
@if (((Model.User?.IsModerator ?? false) || Model.User?.UserId == comment.PosterUserId || Model.User?.UserId == pageOwnerId) && !comment.Deleted)
{
<button class="ui red icon button" style="display:inline-flex; float: right" onclick="deleteComment(@comment.CommentId)">
<i class="trash icon"></i>
</button>
}
<p>
<i>@TimeZoneInfo.ConvertTime(timestamp, timeZoneInfo).ToString("M/d/yyyy @ h:mm:ss tt")</i>
</p>
@if (i != Model.Comments.Count - 1)
{
<div class="ui divider"></div>
}
</div>
</div> </div>
}
<div class="comment">
<b>@await comment.Poster.ToLink(Html, ViewData, language): </b>
@if (comment.Deleted)
{
<i>
<span>@decodedMessage</span>
</i>
}
else
{
<span>@decodedMessage</span>
}
@if (((Model.User?.IsModerator ?? false) || Model.User?.UserId == comment.PosterUserId || Model.User?.UserId == pageOwnerId) && !comment.Deleted)
{
<button class="ui red icon button" style="display:inline-flex; float: right" onclick="deleteComment(@comment.CommentId)">
<i class="trash icon"></i>
</button>
}
<p>
<i>@TimeZoneInfo.ConvertTime(timestamp, timeZoneInfo).ToString("M/d/yyyy @ h:mm:ss tt")</i>
</p>
@if (i != Model.Comments.Count - 1)
{
<div class="ui divider"></div>
}
</div>
</div>
} }
<script> <script>
function deleteComment(commentId){ function deleteComment(commentId){

View file

@ -23,21 +23,18 @@
@if (Model.ProfileUser.IsBanned) @if (Model.ProfileUser.IsBanned)
{ {
<div class="ui inverted red segment"> <div class="ui inverted red segment">
<h2>User is currently banned!</h2>
@if (Model.User != null && Model.User.IsModerator) @if (Model.User != null && Model.User.IsModerator)
{ {
<h3 style="margin-bottom:3px;"><i class="ban icon"></i> There is an active moderation case on this account.</h3>
<b>Reason:</b> <b>Reason:</b>
<span>"@Model.ProfileUser.BannedReason"</span><br> <span>"@Model.ProfileUser.BannedReason"</span>
<b>Case ID:</b>
<span>@Model.Case?.CaseId</span>
<p> <p>
<i>Only you and other moderators may view the ban reason.</i> <i>Note: Only you and other moderators may view the ban reason.</i>
</p> </p>
} }
else else
{ {
<h3 style="margin-bottom:3px;"><i class="ban icon"></i> This user is currently banned.</h3> <p>For shame...</p>
<p>Users who violate our Community Guidelines will be moderated. Be sure to follow the rules!</p>
} }
</div> </div>
} }
@ -272,17 +269,7 @@
<div class="ui fitted hidden divider"></div> <div class="ui fitted hidden divider"></div>
} }
@if (Model.ProfileUser.IsBanned && Model.Case != null) @if (Model.ProfileUser.CommentsEnabled)
{
<div>
<a class="ui red button" href="moderation/case/@Model.Case.CaseId/dismiss">
<i class="unlock icon"></i>
<span>Unban User</span>
</a>
</div>
}
@if (Model.ProfileUser.CommentsEnabled && !Model.ProfileUser.IsBanned)
{ {
<div> <div>
<a class="ui yellow button" href="/moderation/newCase?type=@((int)CaseType.UserDisableComments)&affectedId=@Model.ProfileUser.UserId"> <a class="ui yellow button" href="/moderation/newCase?type=@((int)CaseType.UserDisableComments)&affectedId=@Model.ProfileUser.UserId">
@ -296,7 +283,7 @@
<div> <div>
<a class="ui red button" href="/moderation/user/@Model.ProfileUser.UserId/wipePlanets"> <a class="ui red button" href="/moderation/user/@Model.ProfileUser.UserId/wipePlanets">
<i class="trash alternate icon"></i> <i class="trash alternate icon"></i>
<span>Wipe User Earth Decorations</span> <span>Wipe user's earth decorations</span>
</a> </a>
</div> </div>
<div class="ui fitted hidden divider"></div> <div class="ui fitted hidden divider"></div>

View file

@ -4,7 +4,6 @@ using LBPUnion.ProjectLighthouse.Levels;
using LBPUnion.ProjectLighthouse.PlayerData; using LBPUnion.ProjectLighthouse.PlayerData;
using LBPUnion.ProjectLighthouse.PlayerData.Profiles; using LBPUnion.ProjectLighthouse.PlayerData.Profiles;
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts; using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
using LBPUnion.ProjectLighthouse.Administration;
using LBPUnion.ProjectLighthouse.Types; using LBPUnion.ProjectLighthouse.Types;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
@ -25,8 +24,6 @@ public class UserPage : BaseLayout
public List<Slot>? HeartedSlots; public List<Slot>? HeartedSlots;
public List<Slot>? QueuedSlots; public List<Slot>? QueuedSlots;
public ModerationCase? Case;
public User? ProfileUser; public User? ProfileUser;
public UserPage(Database database) : base(database) public UserPage(Database database) : base(database)
{} {}