From 69855406f500c00988e4e7cfc1614bf370b11297 Mon Sep 17 00:00:00 2001 From: sudokoko Date: Mon, 30 Oct 2023 13:46:05 -0400 Subject: [PATCH] Miscellaneous website/moderation/notification fixes (#940) --- .../Controllers/MessageController.cs | 10 +++------- .../Pages/SlotPage.cshtml.cs | 6 +++--- .../Pages/UserPage.cshtml.cs | 3 ++- .../RepeatingTasks/DismissExpiredCasesTask.cs | 3 +++ 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/MessageController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/MessageController.cs index 22abd9de..df11efdd 100644 --- a/ProjectLighthouse.Servers.GameServer/Controllers/MessageController.cs +++ b/ProjectLighthouse.Servers.GameServer/Controllers/MessageController.cs @@ -89,16 +89,12 @@ along with this program. If not, see ."; StringBuilder builder = new(); - // ReSharper disable once ForCanBeConvertedToForeach - // Suppressing this because we need to modify the list while iterating over it. - for (int i = 0; i < notifications.Count; i++) + foreach (NotificationEntity notification in notifications) { - NotificationEntity n = notifications[i]; - builder.AppendLine(LighthouseSerializer.Serialize(this.HttpContext.RequestServices, - GameNotification.CreateFromEntity(n))); + GameNotification.CreateFromEntity(notification))); - n.IsDismissed = true; + notification.IsDismissed = true; } await this.database.SaveChangesAsync(); diff --git a/ProjectLighthouse.Servers.Website/Pages/SlotPage.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/SlotPage.cshtml.cs index bed13078..d1309d69 100644 --- a/ProjectLighthouse.Servers.Website/Pages/SlotPage.cshtml.cs +++ b/ProjectLighthouse.Servers.Website/Pages/SlotPage.cshtml.cs @@ -39,11 +39,11 @@ public class SlotPage : BaseLayout bool isAuthenticated = this.User != null; bool isOwner = slot.Creator == this.User || this.User != null && this.User.IsModerator; - + // Determine if user can view slot according to creator's privacy settings this.CanViewSlot = slot.Creator.LevelVisibility.CanAccess(isAuthenticated, isOwner); - if ((slot.Hidden || slot.SubLevel && (this.User == null && this.User != slot.Creator)) && !(this.User?.IsModerator ?? false)) + if ((slot.Hidden || slot.SubLevel && (this.User == null || this.User != slot.Creator)) && !(this.User?.IsModerator ?? false)) return this.NotFound(); string slotSlug = slot.GenerateSlug(); @@ -60,7 +60,7 @@ public class SlotPage : BaseLayout from blockedProfile in this.Database.BlockedProfiles where blockedProfile.UserId == this.User.UserId select blockedProfile.BlockedUserId).ToListAsync(); - + this.CommentsEnabled = ServerConfiguration.Instance.UserGeneratedContentLimits.LevelCommentsEnabled && this.Slot.CommentsEnabled; if (this.CommentsEnabled) { diff --git a/ProjectLighthouse.Servers.Website/Pages/UserPage.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/UserPage.cshtml.cs index 670c8801..64bfb501 100644 --- a/ProjectLighthouse.Servers.Website/Pages/UserPage.cshtml.cs +++ b/ProjectLighthouse.Servers.Website/Pages/UserPage.cshtml.cs @@ -52,7 +52,7 @@ public class UserPage : BaseLayout bool isAuthenticated = this.User != null; bool isOwner = this.ProfileUser == this.User || this.User != null && this.User.IsModerator; - + // Determine if user can view profile according to profileUser's privacy settings this.CanViewProfile = this.ProfileUser.ProfileVisibility.CanAccess(isAuthenticated, isOwner); this.CanViewSlots = this.ProfileUser.LevelVisibility.CanAccess(isAuthenticated, isOwner); @@ -68,6 +68,7 @@ public class UserPage : BaseLayout this.Slots = await this.Database.Slots.Include(p => p.Creator) .OrderByDescending(s => s.LastUpdated) .Where(p => p.CreatorId == userId) + .Where(p => p.Creator != null && (!p.SubLevel || p.Creator == this.User)) .Take(10) .ToListAsync(); diff --git a/ProjectLighthouse/Administration/Maintenance/RepeatingTasks/DismissExpiredCasesTask.cs b/ProjectLighthouse/Administration/Maintenance/RepeatingTasks/DismissExpiredCasesTask.cs index e6620662..cfb8f48d 100644 --- a/ProjectLighthouse/Administration/Maintenance/RepeatingTasks/DismissExpiredCasesTask.cs +++ b/ProjectLighthouse/Administration/Maintenance/RepeatingTasks/DismissExpiredCasesTask.cs @@ -33,6 +33,9 @@ public class DismissExpiredCasesTask : IRepeatingTask { @case.DismissedAt = DateTime.UtcNow; @case.DismisserUsername = "maintenance task"; + + @case.Processed = false; + Logger.Info($"Dismissed expired case {@case.CaseId}", LogArea.Maintenance); }