diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/CommentController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/CommentController.cs
index 78f9cc51..8c861062 100644
--- a/ProjectLighthouse.Servers.GameServer/Controllers/CommentController.cs
+++ b/ProjectLighthouse.Servers.GameServer/Controllers/CommentController.cs
@@ -1,11 +1,14 @@
#nullable enable
+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;
@@ -119,6 +122,10 @@ public class CommentController : ControllerBase
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);
+
bool success = await this.database.PostComment(token.UserId, targetId, type, filteredText);
if (success) return this.Ok();
diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/MessageController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/MessageController.cs
index 03c9877d..18b245c1 100644
--- a/ProjectLighthouse.Servers.GameServer/Controllers/MessageController.cs
+++ b/ProjectLighthouse.Servers.GameServer/Controllers/MessageController.cs
@@ -86,6 +86,9 @@ along with this program. If not, see .";
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 .";
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);
}
diff --git a/ProjectLighthouse.Servers.Website/Controllers/SlotPageController.cs b/ProjectLighthouse.Servers.Website/Controllers/SlotPageController.cs
index eee60619..66eafbc0 100644
--- a/ProjectLighthouse.Servers.Website/Controllers/SlotPageController.cs
+++ b/ProjectLighthouse.Servers.Website/Controllers/SlotPageController.cs
@@ -1,4 +1,5 @@
#nullable enable
+using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Logging;
@@ -68,16 +69,21 @@ public class SlotPageController : ControllerBase
return this.Redirect("~/slot/" + 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.Level, msg);
+ if (ServerConfiguration.Instance.LogChatFiltering && filteredText != msg)
+ Logger.Info($"Censored profane word(s) from slot comment sent by {username}: \"{msg}\" => \"{filteredText}\"",
+ LogArea.Filter);
+
+ bool success = await this.database.PostComment(token.UserId, id, CommentType.Level, filteredText);
if (success)
{
- Logger.Success($"Posted comment from {token.UserId}: \"{msg}\" on level {id}", LogArea.Comments);
+ Logger.Success($"Posted comment from {username}: \"{filteredText}\" on level {id}", LogArea.Comments);
}
else
{
- Logger.Error($"Failed to post comment from {token.UserId}: \"{msg}\" on level {id}", LogArea.Comments);
+ Logger.Error($"Failed to post comment from {username}: \"{filteredText}\" on level {id}", LogArea.Comments);
}
return this.Redirect("~/slot/" + id);
diff --git a/ProjectLighthouse.Servers.Website/Controllers/UserPageController.cs b/ProjectLighthouse.Servers.Website/Controllers/UserPageController.cs
index 71f8b409..161bb1a8 100644
--- a/ProjectLighthouse.Servers.Website/Controllers/UserPageController.cs
+++ b/ProjectLighthouse.Servers.Website/Controllers/UserPageController.cs
@@ -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);
diff --git a/ProjectLighthouse/Configuration/ServerConfiguration.cs b/ProjectLighthouse/Configuration/ServerConfiguration.cs
index b74f2bad..e2c74296 100644
--- a/ProjectLighthouse/Configuration/ServerConfiguration.cs
+++ b/ProjectLighthouse/Configuration/ServerConfiguration.cs
@@ -11,7 +11,7 @@ public class ServerConfiguration : ConfigurationBase
// This is so Lighthouse can properly identify outdated configurations and update them with newer settings accordingly.
// If you are modifying anything here, this value MUST be incremented.
// Thanks for listening~
- public override int ConfigVersion { get; set; } = 20;
+ public override int ConfigVersion { get; set; } = 21;
public override string ConfigName { get; set; } = "lighthouse.yml";
public string WebsiteListenUrl { get; set; } = "http://localhost:10060";
@@ -30,6 +30,7 @@ public class ServerConfiguration : ConfigurationBase
#endif
public bool CheckForUnsafeFiles { get; set; } = true;
public bool LogChatFiltering { get; set; } = false;
+ public bool LogChatMessages { get; set; } = false;
public AuthenticationConfiguration Authentication { get; set; } = new();
public CaptchaConfiguration Captcha { get; set; } = new();
diff --git a/ProjectLighthouse/Helpers/CensorHelper.cs b/ProjectLighthouse/Helpers/CensorHelper.cs
index ead5e981..e5ff7953 100644
--- a/ProjectLighthouse/Helpers/CensorHelper.cs
+++ b/ProjectLighthouse/Helpers/CensorHelper.cs
@@ -2,8 +2,6 @@ using System;
using System.Collections.Generic;
using System.Text;
using LBPUnion.ProjectLighthouse.Configuration;
-using LBPUnion.ProjectLighthouse.Logging;
-using LBPUnion.ProjectLighthouse.Types.Logging;
namespace LBPUnion.ProjectLighthouse.Helpers;
@@ -24,10 +22,6 @@ public static class CensorHelper
if (CensorConfiguration.Instance.UserInputFilterMode == FilterMode.None) return message;
StringBuilder stringBuilder = new(message);
- const int lbpCharLimit = 94;
-
- int profaneCount = 0;
-
foreach (string profanity in CensorConfiguration.Instance.FilteredWordList)
{
int lastFoundProfanity = 0;
@@ -47,13 +41,9 @@ public static class CensorHelper
for (int i = censorIndices.Count - 1; i >= 0; i--)
{
Censor(censorIndices[i], profanity.Length, stringBuilder);
- profaneCount += 1;
}
}
- if (ServerConfiguration.Instance.LogChatFiltering && profaneCount > 0 && message.Length <= lbpCharLimit)
- Logger.Info($"Censored {profaneCount} profane words from message \"{message}\"", LogArea.Filter);
-
return stringBuilder.ToString();
}