add support for extracting Updated field from Statusable implementers

This commit is contained in:
kim 2024-11-13 12:02:17 +00:00
commit fc8d3742c9
5 changed files with 144 additions and 24 deletions

View file

@ -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,

View file

@ -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 &gtsmodel.InteractionRequest{
ID: reqID,
@ -178,7 +166,7 @@ func StatusFaveToInteractionRequest(
InteractionURI: fave.URI,
InteractionType: gtsmodel.InteractionLike,
Like: fave,
}, nil
}
}
func (c *Converter) StatusToSinBinStatus(