Reduce CaseTypes to those that can be temporary

This commit is contained in:
jvyden 2022-08-05 17:18:43 -04:00
parent e45a93dc33
commit b3d91fd470
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278
5 changed files with 8 additions and 66 deletions

View file

@ -96,8 +96,7 @@ public class AdminUserController : ControllerBase
Logger.Error($"Failed to delete planet resource {hash}\n{e}", LogArea.Admin); Logger.Error($"Failed to delete planet resource {hash}\n{e}", LogArea.Admin);
} }
} }
this.database.Cases.Add(ModerationCase.NewPlanetDeletionCase(user.UserId, targetedUser.UserId));
await this.database.SaveChangesAsync(); await this.database.SaveChangesAsync();
return this.Redirect($"/user/{targetedUser.UserId}"); return this.Redirect($"/user/{targetedUser.UserId}");

View file

@ -28,7 +28,6 @@ public class ModerationSlotController : ControllerBase
Slot? slot = await this.database.Slots.FirstOrDefaultAsync(s => s.SlotId == id); Slot? slot = await this.database.Slots.FirstOrDefaultAsync(s => s.SlotId == id);
if (slot == null) return this.NotFound(); if (slot == null) return this.NotFound();
slot.TeamPick = true; slot.TeamPick = true;
this.database.Cases.Add(ModerationCase.NewTeamPickCase(user.UserId, slot.SlotId, true));
await this.database.SaveChangesAsync(); await this.database.SaveChangesAsync();
return this.Ok(); return this.Ok();
@ -43,7 +42,6 @@ public class ModerationSlotController : ControllerBase
Slot? slot = await this.database.Slots.FirstOrDefaultAsync(s => s.SlotId == id); Slot? slot = await this.database.Slots.FirstOrDefaultAsync(s => s.SlotId == id);
if (slot == null) return this.NotFound(); if (slot == null) return this.NotFound();
slot.TeamPick = false; slot.TeamPick = false;
this.database.Cases.Add(ModerationCase.NewTeamPickCase(user.UserId, slot.SlotId, false));
await this.database.SaveChangesAsync(); await this.database.SaveChangesAsync();
return this.Ok(); return this.Ok();
@ -59,7 +57,6 @@ public class ModerationSlotController : ControllerBase
if (slot == null) return this.Ok(); if (slot == null) return this.Ok();
await this.database.RemoveSlot(slot); await this.database.RemoveSlot(slot);
this.database.Cases.Add(ModerationCase.NewLevelDeletionCase(user.UserId, slot.SlotId));
return this.Ok(); return this.Ok();
} }

View file

@ -44,4 +44,6 @@
{ {
<b>No description was provided.</b> <b>No description was provided.</b>
} }
<a href="/moderation/case/@Model.CaseId/expire"></a>
</div> </div>

View file

@ -1,6 +1,6 @@
namespace LBPUnion.ProjectLighthouse.Administration; namespace LBPUnion.ProjectLighthouse.Administration;
// Next available ID for use: 18 // Next available ID for use: 7
// PLEASE UPDATE THIS WHEN YOU ADD SOMETHING HERE! // PLEASE UPDATE THIS WHEN YOU ADD SOMETHING HERE!
// IF YOU DO NOT ADD THIS IN ORDER PROPERLY THEN THERE WILL BE DATA CORRUPTION! // IF YOU DO NOT ADD THIS IN ORDER PROPERLY THEN THERE WILL BE DATA CORRUPTION!
// THE VALUE MUST ALWAYS BE EXPLICITLY SET. // THE VALUE MUST ALWAYS BE EXPLICITLY SET.
@ -9,25 +9,11 @@ public enum CaseType
UserSilence = 0, UserSilence = 0,
UserRestriction = 1, UserRestriction = 1,
UserBan = 2, UserBan = 2,
UserDeletion = 3, UserCommentsDisabled = 3,
UserCommentsDisabled = 4,
UserDetailsEdited = 5,
UserPlanetsDeletion = 6,
LevelDeletion = 7, LevelLock = 4,
LevelLock = 8, LevelCommentsDisabled = 5,
LevelCommentsDisabled = 9, LevelDetailsEdited = 6,
LevelDetailsEdited = 10,
LevelTeamPickAdded = 16,
LevelTeamPickRemoved = 17,
CommentDeletion = 11,
ReviewDeletion = 12,
PhotoDeletion = 13,
HashModeration = 14,
IpAddressBan = 15,
} }
public static class CaseTypeExtensions public static class CaseTypeExtensions
@ -36,13 +22,10 @@ public static class CaseTypeExtensions
{ {
return type switch return type switch
{ {
CaseType.UserDeletion => false, // you cant get a user from a deleted id
CaseType.UserSilence => true, CaseType.UserSilence => true,
CaseType.UserRestriction => true, CaseType.UserRestriction => true,
CaseType.UserBan => true, CaseType.UserBan => true,
CaseType.UserCommentsDisabled => true, CaseType.UserCommentsDisabled => true,
CaseType.UserDetailsEdited => true,
CaseType.UserPlanetsDeletion => true,
_ => false, _ => false,
}; };
} }
@ -51,12 +34,9 @@ public static class CaseTypeExtensions
{ {
return type switch return type switch
{ {
CaseType.LevelDeletion => false, // you cant get a slot from a deleted id
CaseType.LevelLock => true, CaseType.LevelLock => true,
CaseType.LevelCommentsDisabled => true, CaseType.LevelCommentsDisabled => true,
CaseType.LevelDetailsEdited => true, CaseType.LevelDetailsEdited => true,
CaseType.LevelTeamPickAdded => true,
CaseType.LevelTeamPickRemoved => true,
_ => false, _ => false,
}; };
} }

View file

@ -47,24 +47,7 @@ public class ModerationCase
#region Case creators #region Case creators
#region Level #region Level
public static ModerationCase NewTeamPickCase(int caseCreator, int slotId, bool added)
=> new()
{
CaseType = added ? CaseType.LevelTeamPickAdded : CaseType.LevelTeamPickRemoved,
CaseDescription = "",
CaseCreatorId = caseCreator,
CaseCreated = DateTime.Now,
AffectedId = slotId,
};
public static ModerationCase NewLevelDeletionCase(int caseCreator, int slotId)
=> new()
{
CaseType = CaseType.LevelDeletion,
CaseDescription = "Deleted slot ID " + slotId,
CaseCreatorId = caseCreator,
CaseCreated = DateTime.Now,
};
#endregion #endregion
#region User #region User
@ -79,25 +62,6 @@ public class ModerationCase
AffectedId = userId, AffectedId = userId,
}; };
public static ModerationCase NewAccountDeletionCase(int caseCreator, int userId)
=> new()
{
CaseType = CaseType.UserDeletion,
CaseDescription = "Deleted user ID " + userId,
CaseCreatorId = caseCreator,
CaseCreated = DateTime.Now,
};
public static ModerationCase NewPlanetDeletionCase(int caseCreator, int userId)
=> new()
{
CaseType = CaseType.UserPlanetsDeletion,
CaseDescription = "",
CaseCreatorId = caseCreator,
CaseCreated = DateTime.Now,
AffectedId = userId,
};
#endregion #endregion
#endregion #endregion
} }