From 6cec7067927d5b7461798915eaaf3640a1ae0714 Mon Sep 17 00:00:00 2001 From: Slendy Date: Sun, 5 Feb 2023 21:26:50 -0600 Subject: [PATCH] Fix logging for posting website comments --- .../Controllers/SlotPageController.cs | 13 ++++++++++--- .../Controllers/UserPageController.cs | 11 +++++++++-- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/ProjectLighthouse.Servers.Website/Controllers/SlotPageController.cs b/ProjectLighthouse.Servers.Website/Controllers/SlotPageController.cs index be7acb64..46189c2c 100644 --- a/ProjectLighthouse.Servers.Website/Controllers/SlotPageController.cs +++ b/ProjectLighthouse.Servers.Website/Controllers/SlotPageController.cs @@ -65,7 +65,7 @@ public class SlotPageController : ControllerBase if (msg == null) { - Logger.Error($"Refusing to post comment from {token.UserId} on user {id}, {nameof(msg)} is null", LogArea.Comments); + Logger.Error($"Refusing to post comment from {token.UserId} on level {id}, {nameof(msg)} is null", LogArea.Comments); return this.Redirect("~/slot/" + id); } @@ -73,8 +73,15 @@ public class SlotPageController : ControllerBase msg = SanitizationHelper.SanitizeString(msg); msg = CensorHelper.FilterMessage(msg); - await this.database.PostComment(token.UserId, id, CommentType.Level, msg); - Logger.Success($"Posted comment from {token.UserId}: \"{msg}\" on user {id}", LogArea.Comments); + bool success = await this.database.PostComment(token.UserId, id, CommentType.Level, msg); + if (success) + { + Logger.Success($"Posted comment from {token.UserId}: \"{msg}\" on level {id}", LogArea.Comments); + } + else + { + Logger.Error($"Failed to post comment from {token.UserId}: \"{msg}\" 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 b05bc07b..e7e1cfb1 100644 --- a/ProjectLighthouse.Servers.Website/Controllers/UserPageController.cs +++ b/ProjectLighthouse.Servers.Website/Controllers/UserPageController.cs @@ -47,8 +47,15 @@ public class UserPageController : ControllerBase msg = SanitizationHelper.SanitizeString(msg); msg = CensorHelper.FilterMessage(msg); - await this.database.PostComment(token.UserId, id, CommentType.Profile, msg); - Logger.Success($"Posted comment from {token.UserId}: \"{msg}\" on user {id}", LogArea.Comments); + bool success = await this.database.PostComment(token.UserId, id, CommentType.Profile, msg); + if (success) + { + Logger.Success($"Posted comment from {token.UserId}: \"{msg}\" on user {id}", LogArea.Comments); + } + else + { + Logger.Error($"Failed to post comment from {token.UserId}: \"{msg}\" on user {id}", LogArea.Comments); + } return this.Redirect("~/user/" + id); }