diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/Slots/PublishController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/Slots/PublishController.cs index e1b4c9b0..e29f3fe0 100644 --- a/ProjectLighthouse.Servers.GameServer/Controllers/Slots/PublishController.cs +++ b/ProjectLighthouse.Servers.GameServer/Controllers/Slots/PublishController.cs @@ -240,6 +240,12 @@ public class PublishController : ControllerBase oldSlot.MinimumPlayers = Math.Clamp(slot.MinimumPlayers, 1, 4); oldSlot.MaximumPlayers = Math.Clamp(slot.MaximumPlayers, 1, 4); + + // Check if the level has been locked by a moderator to avoid unlocking it + if (oldSlot.LockedByModerator) + { + oldSlot.InitiallyLocked = true; + } await this.database.SaveChangesAsync(); return this.Ok(SlotBase.CreateFromEntity(oldSlot, token)); diff --git a/ProjectLighthouse.Servers.Website/Pages/SlotPage.cshtml b/ProjectLighthouse.Servers.Website/Pages/SlotPage.cshtml index dbfe7235..78b0a919 100644 --- a/ProjectLighthouse.Servers.Website/Pages/SlotPage.cshtml +++ b/ProjectLighthouse.Servers.Website/Pages/SlotPage.cshtml @@ -26,12 +26,32 @@ @if (Model.Slot!.Hidden) {
-

This level is currently hidden.

-

Only you and moderators may view this level.

- - Reason: "@Model.Slot.HiddenReason" - -

For more information please contact a moderator.

+

This level is currently hidden.

+ @if (Model.User != null && Model.User.IsModerator) + { + Reason: + "@Model.Slot.HiddenReason" + } + else + { +

This level has been hidden for violating the Terms of Service. Remember to follow the rules!

+ } +
+} + +@if (Model.Slot!.LockedByModerator) +{ +
+

This level has been locked by a moderator.

+ @if (Model.User != null && Model.User.IsModerator) + { + Reason: + "@Model.Slot.LockedReason" + } + else + { +

This level has been locked for violating the Terms of Service. Remember to follow the rules!

+ }
} @@ -208,6 +228,16 @@ } + @if (!Model.Slot!.InitiallyLocked && !Model.Slot!.LockedByModerator) + { + +
+ + Forcibly Lock Level +
+
+ } + @if (Model.Slot!.CommentsEnabled) { diff --git a/ProjectLighthouse.Servers.Website/Pages/UserPage.cshtml b/ProjectLighthouse.Servers.Website/Pages/UserPage.cshtml index 99d5588d..97fb44e7 100644 --- a/ProjectLighthouse.Servers.Website/Pages/UserPage.cshtml +++ b/ProjectLighthouse.Servers.Website/Pages/UserPage.cshtml @@ -23,14 +23,11 @@ @if (Model.ProfileUser.IsBanned) {
-

This user is currently banned.

+

This user is currently banned.

@if (Model.User != null && Model.User.IsModerator) { Reason: - "@Model.ProfileUser.BannedReason"
-

- Only you and other moderators may view the ban reason. -

+ "@Model.ProfileUser.BannedReason" } else { diff --git a/ProjectLighthouse/Administration/Maintenance/RepeatingTasks/PerformCaseActionsTask.cs b/ProjectLighthouse/Administration/Maintenance/RepeatingTasks/PerformCaseActionsTask.cs index a0d9d91c..ff857ce5 100644 --- a/ProjectLighthouse/Administration/Maintenance/RepeatingTasks/PerformCaseActionsTask.cs +++ b/ProjectLighthouse/Administration/Maintenance/RepeatingTasks/PerformCaseActionsTask.cs @@ -77,6 +77,13 @@ public class PerformCaseActionsTask : IRepeatingTask slot!.CommentsEnabled = true; break; } + case CaseType.LevelLock: + { + slot!.InitiallyLocked = false; + slot.LockedByModerator = false; + slot.LockedReason = ""; + break; + } default: throw new ArgumentOutOfRangeException(); } } @@ -121,6 +128,13 @@ public class PerformCaseActionsTask : IRepeatingTask slot!.CommentsEnabled = false; break; } + case CaseType.LevelLock: + { + slot!.InitiallyLocked = true; + slot.LockedByModerator = true; + slot.LockedReason = @case.Reason; + break; + } default: throw new ArgumentOutOfRangeException(); } } diff --git a/ProjectLighthouse/Migrations/20230707125059_AddModerationLevelLocks.cs b/ProjectLighthouse/Migrations/20230707125059_AddModerationLevelLocks.cs new file mode 100644 index 00000000..b9bee259 --- /dev/null +++ b/ProjectLighthouse/Migrations/20230707125059_AddModerationLevelLocks.cs @@ -0,0 +1,41 @@ +using LBPUnion.ProjectLighthouse.Database; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace ProjectLighthouse.Migrations +{ + [DbContext(typeof(DatabaseContext))] + [Migration("20230707125059_AddModerationLevelLocks")] + public partial class AddModerationLevelLocks : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "LockedByModerator", + table: "Slots", + type: "tinyint(1)", + nullable: false, + defaultValue: false); + + migrationBuilder.AddColumn( + name: "LockedReason", + table: "Slots", + type: "longtext", + nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "LockedByModerator", + table: "Slots"); + + migrationBuilder.DropColumn( + name: "LockedReason", + table: "Slots"); + } + } +} diff --git a/ProjectLighthouse/ProjectLighthouse/Migrations/DatabaseModelSnapshot.cs b/ProjectLighthouse/ProjectLighthouse/Migrations/DatabaseModelSnapshot.cs index 2e5991fa..aebdea4f 100644 --- a/ProjectLighthouse/ProjectLighthouse/Migrations/DatabaseModelSnapshot.cs +++ b/ProjectLighthouse/ProjectLighthouse/Migrations/DatabaseModelSnapshot.cs @@ -16,7 +16,7 @@ namespace ProjectLighthouse.Migrations { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "7.0.7") + .HasAnnotation("ProductVersion", "7.0.8") .HasAnnotation("Relational:MaxIdentifierLength", 64); modelBuilder.Entity("LBPUnion.ProjectLighthouse.Types.Entities.Interaction.HeartedLevelEntity", b => @@ -406,6 +406,13 @@ namespace ProjectLighthouse.Migrations b.Property("LocationPacked") .HasColumnType("bigint unsigned"); + b.Property("LockedByModerator") + .HasColumnType("tinyint(1)"); + + b.Property("LockedReason") + .IsRequired() + .HasColumnType("longtext"); + b.Property("MaximumPlayers") .HasColumnType("int"); diff --git a/ProjectLighthouse/Types/Entities/Level/SlotEntity.cs b/ProjectLighthouse/Types/Entities/Level/SlotEntity.cs index 73e84072..94716f19 100644 --- a/ProjectLighthouse/Types/Entities/Level/SlotEntity.cs +++ b/ProjectLighthouse/Types/Entities/Level/SlotEntity.cs @@ -66,6 +66,10 @@ public class SlotEntity public UserEntity? Creator { get; set; } public bool InitiallyLocked { get; set; } + + public bool LockedByModerator { get; set; } + + public string LockedReason { get; set; } = ""; public bool SubLevel { get; set; } diff --git a/ProjectLighthouse/Types/Moderation/Cases/CaseType.cs b/ProjectLighthouse/Types/Moderation/Cases/CaseType.cs index ceb16dbb..78ee1686 100644 --- a/ProjectLighthouse/Types/Moderation/Cases/CaseType.cs +++ b/ProjectLighthouse/Types/Moderation/Cases/CaseType.cs @@ -5,7 +5,7 @@ using LBPUnion.ProjectLighthouse.Extensions; namespace LBPUnion.ProjectLighthouse.Types.Moderation.Cases; -// Next available ID for use: 6 +// Next available ID for use: 7 // PLEASE UPDATE THIS WHEN YOU ADD SOMETHING HERE! // IF YOU DO NOT ADD THIS IN ORDER PROPERLY THEN THERE WILL BE DATA CORRUPTION! // THE VALUE MUST ALWAYS BE EXPLICITLY SET. @@ -18,6 +18,7 @@ public enum CaseType LevelHide = 4, LevelDisableComments = 5, + LevelLock = 6, } public static class CaseTypeExtensions @@ -40,6 +41,7 @@ public static class CaseTypeExtensions { CaseType.LevelHide => true, CaseType.LevelDisableComments => true, + CaseType.LevelLock => true, _ => false, }; }