From 73ad687874d1e730c27203d9340511a27dd79de6 Mon Sep 17 00:00:00 2001 From: jvyden Date: Tue, 26 Oct 2021 22:54:06 -0400 Subject: [PATCH] Add timestamp to comments --- ProjectLighthouse/Controllers/CommentController.cs | 3 +++ ProjectLighthouse/Helpers/TimeHelper.cs | 8 ++++++++ 2 files changed, 11 insertions(+) create mode 100644 ProjectLighthouse/Helpers/TimeHelper.cs diff --git a/ProjectLighthouse/Controllers/CommentController.cs b/ProjectLighthouse/Controllers/CommentController.cs index 9f2967f1..f819a5d4 100644 --- a/ProjectLighthouse/Controllers/CommentController.cs +++ b/ProjectLighthouse/Controllers/CommentController.cs @@ -3,6 +3,7 @@ using System.IO; using System.Linq; using System.Threading.Tasks; using System.Xml.Serialization; +using LBPUnion.ProjectLighthouse.Helpers; using LBPUnion.ProjectLighthouse.Serialization; using LBPUnion.ProjectLighthouse.Types; using LBPUnion.ProjectLighthouse.Types.Profiles; @@ -50,6 +51,8 @@ namespace LBPUnion.ProjectLighthouse.Controllers { comment.PosterUserId = poster.UserId; comment.TargetUserId = target.UserId; + comment.Timestamp = TimeHelper.UnixTimeMilliseconds(); + this.database.Comments.Add(comment); await this.database.SaveChangesAsync(); return this.Ok(); diff --git a/ProjectLighthouse/Helpers/TimeHelper.cs b/ProjectLighthouse/Helpers/TimeHelper.cs new file mode 100644 index 00000000..418fff6f --- /dev/null +++ b/ProjectLighthouse/Helpers/TimeHelper.cs @@ -0,0 +1,8 @@ +using System; + +namespace LBPUnion.ProjectLighthouse.Helpers { + public static class TimeHelper { + public static long UnixTimeMilliseconds() => DateTimeOffset.Now.ToUnixTimeMilliseconds(); + public static long UnixTimeSeconds() => DateTimeOffset.Now.ToUnixTimeSeconds(); + } +} \ No newline at end of file