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";
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>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 LBPUnion.ProjectLighthouse.Localization
@using LBPUnion.ProjectLighthouse.PlayerData.Profiles
@ -16,27 +16,19 @@
{
<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)
{
<b>
<i>Comments are disabled.</i>
</b>
}
else if (Model.Comments.Count >= 50)
{
<p>There are more than 50 comments. Displaying the newest ones.</p>
}
else
{
int count = Model.Comments.Count;
<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>
<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();
StringWriter messageWriter = new();
HttpUtility.HtmlDecode(comment.getComment(), messageWriter);
Comment comment = Model.Comments[i];
DateTimeOffset timestamp = DateTimeOffset.FromUnixTimeSeconds(comment.Timestamp / 1000).ToLocalTime();
StringWriter messageWriter = new();
HttpUtility.HtmlDecode(comment.getComment(), messageWriter);
string decodedMessage = messageWriter.ToString();
string? url = Url.RouteUrl(ViewContext.RouteData.Values);
if (url == null) continue;
string decodedMessage = messageWriter.ToString();
string? url = Url.RouteUrl(ViewContext.RouteData.Values);
if (url == null) continue;
int rating = comment.ThumbsUp - comment.ThumbsDown;
int rating = comment.ThumbsUp - comment.ThumbsDown;
<div style="display: flex" id="@comment.CommentId">
@{
string style = "";
if (Model.User?.UserId == comment.PosterUserId)
{
style = "pointer-events: none";
}
<div style="display: flex" id="@comment.CommentId">
@{
string style = "";
if (Model.User?.UserId == comment.PosterUserId)
{
style = "pointer-events: none";
}
<div class="voting" style="@(style)">
<a href="@url/rateComment?commentId=@(comment.CommentId)&rating=@(comment.YourThumb == 1 ? 0 : 1)">
<i class="fitted @(comment.YourThumb == 1 ? "green" : "grey") arrow up link icon" style="display: block"></i>
</a>
<span style="text-align: center; margin: auto; @(rating < 0 ? "margin-left: -5px" : "")">@(rating)</span>
<a href="@url/rateComment?commentId=@(comment.CommentId)&rating=@(comment.YourThumb == -1 ? 0 : -1)">
<i class="fitted @(comment.YourThumb == -1 ? "red" : "grey") arrow down link icon" style="display: block"></i>
</a>
</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 class="voting" style="@(style)">
<a href="@url/rateComment?commentId=@(comment.CommentId)&rating=@(comment.YourThumb == 1 ? 0 : 1)">
<i class="fitted @(comment.YourThumb == 1 ? "green" : "grey") arrow up link icon" style="display: block"></i>
</a>
<span style="text-align: center; margin: auto; @(rating < 0 ? "margin-left: -5px" : "")">@(rating)</span>
<a href="@url/rateComment?commentId=@(comment.CommentId)&rating=@(comment.YourThumb == -1 ? 0 : -1)">
<i class="fitted @(comment.YourThumb == -1 ? "red" : "grey") arrow down link icon" style="display: block"></i>
</a>
</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>
function deleteComment(commentId){
@ -121,4 +110,4 @@
}
}
</script>
</div>
</div>

View file

@ -23,21 +23,18 @@
@if (Model.ProfileUser.IsBanned)
{
<div class="ui inverted red segment">
<h2>User is currently banned!</h2>
@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>
<span>"@Model.ProfileUser.BannedReason"</span><br>
<b>Case ID:</b>
<span>@Model.Case?.CaseId</span>
<span>"@Model.ProfileUser.BannedReason"</span>
<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>
}
else
{
<h3 style="margin-bottom:3px;"><i class="ban icon"></i> This user is currently banned.</h3>
<p>Users who violate our Community Guidelines will be moderated. Be sure to follow the rules!</p>
<p>For shame...</p>
}
</div>
}
@ -271,18 +268,8 @@
</div>
<div class="ui fitted hidden divider"></div>
}
@if (Model.ProfileUser.IsBanned && Model.Case != null)
{
<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)
@if (Model.ProfileUser.CommentsEnabled)
{
<div>
<a class="ui yellow button" href="/moderation/newCase?type=@((int)CaseType.UserDisableComments)&affectedId=@Model.ProfileUser.UserId">
@ -296,7 +283,7 @@
<div>
<a class="ui red button" href="/moderation/user/@Model.ProfileUser.UserId/wipePlanets">
<i class="trash alternate icon"></i>
<span>Wipe User Earth Decorations</span>
<span>Wipe user's earth decorations</span>
</a>
</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.Profiles;
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
using LBPUnion.ProjectLighthouse.Administration;
using LBPUnion.ProjectLighthouse.Types;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
@ -25,8 +24,6 @@ public class UserPage : BaseLayout
public List<Slot>? HeartedSlots;
public List<Slot>? QueuedSlots;
public ModerationCase? Case;
public User? ProfileUser;
public UserPage(Database database) : base(database)
{}