summaryrefslogtreecommitdiff
path: root/internal/federation/dereferencing/announce.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/federation/dereferencing/announce.go')
-rw-r--r--internal/federation/dereferencing/announce.go24
1 files changed, 18 insertions, 6 deletions
diff --git a/internal/federation/dereferencing/announce.go b/internal/federation/dereferencing/announce.go
index d786d0695..a3eaf199d 100644
--- a/internal/federation/dereferencing/announce.go
+++ b/internal/federation/dereferencing/announce.go
@@ -69,12 +69,6 @@ func (d *Dereferencer) EnrichAnnounce(
return nil, err
}
- // Generate an ID for the boost wrapper status.
- boost.ID, err = id.NewULIDFromTime(boost.CreatedAt)
- if err != nil {
- return nil, gtserror.Newf("error generating id: %w", err)
- }
-
// Set boost_of_uri again in case the
// original URI was an indirect link.
boost.BoostOfURI = target.URI
@@ -92,6 +86,24 @@ func (d *Dereferencer) EnrichAnnounce(
boost.Visibility = target.Visibility
boost.Federated = target.Federated
+ // Ensure this Announce is permitted by the Announcee.
+ permit, err := d.isPermittedStatus(ctx, requestUser, nil, boost)
+ if err != nil {
+ return nil, gtserror.Newf("error checking permitted status %s: %w", boost.URI, err)
+ }
+
+ if !permit {
+ // Return a checkable error type that can be ignored.
+ err := gtserror.Newf("dropping unpermitted status: %s", boost.URI)
+ return nil, gtserror.SetNotPermitted(err)
+ }
+
+ // Generate an ID for the boost wrapper status.
+ boost.ID, err = id.NewULIDFromTime(boost.CreatedAt)
+ if err != nil {
+ return nil, gtserror.Newf("error generating id: %w", err)
+ }
+
// Store the boost wrapper status in database.
switch err = d.state.DB.PutStatus(ctx, boost); {
case err == nil: