mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2026-01-03 02:13:17 -06:00
add support for extracting Updated field from Statusable implementers
This commit is contained in:
parent
55d6731497
commit
fc8d3742c9
5 changed files with 144 additions and 24 deletions
|
|
@ -348,18 +348,25 @@ func (c *Converter) ASStatusToStatus(ctx context.Context, statusable ap.Statusab
|
|||
// zero-time will fall back to db defaults.
|
||||
if pub := ap.GetPublished(statusable); !pub.IsZero() {
|
||||
status.CreatedAt = pub
|
||||
status.UpdatedAt = pub
|
||||
} else {
|
||||
log.Warnf(ctx, "unusable published property on %s", uri)
|
||||
}
|
||||
|
||||
// status.Updated
|
||||
//
|
||||
// Extract updated time for status, defaults to Published.
|
||||
if upd := ap.GetUpdated(statusable); !upd.IsZero() {
|
||||
status.UpdatedAt = upd
|
||||
} else {
|
||||
status.UpdatedAt = status.CreatedAt
|
||||
}
|
||||
|
||||
// status.AccountURI
|
||||
// status.AccountID
|
||||
// status.Account
|
||||
//
|
||||
// Account that created the status. Assume we have
|
||||
// this in the db by the time this function is called,
|
||||
// error if we don't.
|
||||
// Account that created the status. Assume we have this
|
||||
// in the db by the time this function is called, else error.
|
||||
status.Account, err = c.getASAttributedToAccount(ctx,
|
||||
status.URI,
|
||||
statusable,
|
||||
|
|
|
|||
|
|
@ -104,14 +104,8 @@ func (c *Converter) StatusToBoost(
|
|||
return boost, nil
|
||||
}
|
||||
|
||||
func StatusToInteractionRequest(
|
||||
ctx context.Context,
|
||||
status *gtsmodel.Status,
|
||||
) (*gtsmodel.InteractionRequest, error) {
|
||||
reqID, err := id.NewULIDFromTime(status.CreatedAt)
|
||||
if err != nil {
|
||||
return nil, gtserror.Newf("error generating ID: %w", err)
|
||||
}
|
||||
func StatusToInteractionRequest(status *gtsmodel.Status) *gtsmodel.InteractionRequest {
|
||||
reqID := id.NewULIDFromTime(status.CreatedAt)
|
||||
|
||||
var (
|
||||
targetID string
|
||||
|
|
@ -154,17 +148,11 @@ func StatusToInteractionRequest(
|
|||
InteractionType: interactionType,
|
||||
Reply: reply,
|
||||
Announce: announce,
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
|
||||
func StatusFaveToInteractionRequest(
|
||||
ctx context.Context,
|
||||
fave *gtsmodel.StatusFave,
|
||||
) (*gtsmodel.InteractionRequest, error) {
|
||||
reqID, err := id.NewULIDFromTime(fave.CreatedAt)
|
||||
if err != nil {
|
||||
return nil, gtserror.Newf("error generating ID: %w", err)
|
||||
}
|
||||
func StatusFaveToInteractionRequest(fave *gtsmodel.StatusFave) *gtsmodel.InteractionRequest {
|
||||
reqID := id.NewULIDFromTime(fave.CreatedAt)
|
||||
|
||||
return >smodel.InteractionRequest{
|
||||
ID: reqID,
|
||||
|
|
@ -178,7 +166,7 @@ func StatusFaveToInteractionRequest(
|
|||
InteractionURI: fave.URI,
|
||||
InteractionType: gtsmodel.InteractionLike,
|
||||
Like: fave,
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Converter) StatusToSinBinStatus(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue