Add ability to hide comments on levels and profiles

This commit is contained in:
jvyden 2022-08-06 14:23:37 -04:00
commit 8fe9bd4c57
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278
12 changed files with 123 additions and 16 deletions

View file

@ -28,13 +28,16 @@ public class NewCasePage : BaseLayout
return this.Page();
}
public async Task<IActionResult> OnPost(CaseType? type, string reason, string modNotes, DateTime expires, int? affectedId)
public async Task<IActionResult> OnPost(CaseType? type, string? reason, string? modNotes, DateTime expires, int? affectedId)
{
User? user = this.Database.UserFromWebRequest(this.Request);
if (user == null || !user.IsModerator) return this.Redirect("/login");
if (type == null) return this.BadRequest();
if (affectedId == null) return this.BadRequest();
reason ??= string.Empty;
modNotes ??= string.Empty;
// this is fucking ugly
// if id is invalid then return bad request

View file

@ -223,7 +223,7 @@
</div>
</a>
@if (!(bool)Model.Slot?.Hidden)
@if (!Model.Slot!.Hidden)
{
<a href="/moderation/newCase?type=@((int)CaseType.LevelHide)&affectedId=@Model.Slot?.SlotId">
<div class="ui yellow button">
@ -232,5 +232,13 @@
</div>
</a>
}
@if (Model.Slot!.CommentsEnabled)
{
<a class="ui yellow button" href="/moderation/newCase?type=@((int)CaseType.LevelDisableComments)&affectedId=@Model.Slot?.SlotId">
<i class="lock icon"></i>
<span>Disable Comments</span>
</a>
}
</div>
}

View file

@ -17,7 +17,7 @@ public class SlotPage : BaseLayout
public List<Review> Reviews = new();
public List<Photo> Photos = new();
public readonly bool CommentsEnabled = ServerConfiguration.Instance.UserGeneratedContentLimits.LevelCommentsEnabled;
public bool CommentsEnabled;
public readonly bool ReviewsEnabled = ServerConfiguration.Instance.UserGeneratedContentLimits.LevelReviewsEnabled;
public Slot? Slot;
@ -58,6 +58,7 @@ public class SlotPage : BaseLayout
this.Slot = slot;
this.CommentsEnabled = ServerConfiguration.Instance.UserGeneratedContentLimits.LevelCommentsEnabled && this.Slot.CommentsEnabled;
if (this.CommentsEnabled)
{
this.Comments = await this.Database.Comments.Include(p => p.Poster)

View file

@ -132,6 +132,17 @@
<div class="ui fitted hidden divider"></div>
}
@if (Model.ProfileUser.CommentsEnabled)
{
<div>
<a class="ui yellow button" href="/moderation/newCase?type=@((int)CaseType.UserDisableComments)&affectedId=@Model.ProfileUser.UserId">
<i class="lock icon"></i>
<span>Disable Comments</span>
</a>
</div>
<div class="ui fitted hidden divider"></div>
}
<div>
<a class="ui red button" href="/moderation/user/@Model.ProfileUser.UserId/wipePlanets">
<i class="trash alternate icon"></i>

View file

@ -13,7 +13,7 @@ public class UserPage : BaseLayout
{
public List<Comment>? Comments;
public bool CommentsEnabled = ServerConfiguration.Instance.UserGeneratedContentLimits.ProfileCommentsEnabled;
public bool CommentsEnabled;
public bool IsProfileUserHearted;
@ -51,7 +51,9 @@ public class UserPage : BaseLayout
}
this.Photos = await this.Database.Photos.Include(p => p.Slot).OrderByDescending(p => p.Timestamp).Where(p => p.CreatorId == userId).Take(6).ToListAsync();
if (this.CommentsEnabled)
this.CommentsEnabled = ServerConfiguration.Instance.UserGeneratedContentLimits.LevelCommentsEnabled && this.ProfileUser.CommentsEnabled;
if(this.CommentsEnabled)
{
this.Comments = await this.Database.Comments.Include(p => p.Poster)
.OrderByDescending(p => p.Timestamp)