mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-25 23:13:32 -06:00
[bugfix] small editing tweaks (#3631)
* ensure edited_at isn't set on boost wrapper statuses * improve handling of remote status updated_at to fix previous cases * formatting * add remote status published / updated field validation checks, handle appropriately in handleStatusEdit() * specifically allowed updated to be equal to published * only check creation date change when an existing status
This commit is contained in:
parent
fe8d5f2307
commit
0784aa3218
3 changed files with 33 additions and 12 deletions
|
|
@ -22,6 +22,7 @@ import (
|
|||
"context"
|
||||
"errors"
|
||||
"net/url"
|
||||
"time"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/ap"
|
||||
|
|
@ -357,15 +358,21 @@ func (c *Converter) ASStatusToStatus(ctx context.Context, statusable ap.Statusab
|
|||
status.CreatedAt = pub
|
||||
} else {
|
||||
log.Warnf(ctx, "unusable published property on %s", uri)
|
||||
status.CreatedAt = time.Now()
|
||||
}
|
||||
|
||||
// status.Updated
|
||||
//
|
||||
// Extract updated time for status, defaults to Published.
|
||||
if upd := ap.GetUpdated(statusable); !upd.IsZero() {
|
||||
// Extract and validate update time for status. Defaults to published.
|
||||
if upd := ap.GetUpdated(statusable); !upd.Before(status.CreatedAt) {
|
||||
status.UpdatedAt = upd
|
||||
} else {
|
||||
} else if upd.IsZero() {
|
||||
status.UpdatedAt = status.CreatedAt
|
||||
} else {
|
||||
|
||||
// This is a malformed status that will likely break our systems.
|
||||
err := gtserror.Newf("status %s 'updated' predates 'published'", uri)
|
||||
return nil, gtserror.SetMalformed(err)
|
||||
}
|
||||
|
||||
// status.AccountURI
|
||||
|
|
|
|||
|
|
@ -1383,11 +1383,13 @@ func (c *Converter) baseStatusToFrontend(
|
|||
InteractionPolicy: *apiInteractionPolicy,
|
||||
}
|
||||
|
||||
// Nullable fields.
|
||||
if !s.UpdatedAt.Equal(s.CreatedAt) {
|
||||
// Only set edited_at if this is a non-boost-wrapper
|
||||
// with an updated_at date different to creation date.
|
||||
if !s.UpdatedAt.Equal(s.CreatedAt) && s.BoostOfID == "" {
|
||||
timestamp := util.FormatISO8601(s.UpdatedAt)
|
||||
apiStatus.EditedAt = util.Ptr(timestamp)
|
||||
}
|
||||
|
||||
apiStatus.InReplyToID = util.PtrIf(s.InReplyToID)
|
||||
apiStatus.InReplyToAccountID = util.PtrIf(s.InReplyToAccountID)
|
||||
apiStatus.Language = util.PtrIf(s.Language)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue