mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-29 16:38:37 +00:00
Log filter requests
This commit is contained in:
parent
2647da0489
commit
f36106cc86
2 changed files with 15 additions and 1 deletions
|
@ -1,5 +1,7 @@
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Kettu;
|
||||||
|
using LBPUnion.ProjectLighthouse.Logging;
|
||||||
using LBPUnion.ProjectLighthouse.Types;
|
using LBPUnion.ProjectLighthouse.Types;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
@ -32,10 +34,17 @@ namespace LBPUnion.ProjectLighthouse.Controllers {
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Filters chat messages sent by a user.
|
/// Filters chat messages sent by a user.
|
||||||
|
/// The reponse sent is the text that will appear in-game.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[HttpPost("filter")]
|
[HttpPost("filter")]
|
||||||
public async Task<IActionResult> Filter() {
|
public async Task<IActionResult> 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -16,6 +16,11 @@ namespace LBPUnion.ProjectLighthouse.Logging {
|
||||||
public override string Name => "HTTP";
|
public override string Name => "HTTP";
|
||||||
public static readonly LoggerLevelHttp Instance = new();
|
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 class LoggerLevelAspNet : LoggerLevel {
|
||||||
public override string Name => "AspNet";
|
public override string Name => "AspNet";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue