From 148bc121cc7b6befbf67d6ec069d3accaa3078e6 Mon Sep 17 00:00:00 2001 From: kim Date: Thu, 5 Dec 2024 13:08:54 +0000 Subject: [PATCH] slight formatting tweak --- internal/federation/dereferencing/status.go | 13 ++++++++++--- internal/federation/dereferencing/util.go | 21 --------------------- 2 files changed, 10 insertions(+), 24 deletions(-) diff --git a/internal/federation/dereferencing/status.go b/internal/federation/dereferencing/status.go index ac5e87402..e04096a83 100644 --- a/internal/federation/dereferencing/status.go +++ b/internal/federation/dereferencing/status.go @@ -1211,11 +1211,18 @@ func (d *Dereferencer) handleStatusEdit( edit.Text = existing.Text edit.Language = existing.Language edit.Sensitive = existing.Sensitive - edit.AttachmentIDs = existing.AttachmentIDs - edit.AttachmentDescriptions = getAttachmentDescriptions(existing.Attachments) - edit.Attachments = existing.Attachments edit.StatusID = status.ID + // Copy existing attachments and descriptions. + edit.AttachmentIDs = existing.AttachmentIDs + edit.Attachments = existing.Attachments + if l := len(existing.Attachments); l > 0 { + edit.AttachmentDescriptions = make([]string, l) + for i, attach := range existing.Attachments { + edit.AttachmentDescriptions[i] = attach.Description + } + } + // Edit creation is last update time. edit.CreatedAt = existing.UpdatedAt diff --git a/internal/federation/dereferencing/util.go b/internal/federation/dereferencing/util.go index d62867761..208117660 100644 --- a/internal/federation/dereferencing/util.go +++ b/internal/federation/dereferencing/util.go @@ -21,7 +21,6 @@ import ( "slices" "github.com/superseriousbusiness/gotosocial/internal/gtsmodel" - "github.com/superseriousbusiness/gotosocial/internal/util/xslices" ) // getEmojiByShortcodeDomain searches input slice @@ -71,23 +70,3 @@ func pollStateUpdated(existing, latest *gtsmodel.Poll) bool { func pollJustClosed(existing, latest *gtsmodel.Poll) bool { return existing.ClosedAt.IsZero() && latest.Closed() } - -// statusChanged returns whether a status has changed in a way that -// indicates that existing should be snapshotted for version history. -func statusChanged(existing, latest *gtsmodel.Status) bool { - return existing.Content != latest.Content || - existing.ContentWarning != latest.ContentWarning || - !slices.Equal(existing.AttachmentIDs, latest.AttachmentIDs) -} - -// getAttachmentDescriptions returns a slice of the media attachment descriptions of input slice. -func getAttachmentDescriptions(attachments []*gtsmodel.MediaAttachment) []string { - if len(attachments) == 0 { - return nil - } - return xslices.Gather( - nil, - attachments, - func(a *gtsmodel.MediaAttachment) string { return a.Description }, - ) -}