summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2025-01-31 17:09:11 +0100
committerLibravatar GitHub <noreply@github.com>2025-01-31 17:09:11 +0100
commitc47b9bd1d184ce415a9df9815536a161ab2869b5 (patch)
tree064566c4bbec608ac570591c8a8bb97de1323804 /internal
parent[chore] Web Push: Use server URL for VAPID sub claim (#3716) (diff)
downloadgotosocial-c47b9bd1d184ce415a9df9815536a161ab2869b5.tar.xz
[chore] Add "object" uri to outgoing Accept + Reject messages (#3717)
Diffstat (limited to 'internal')
-rw-r--r--internal/typeutils/internaltoas.go36
-rw-r--r--internal/typeutils/internaltoas_test.go8
2 files changed, 41 insertions, 3 deletions
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)
diff --git a/internal/typeutils/internaltoas_test.go b/internal/typeutils/internaltoas_test.go
index 4d0d95641..ce949d577 100644
--- a/internal/typeutils/internaltoas_test.go
+++ b/internal/typeutils/internaltoas_test.go
@@ -1235,7 +1235,9 @@ func (suite *InternalToASTestSuite) TestInteractionReqToASAcceptAnnounce() {
req := &gtsmodel.InteractionRequest{
ID: "01J1AKMZ8JE5NW0ZSFTRC1JJNE",
CreatedAt: testrig.TimeMustParse("2022-06-09T13:12:00Z"),
- TargetAccountID: acceptingAccount.ID,
+ StatusID: "01JJYCVKCXB9JTQD1XW2KB8MT3",
+ Status: &gtsmodel.Status{URI: "http://localhost:8080/users/the_mighty_zork/statuses/01JJYCVKCXB9JTQD1XW2KB8MT3"},
+ TargetAccountID: acceptingAccount.ID,
TargetAccount: acceptingAccount,
InteractingAccountID: interactingAccount.ID,
InteractingAccount: interactingAccount,
@@ -1272,6 +1274,7 @@ func (suite *InternalToASTestSuite) TestInteractionReqToASAcceptAnnounce() {
],
"id": "http://localhost:8080/users/the_mighty_zork/accepts/01J1AKMZ8JE5NW0ZSFTRC1JJNE",
"object": "https://fossbros-anonymous.io/users/foss_satan/statuses/01J1AKRRHQ6MDDQHV0TP716T2K",
+ "target": "http://localhost:8080/users/the_mighty_zork/statuses/01JJYCVKCXB9JTQD1XW2KB8MT3",
"to": "http://fossbros-anonymous.io/users/foss_satan",
"type": "Accept"
}`, string(b))
@@ -1284,6 +1287,8 @@ func (suite *InternalToASTestSuite) TestInteractionReqToASAcceptLike() {
req := &gtsmodel.InteractionRequest{
ID: "01J1AKMZ8JE5NW0ZSFTRC1JJNE",
CreatedAt: testrig.TimeMustParse("2022-06-09T13:12:00Z"),
+ StatusID: "01JJYCVKCXB9JTQD1XW2KB8MT3",
+ Status: &gtsmodel.Status{URI: "http://localhost:8080/users/the_mighty_zork/statuses/01JJYCVKCXB9JTQD1XW2KB8MT3"},
TargetAccountID: acceptingAccount.ID,
TargetAccount: acceptingAccount,
InteractingAccountID: interactingAccount.ID,
@@ -1317,6 +1322,7 @@ func (suite *InternalToASTestSuite) TestInteractionReqToASAcceptLike() {
"actor": "http://localhost:8080/users/the_mighty_zork",
"id": "http://localhost:8080/users/the_mighty_zork/accepts/01J1AKMZ8JE5NW0ZSFTRC1JJNE",
"object": "https://fossbros-anonymous.io/users/foss_satan/statuses/01J1AKRRHQ6MDDQHV0TP716T2K",
+ "target": "http://localhost:8080/users/the_mighty_zork/statuses/01JJYCVKCXB9JTQD1XW2KB8MT3",
"to": "http://fossbros-anonymous.io/users/foss_satan",
"type": "Accept"
}`, string(b))