Fix logging for posting website comments

This commit is contained in:
Slendy 2023-02-05 21:26:50 -06:00
parent abfa53ca47
commit 6cec706792
No known key found for this signature in database
GPG key ID: 7288D68361B91428
2 changed files with 19 additions and 5 deletions

View file

@ -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);
}

View file

@ -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);
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);
}