summaryrefslogtreecommitdiff
path: root/internal/processing/status/boost.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/processing/status/boost.go')
-rw-r--r--internal/processing/status/boost.go37
1 files changed, 31 insertions, 6 deletions
diff --git a/internal/processing/status/boost.go b/internal/processing/status/boost.go
index 1b410bb0a..d6a0c2457 100644
--- a/internal/processing/status/boost.go
+++ b/internal/processing/status/boost.go
@@ -66,7 +66,7 @@ func (p *Processor) BoostCreate(
}
// Ensure valid boost target for requester.
- boostable, err := p.filter.StatusBoostable(ctx,
+ policyResult, err := p.intFilter.StatusBoostable(ctx,
requester,
target,
)
@@ -75,12 +75,14 @@ func (p *Processor) BoostCreate(
return nil, gtserror.NewErrorInternalError(err)
}
- if !boostable {
- err := gtserror.New("status is not boostable")
- return nil, gtserror.NewErrorNotFound(err)
+ if policyResult.Forbidden() {
+ const errText = "you do not have permission to boost this status"
+ err := gtserror.New(errText)
+ return nil, gtserror.NewErrorForbidden(err, errText)
}
- // Status is visible and boostable.
+ // Status is visible and boostable
+ // (though maybe pending approval).
boost, err := p.converter.StatusToBoost(ctx,
target,
requester,
@@ -90,6 +92,29 @@ func (p *Processor) BoostCreate(
return nil, gtserror.NewErrorInternalError(err)
}
+ // Derive pendingApproval status.
+ var pendingApproval bool
+ switch {
+ case policyResult.WithApproval():
+ // We're allowed to do
+ // this pending approval.
+ pendingApproval = true
+
+ case policyResult.MatchedOnCollection():
+ // We're permitted to do this, but since
+ // we matched due to presence in a followers
+ // or following collection, we should mark
+ // as pending approval and wait for an accept.
+ pendingApproval = true
+
+ case policyResult.Permitted():
+ // We're permitted to do this
+ // based on another kind of match.
+ pendingApproval = false
+ }
+
+ boost.PendingApproval = &pendingApproval
+
// Store the new boost.
if err := p.state.DB.PutStatus(ctx, boost); err != nil {
return nil, gtserror.NewErrorInternalError(err)
@@ -184,7 +209,7 @@ func (p *Processor) StatusBoostedBy(ctx context.Context, requestingAccount *gtsm
targetStatus = boostedStatus
}
- visible, err := p.filter.StatusVisible(ctx, requestingAccount, targetStatus)
+ visible, err := p.visFilter.StatusVisible(ctx, requestingAccount, targetStatus)
if err != nil {
err = fmt.Errorf("BoostedBy: error seeing if status %s is visible: %s", targetStatus.ID, err)
return nil, gtserror.NewErrorNotFound(err)