Rename enum to FilterLocation for readability

This commit is contained in:
FeTetra 2024-12-10 13:08:49 -05:00
commit bffd53cdc0
12 changed files with 14 additions and 14 deletions

View file

@ -142,7 +142,7 @@ public class CommentController : ControllerBase
targetId = await this.database.UserIdFromUsername(username!); targetId = await this.database.UserIdFromUsername(username!);
} }
string filteredText = CensorHelper.FilterMessage(comment.Message, Location.ChatMessage, username); string filteredText = CensorHelper.FilterMessage(comment.Message, FilterLocation.ChatMessage, username);
bool success = await this.database.PostComment(token.UserId, targetId, type, filteredText); bool success = await this.database.PostComment(token.UserId, targetId, type, filteredText);
if (success) return this.Ok(); if (success) return this.Ok();

View file

@ -146,7 +146,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.";
if (ServerConfiguration.Instance.LogChatMessages) Logger.Info($"{username}: \"{message}\"", LogArea.Filter); if (ServerConfiguration.Instance.LogChatMessages) Logger.Info($"{username}: \"{message}\"", LogArea.Filter);
message = CensorHelper.FilterMessage(message, Location.ChatMessage, username); message = CensorHelper.FilterMessage(message, FilterLocation.ChatMessage, username);
return this.Ok(message); return this.Ok(message);
} }

View file

@ -143,7 +143,7 @@ public class PublishController : ControllerBase
// Yes Rider, this isn't null // Yes Rider, this isn't null
Debug.Assert(slot.Resources != null, "slot.ResourceList != null"); Debug.Assert(slot.Resources != null, "slot.ResourceList != null");
slot.Name = CensorHelper.FilterMessage(slot.Name, Location.SlotName, user.Username); slot.Name = CensorHelper.FilterMessage(slot.Name, FilterLocation.SlotName, user.Username);
if (slot.Name.Length > 64) if (slot.Name.Length > 64)
{ {
@ -154,7 +154,7 @@ public class PublishController : ControllerBase
return this.BadRequest(); return this.BadRequest();
} }
slot.Description = CensorHelper.FilterMessage(slot.Description, Location.SlotDescription, user.Username); slot.Description = CensorHelper.FilterMessage(slot.Description, FilterLocation.SlotDescription, user.Username);
if (slot.Description.Length > 512) if (slot.Description.Length > 512)
{ {

View file

@ -101,7 +101,7 @@ public class ReviewController : ControllerBase
// Temporary fix until this can be refactored to use a UserEntity properly // Temporary fix until this can be refactored to use a UserEntity properly
string username = await this.database.UsernameFromGameToken(token); string username = await this.database.UsernameFromGameToken(token);
newReview.Text = CensorHelper.FilterMessage(newReview.Text, Location.SlotReview, username); newReview.Text = CensorHelper.FilterMessage(newReview.Text, FilterLocation.SlotReview, username);
if (newReview.Text.Length > 512) return this.BadRequest(); if (newReview.Text.Length > 512) return this.BadRequest();

View file

@ -81,7 +81,7 @@ public class UserController : ControllerBase
if (update.Biography.Length > 512) return this.BadRequest(); if (update.Biography.Length > 512) return this.BadRequest();
string filteredBio = CensorHelper.FilterMessage(update.Biography, Location.UserBiography, user.Username); string filteredBio = CensorHelper.FilterMessage(update.Biography, FilterLocation.UserBiography, user.Username);
user.Biography = filteredBio; user.Biography = filteredBio;
} }

View file

@ -74,7 +74,7 @@ public class SlotPageController : ControllerBase
} }
string username = await this.database.UsernameFromWebToken(token); string username = await this.database.UsernameFromWebToken(token);
string filteredText = CensorHelper.FilterMessage(msg, Location.SlotReview, username); string filteredText = CensorHelper.FilterMessage(msg, FilterLocation.SlotReview, username);
bool success = await this.database.PostComment(token.UserId, id, CommentType.Level, filteredText); bool success = await this.database.PostComment(token.UserId, id, CommentType.Level, filteredText);
if (success) if (success)

View file

@ -50,7 +50,7 @@ public class UserPageController : ControllerBase
} }
string username = await this.database.UsernameFromWebToken(token); string username = await this.database.UsernameFromWebToken(token);
string filteredText = CensorHelper.FilterMessage(msg, Location.UserComment, username); string filteredText = CensorHelper.FilterMessage(msg, FilterLocation.UserComment, username);
bool success = await this.database.PostComment(token.UserId, id, CommentType.Profile, filteredText); bool success = await this.database.PostComment(token.UserId, id, CommentType.Profile, filteredText);
if (success) if (success)

View file

@ -20,7 +20,7 @@ public class FilterTestPage : BaseLayout
public IActionResult OnGet(string? text = null) public IActionResult OnGet(string? text = null)
{ {
#if DEBUG #if DEBUG
if (text != null) this.FilteredText = CensorHelper.FilterMessage(text, Location.Test); if (text != null) this.FilteredText = CensorHelper.FilterMessage(text, FilterLocation.Test);
this.Text = text; this.Text = text;
return this.Page(); return this.Page();

View file

@ -37,14 +37,14 @@ public class SlotSettingsPage : BaseLayout
if (name != null) if (name != null)
{ {
name = CensorHelper.FilterMessage(name, Location.SlotName, this.User.Username); name = CensorHelper.FilterMessage(name, FilterLocation.SlotName, this.User.Username);
if (this.Slot.Name != name && name.Length <= 64) if (this.Slot.Name != name && name.Length <= 64)
this.Slot.Name = name; this.Slot.Name = name;
} }
if (description != null) if (description != null)
{ {
description = CensorHelper.FilterMessage(description, Location.SlotDescription, this.User.Username); description = CensorHelper.FilterMessage(description, FilterLocation.SlotDescription, this.User.Username);
if (this.Slot.Description != description && description.Length <= 512) if (this.Slot.Description != description && description.Length <= 512)
this.Slot.Description = description; this.Slot.Description = description;
} }

View file

@ -58,7 +58,7 @@ public class UserSettingsPage : BaseLayout
if (this.ProfileUser.Biography != biography && biography.Length <= 512) if (this.ProfileUser.Biography != biography && biography.Length <= 512)
{ {
string filteredBio = CensorHelper.FilterMessage(biography, Location.UserBiography, this.ProfileUser.Username); string filteredBio = CensorHelper.FilterMessage(biography, FilterLocation.UserBiography, this.ProfileUser.Username);
this.ProfileUser.Biography = filteredBio; this.ProfileUser.Biography = filteredBio;
} }

View file

@ -20,7 +20,7 @@ public static class CensorHelper
"UwU", "OwO", "uwu", "owo", "o3o", ">.>", "*pounces on you*", "*boops*", "*baps*", ":P", "x3", "O_O", "xD", ":3", ";3", "^w^", "UwU", "OwO", "uwu", "owo", "o3o", ">.>", "*pounces on you*", "*boops*", "*baps*", ":P", "x3", "O_O", "xD", ":3", ";3", "^w^",
}; };
public static string FilterMessage(string message, Location filterLocation = Location.None, string username = null) public static string FilterMessage(string message, FilterLocation filterLocation = FilterLocation.None, string username = null)
{ {
if (CensorConfiguration.Instance.UserInputFilterMode == FilterMode.None) return message; if (CensorConfiguration.Instance.UserInputFilterMode == FilterMode.None) return message;
StringBuilder stringBuilder = new(message); StringBuilder stringBuilder = new(message);

View file

@ -1,6 +1,6 @@
namespace LBPUnion.ProjectLighthouse.Types.Filter; namespace LBPUnion.ProjectLighthouse.Types.Filter;
public enum Location public enum FilterLocation
{ {
SlotName = 0, SlotName = 0,
SlotDescription = 1, SlotDescription = 1,