Add ability to hide comments on levels and profiles

This commit is contained in:
jvyden 2022-08-06 14:23:37 -04:00
parent 0b8c0cbfb4
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

@ -58,6 +58,19 @@ public class CommentController : ControllerBase
if (type == CommentType.Level && slotType == "developer") targetId = await SlotHelper.GetPlaceholderSlotId(this.database, slotId, SlotType.Developer);
if (type == CommentType.Profile)
{
User? profile = await this.database.Users.FirstOrDefaultAsync(s => s.UserId == targetId);
if (profile == null) return this.BadRequest();
if (!profile.CommentsEnabled) return this.NotFound();
}
else
{
Slot? slot = await this.database.Slots.FirstOrDefaultAsync(s => s.SlotId == targetId);
if (slot == null) return this.BadRequest();
if (!slot.CommentsEnabled) return this.NotFound();
}
List<Comment> comments = await this.database.Comments.Include
(c => c.Poster)
.Where(c => c.TargetId == targetId && c.Type == type)