From c47b9bd1d184ce415a9df9815536a161ab2869b5 Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Fri, 31 Jan 2025 17:09:11 +0100 Subject: [chore] Add "object" uri to outgoing Accept + Reject messages (#3717) --- internal/typeutils/internaltoas.go | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) (limited to 'internal/typeutils/internaltoas.go') diff --git a/internal/typeutils/internaltoas.go b/internal/typeutils/internaltoas.go index ce5187bde..ef492d91d 100644 --- a/internal/typeutils/internaltoas.go +++ b/internal/typeutils/internaltoas.go @@ -2021,7 +2021,19 @@ func (c *Converter) InteractionReqToASAccept( objectIRI, err := url.Parse(req.InteractionURI) if err != nil { - return nil, gtserror.Newf("invalid target uri: %w", err) + return nil, gtserror.Newf("invalid object uri: %w", err) + } + + if req.Status == nil { + req.Status, err = c.state.DB.GetStatusByID(ctx, req.StatusID) + if err != nil { + return nil, gtserror.Newf("db error getting interaction req target status: %w", err) + } + } + + targetIRI, err := url.Parse(req.Status.URI) + if err != nil { + return nil, gtserror.Newf("invalid interaction req target status uri: %w", err) } toIRI, err := url.Parse(req.InteractingAccount.URI) @@ -2040,6 +2052,10 @@ func (c *Converter) InteractionReqToASAccept( // Object is the interaction URI. ap.AppendObjectIRIs(accept, objectIRI) + // Target is the URI of the + // status being interacted with. + ap.AppendTargetIRIs(accept, targetIRI) + // Address to the owner // of interaction URI. ap.AppendTo(accept, toIRI) @@ -2101,7 +2117,19 @@ func (c *Converter) InteractionReqToASReject( objectIRI, err := url.Parse(req.InteractionURI) if err != nil { - return nil, gtserror.Newf("invalid target uri: %w", err) + return nil, gtserror.Newf("invalid object uri: %w", err) + } + + if req.Status == nil { + req.Status, err = c.state.DB.GetStatusByID(ctx, req.StatusID) + if err != nil { + return nil, gtserror.Newf("db error getting interaction req target status: %w", err) + } + } + + targetIRI, err := url.Parse(req.Status.URI) + if err != nil { + return nil, gtserror.Newf("invalid interaction req target status uri: %w", err) } toIRI, err := url.Parse(req.InteractingAccount.URI) @@ -2120,6 +2148,10 @@ func (c *Converter) InteractionReqToASReject( // Object is the interaction URI. ap.AppendObjectIRIs(reject, objectIRI) + // Target is the URI of the + // status being interacted with. + ap.AppendTargetIRIs(reject, targetIRI) + // Address to the owner // of interaction URI. ap.AppendTo(reject, toIRI) -- cgit v1.2.3