Censor filter logging improvements (#804)

* Move censor/msg logging to MessageController & separate LogAreas/config

* Correct LBP character limit to 95

* Log filtered comments as well

* Remove two unnecessary variables from CensorHelper

* Add censor logging to SlotPage/UserPage controllers and improve logging slightly

* Remove accidental dollar sign in log

* Grammatical nitpick in CommentController.cs

* Contextual nitpick in MessageController.cs

* Add escaped quotes in CommentController log to match the rest

* Increase limit to account for descriptions, magic mouth, etc.

* Consolidate LogChatMessages logging into Filter log area to prevent confusion

* Apply code review suggestions
This commit is contained in:
koko 2023-06-18 19:39:39 -04:00 committed by GitHub
parent 8b1121a4f8
commit e5cfeb1e39
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 39 additions and 22 deletions

View file

@ -1,4 +1,5 @@
#nullable enable
using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Logging;
@ -44,16 +45,21 @@ public class UserPageController : ControllerBase
return this.Redirect("~/user/" + id);
}
msg = CensorHelper.FilterMessage(msg);
string username = await this.database.UsernameFromWebToken(token);
string filteredText = CensorHelper.FilterMessage(msg);
bool success = await this.database.PostComment(token.UserId, id, CommentType.Profile, msg);
if (ServerConfiguration.Instance.LogChatFiltering && filteredText != msg)
Logger.Info($"Censored profane word(s) from user comment sent by {username}: \"{msg}\" => \"{filteredText}\"",
LogArea.Filter);
bool success = await this.database.PostComment(token.UserId, id, CommentType.Profile, filteredText);
if (success)
{
Logger.Success($"Posted comment from {token.UserId}: \"{msg}\" on user {id}", LogArea.Comments);
Logger.Success($"Posted comment from {username}: \"{filteredText}\" on user {id}", LogArea.Comments);
}
else
{
Logger.Error($"Failed to post comment from {token.UserId}: \"{msg}\" on user {id}", LogArea.Comments);
Logger.Error($"Failed to post comment from {username}: \"{filteredText}\" on user {id}", LogArea.Comments);
}
return this.Redirect("~/user/" + id);