diff --git a/ProjectLighthouse/Controllers/MessageController.cs b/ProjectLighthouse/Controllers/MessageController.cs index ff6b8112..b060c88f 100644 --- a/ProjectLighthouse/Controllers/MessageController.cs +++ b/ProjectLighthouse/Controllers/MessageController.cs @@ -1,5 +1,7 @@ using System.IO; using System.Threading.Tasks; +using Kettu; +using LBPUnion.ProjectLighthouse.Logging; using LBPUnion.ProjectLighthouse.Types; using Microsoft.AspNetCore.Mvc; @@ -32,10 +34,17 @@ namespace LBPUnion.ProjectLighthouse.Controllers { } /// /// Filters chat messages sent by a user. + /// The reponse sent is the text that will appear in-game. /// [HttpPost("filter")] public async Task Filter() { - return this.Ok(await new StreamReader(this.Request.Body).ReadToEndAsync()); + User user = await this.database.UserFromRequest(this.Request); + if(user == null) return this.StatusCode(403, ""); + + string loggedText = await new StreamReader(this.Request.Body).ReadToEndAsync(); + + Logger.Log($"{user.Username}: {loggedText}", LoggerLevelFilter.Instance); + return this.Ok(loggedText); } } } \ No newline at end of file diff --git a/ProjectLighthouse/Logging/LoggerLevels.cs b/ProjectLighthouse/Logging/LoggerLevels.cs index 72831dd3..7ddb690c 100644 --- a/ProjectLighthouse/Logging/LoggerLevels.cs +++ b/ProjectLighthouse/Logging/LoggerLevels.cs @@ -16,6 +16,11 @@ namespace LBPUnion.ProjectLighthouse.Logging { public override string Name => "HTTP"; public static readonly LoggerLevelHttp Instance = new(); } + + public class LoggerLevelFilter : LoggerLevel { + public override string Name => "Filter"; + public static readonly LoggerLevelFilter Instance = new(); + } public class LoggerLevelAspNet : LoggerLevel { public override string Name => "AspNet";