summaryrefslogtreecommitdiff
path: root/internal/processing/interactionrequests
diff options
context:
space:
mode:
authorLibravatar tobi <tobi.smethurst@protonmail.com>2025-09-14 15:37:35 +0200
committerLibravatar tobi <kipvandenbos@noreply.codeberg.org>2025-09-14 15:37:35 +0200
commit754b7be9cfd3f50e6e219177cdd4c992a2d9c38f (patch)
treef20e7d3c4aa12341289aada97542a756d2daed5d /internal/processing/interactionrequests
parent[bugfix] set link header lo,hi values directly from returned slice, don't acc... (diff)
downloadgotosocial-754b7be9cfd3f50e6e219177cdd4c992a2d9c38f.tar.xz
[feature] Support new model of interaction flow for forward compat with v0.21.0 (#4394)
~~Still WIP!~~ This PR allows v0.20.0 of GtS to be forward-compatible with the interaction request / authorization flow that will fully replace the current flow in v0.21.0. Basically, this means we need to recognize LikeRequest, ReplyRequest, and AnnounceRequest, and in response to those requests, deliver either a Reject or an Accept, with the latter pointing towards a LikeAuthorization, ReplyAuthorization, or AnnounceAuthorization, respectively. This can then be used by the remote instance to prove to third parties that the interaction has been accepted by the interactee. These Authorization types need to be dereferencable to third parties, so we need to serve them. As well as recognizing the above "polite" interaction request types, we also need to still serve appropriate responses to "impolite" interaction request types, where an instance that's unaware of interaction policies tries to interact with a post by sending a reply, like, or boost directly, without wrapping it in a WhateverRequest type. Doesn't fully close https://codeberg.org/superseriousbusiness/gotosocial/issues/4026 but gets damn near (just gotta update the federating with GtS documentation). Migrations tested on both Postgres and SQLite. Co-authored-by: kim <grufwub@gmail.com> Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4394 Co-authored-by: tobi <tobi.smethurst@protonmail.com> Co-committed-by: tobi <tobi.smethurst@protonmail.com>
Diffstat (limited to 'internal/processing/interactionrequests')
-rw-r--r--internal/processing/interactionrequests/accept.go14
-rw-r--r--internal/processing/interactionrequests/accept_test.go2
-rw-r--r--internal/processing/interactionrequests/reject.go4
3 files changed, 11 insertions, 9 deletions
diff --git a/internal/processing/interactionrequests/accept.go b/internal/processing/interactionrequests/accept.go
index ce682380b..7efd1f373 100644
--- a/internal/processing/interactionrequests/accept.go
+++ b/internal/processing/interactionrequests/accept.go
@@ -65,14 +65,16 @@ func (p *Processor) Accept(
defer unlock()
// Mark the request as accepted
- // and generate a URI for it.
+ // and generate URIs for it.
req.AcceptedAt = time.Now()
- req.URI = uris.GenerateURIForAccept(acct.Username, req.ID)
+ req.ResponseURI = uris.GenerateURIForAccept(acct.Username, req.ID)
+ req.AuthorizationURI = uris.GenerateURIForAuthorization(acct.Username, req.ID)
if err := p.state.DB.UpdateInteractionRequest(
ctx,
req,
"accepted_at",
- "uri",
+ "response_uri",
+ "authorization_uri",
); err != nil {
err := gtserror.Newf("db error updating interaction request: %w", err)
return nil, gtserror.NewErrorInternalError(err)
@@ -132,7 +134,7 @@ func (p *Processor) acceptLike(
// Update the Like.
req.Like.PendingApproval = util.Ptr(false)
req.Like.PreApproved = false
- req.Like.ApprovedByURI = req.URI
+ req.Like.ApprovedByURI = req.AuthorizationURI
if err := p.state.DB.UpdateStatusFave(
ctx,
req.Like,
@@ -173,7 +175,7 @@ func (p *Processor) acceptReply(
// Update the Reply.
req.Reply.PendingApproval = util.Ptr(false)
req.Reply.PreApproved = false
- req.Reply.ApprovedByURI = req.URI
+ req.Reply.ApprovedByURI = req.AuthorizationURI
if err := p.state.DB.UpdateStatus(
ctx,
req.Reply,
@@ -214,7 +216,7 @@ func (p *Processor) acceptAnnounce(
// Update the Announce.
req.Announce.PendingApproval = util.Ptr(false)
req.Announce.PreApproved = false
- req.Announce.ApprovedByURI = req.URI
+ req.Announce.ApprovedByURI = req.AuthorizationURI
if err := p.state.DB.UpdateStatus(
ctx,
req.Announce,
diff --git a/internal/processing/interactionrequests/accept_test.go b/internal/processing/interactionrequests/accept_test.go
index b48978f2c..cb4212c24 100644
--- a/internal/processing/interactionrequests/accept_test.go
+++ b/internal/processing/interactionrequests/accept_test.go
@@ -67,7 +67,7 @@ func (suite *AcceptTestSuite) TestAccept() {
suite.FailNow(err.Error())
}
suite.False(*dbStatus.PendingApproval)
- suite.Equal(dbReq.URI, dbStatus.ApprovedByURI)
+ suite.Equal(dbReq.AuthorizationURI, dbStatus.ApprovedByURI)
// Wait for a notification
// for interacting status.
diff --git a/internal/processing/interactionrequests/reject.go b/internal/processing/interactionrequests/reject.go
index 3ceaa47d9..4db52e260 100644
--- a/internal/processing/interactionrequests/reject.go
+++ b/internal/processing/interactionrequests/reject.go
@@ -66,12 +66,12 @@ func (p *Processor) Reject(
// Mark the request as rejected
// and generate a URI for it.
req.RejectedAt = time.Now()
- req.URI = uris.GenerateURIForReject(acct.Username, req.ID)
+ req.ResponseURI = uris.GenerateURIForReject(acct.Username, req.ID)
if err := p.state.DB.UpdateInteractionRequest(
ctx,
req,
"rejected_at",
- "uri",
+ "response_uri",
); err != nil {
err := gtserror.Newf("db error updating interaction request: %w", err)
return nil, gtserror.NewErrorInternalError(err)