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

@ -86,6 +86,9 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.";
string message = await this.ReadBodyAsync();
const int lbpCharLimit = 512;
if (message.Length > lbpCharLimit) return this.BadRequest();
if (message.StartsWith("/setemail ") && ServerConfiguration.Instance.Mail.MailEnabled)
{
string email = message[(message.IndexOf(" ", StringComparison.Ordinal)+1)..];
@ -102,12 +105,16 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.";
return this.Ok();
}
string username = await this.database.UsernameFromGameToken(token);
string filteredText = CensorHelper.FilterMessage(message);
string username = await this.database.UsernameFromGameToken(token);
if (ServerConfiguration.Instance.LogChatMessages) Logger.Info($"{username}: \"{message}\"", LogArea.Filter);
if (ServerConfiguration.Instance.LogChatFiltering)
Logger.Info($"{username}: {message} / {filteredText}", 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);
return this.Ok(filteredText);
}