From 16d1790fb1f82409dda830977eb11bbfb03ac192 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sat, 27 Jul 2024 23:10:07 +0800 Subject: [PATCH] :sparkles: New edited at property to prevent post background update shows as edited --- pkg/internal/models/posts.go | 1 + pkg/internal/services/posts.go | 2 ++ 2 files changed, 3 insertions(+) diff --git a/pkg/internal/models/posts.go b/pkg/internal/models/posts.go index 15d28c1..bceb22d 100644 --- a/pkg/internal/models/posts.go +++ b/pkg/internal/models/posts.go @@ -28,6 +28,7 @@ type Post struct { RepostTo *Post `json:"repost_to" gorm:"foreignKey:RepostID"` Realm *Realm `json:"realm"` + EditedAt *time.Time `json:"edited_at"` PinnedAt *time.Time `json:"pinned_at"` IsDraft bool `json:"is_draft"` diff --git a/pkg/internal/services/posts.go b/pkg/internal/services/posts.go index bfd7346..6381440 100644 --- a/pkg/internal/services/posts.go +++ b/pkg/internal/services/posts.go @@ -226,6 +226,8 @@ func NewPost(user models.Account, item models.Post) (models.Post, error) { } } + item.EditedAt = lo.ToPtr(time.Now()) + if err := database.C.Save(&item).Error; err != nil { return item, err }