mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-29 08:28:39 +00:00
Fix missing filtering, filter inconsistencies, and filter logging (#1082)
* Fix missing filtering, filter inconsistencies, and filter logging * Remove unused import and replace removed logger * Make filter log arguments optional * Update ProjectLighthouse.Servers.GameServer/Controllers/MessageController.cs Co-authored-by: sudokoko <sudo@koko.rip> * Update ProjectLighthouse.Servers.Website/Pages/Debug/FilterTestPage.cshtml.cs Co-authored-by: sudokoko <sudo@koko.rip> * Replace filter location strings with enum * Rename enum to FilterLocation for readability --------- Co-authored-by: sudokoko <sudo@koko.rip>
This commit is contained in:
parent
a3022ff5b4
commit
f059b20489
13 changed files with 59 additions and 38 deletions
|
@ -3,12 +3,10 @@ using LBPUnion.ProjectLighthouse.Configuration;
|
|||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Extensions;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Logging;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Token;
|
||||
using LBPUnion.ProjectLighthouse.Types.Filter;
|
||||
using LBPUnion.ProjectLighthouse.Types.Levels;
|
||||
using LBPUnion.ProjectLighthouse.Types.Logging;
|
||||
using LBPUnion.ProjectLighthouse.Types.Serialization;
|
||||
using LBPUnion.ProjectLighthouse.Types.Users;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
|
@ -144,11 +142,7 @@ public class CommentController : ControllerBase
|
|||
targetId = await this.database.UserIdFromUsername(username!);
|
||||
}
|
||||
|
||||
string filteredText = CensorHelper.FilterMessage(comment.Message);
|
||||
|
||||
if (ServerConfiguration.Instance.LogChatFiltering && filteredText != comment.Message)
|
||||
Logger.Info($"Censored profane word(s) from in-game comment sent by {username}: \"{comment.Message}\" => \"{filteredText}\"",
|
||||
LogArea.Filter);
|
||||
string filteredText = CensorHelper.FilterMessage(comment.Message, FilterLocation.ChatMessage, username);
|
||||
|
||||
bool success = await this.database.PostComment(token.UserId, targetId, type, filteredText);
|
||||
if (success) return this.Ok();
|
||||
|
|
|
@ -10,6 +10,7 @@ using LBPUnion.ProjectLighthouse.Serialization;
|
|||
using LBPUnion.ProjectLighthouse.Types.Entities.Notifications;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Token;
|
||||
using LBPUnion.ProjectLighthouse.Types.Filter;
|
||||
using LBPUnion.ProjectLighthouse.Types.Logging;
|
||||
using LBPUnion.ProjectLighthouse.Types.Mail;
|
||||
using LBPUnion.ProjectLighthouse.Types.Serialization;
|
||||
|
@ -143,15 +144,10 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.";
|
|||
|
||||
string username = await this.database.UsernameFromGameToken(token);
|
||||
|
||||
string filteredText = CensorHelper.FilterMessage(message);
|
||||
|
||||
if (ServerConfiguration.Instance.LogChatMessages) Logger.Info($"{username}: \"{message}\"", LogArea.Filter);
|
||||
|
||||
if (ServerConfiguration.Instance.LogChatFiltering && filteredText != message)
|
||||
Logger.Info(
|
||||
$"Censored profane word(s) from in-game text sent by {username}: \"{message}\" => \"{filteredText}\"",
|
||||
LogArea.Filter);
|
||||
message = CensorHelper.FilterMessage(message, FilterLocation.ChatMessage, username);
|
||||
|
||||
return this.Ok(filteredText);
|
||||
return this.Ok(message);
|
||||
}
|
||||
}
|
|
@ -10,6 +10,7 @@ using LBPUnion.ProjectLighthouse.Types.Entities.Level;
|
|||
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Token;
|
||||
using LBPUnion.ProjectLighthouse.Types.Logging;
|
||||
using LBPUnion.ProjectLighthouse.Types.Filter;
|
||||
using LBPUnion.ProjectLighthouse.Types.Resources;
|
||||
using LBPUnion.ProjectLighthouse.Types.Serialization;
|
||||
using LBPUnion.ProjectLighthouse.Types.Users;
|
||||
|
@ -142,7 +143,7 @@ public class PublishController : ControllerBase
|
|||
// Yes Rider, this isn't null
|
||||
Debug.Assert(slot.Resources != null, "slot.ResourceList != null");
|
||||
|
||||
slot.Name = CensorHelper.FilterMessage(slot.Name);
|
||||
slot.Name = CensorHelper.FilterMessage(slot.Name, FilterLocation.SlotName, user.Username);
|
||||
|
||||
if (slot.Name.Length > 64)
|
||||
{
|
||||
|
@ -153,7 +154,7 @@ public class PublishController : ControllerBase
|
|||
return this.BadRequest();
|
||||
}
|
||||
|
||||
slot.Description = CensorHelper.FilterMessage(slot.Description);
|
||||
slot.Description = CensorHelper.FilterMessage(slot.Description, FilterLocation.SlotDescription, user.Username);
|
||||
|
||||
if (slot.Description.Length > 512)
|
||||
{
|
||||
|
|
|
@ -99,7 +99,9 @@ public class ReviewController : ControllerBase
|
|||
GameReview? newReview = await this.DeserializeBody<GameReview>();
|
||||
if (newReview == null) return this.BadRequest();
|
||||
|
||||
newReview.Text = CensorHelper.FilterMessage(newReview.Text);
|
||||
// Temporary fix until this can be refactored to use a UserEntity properly
|
||||
string username = await this.database.UsernameFromGameToken(token);
|
||||
newReview.Text = CensorHelper.FilterMessage(newReview.Text, FilterLocation.SlotReview, username);
|
||||
|
||||
if (newReview.Text.Length > 512) return this.BadRequest();
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ using LBPUnion.ProjectLighthouse.Configuration;
|
|||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Extensions;
|
||||
using LBPUnion.ProjectLighthouse.Files;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Logging;
|
||||
using LBPUnion.ProjectLighthouse.Servers.GameServer.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Servers.GameServer.Types.Users;
|
||||
|
@ -11,6 +12,7 @@ using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
|||
using LBPUnion.ProjectLighthouse.Types.Entities.Token;
|
||||
using LBPUnion.ProjectLighthouse.Types.Levels;
|
||||
using LBPUnion.ProjectLighthouse.Types.Logging;
|
||||
using LBPUnion.ProjectLighthouse.Types.Filter;
|
||||
using LBPUnion.ProjectLighthouse.Types.Serialization;
|
||||
using LBPUnion.ProjectLighthouse.Types.Users;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
|
@ -79,7 +81,9 @@ public class UserController : ControllerBase
|
|||
|
||||
if (update.Biography.Length > 512) return this.BadRequest();
|
||||
|
||||
user.Biography = update.Biography;
|
||||
string filteredBio = CensorHelper.FilterMessage(update.Biography, FilterLocation.UserBiography, user.Username);
|
||||
|
||||
user.Biography = filteredBio;
|
||||
}
|
||||
|
||||
if (update.Location != null) user.Location = update.Location;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue