summaryrefslogtreecommitdiff
path: root/internal/processing
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2025-02-13 14:10:13 +0100
committerLibravatar GitHub <noreply@github.com>2025-02-13 14:10:13 +0100
commitdfcb7862a9e41459ef194a8b67380c580e1ab03d (patch)
tree2c4b69de5cc8afd48c0f69f23303d5be2f0e180a /internal/processing
parent[chore] bump ncruces go-sqlite3 => v0.23.0 (#3785) (diff)
downloadgotosocial-dfcb7862a9e41459ef194a8b67380c580e1ab03d.tar.xz
[bugfix] Return 404 when web context target status hidden (#3792)
Diffstat (limited to 'internal/processing')
-rw-r--r--internal/processing/status/context.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/internal/processing/status/context.go b/internal/processing/status/context.go
index 58977e4ae..47806a64b 100644
--- a/internal/processing/status/context.go
+++ b/internal/processing/status/context.go
@@ -442,6 +442,33 @@ func (p *Processor) WebContextGet(
_, parentHidden := hiddenStatuses[status.InReplyToID]
v, err := p.visFilter.StatusVisible(ctx, nil, status)
if err != nil || !v || parentHidden {
+ // If this is the main status whose
+ // context we're looking for, and it's
+ // not visible for whatever reason, we
+ // should just return a 404 here, as we
+ // can't meaningfully render the thread.
+ if status.ID == targetStatusID {
+ var thisErr error
+ switch {
+ case err != nil:
+ thisErr = gtserror.Newf("error checking visibility of target status: %w", err)
+
+ case !v:
+ const errText = "target status not visible"
+ thisErr = gtserror.New(errText)
+
+ case parentHidden:
+ const errText = "target status parent is hidden"
+ thisErr = gtserror.New(errText)
+ }
+
+ return nil, gtserror.NewErrorNotFound(thisErr)
+ }
+
+ // This isn't the main status whose
+ // context we're looking for, just
+ // your standard not-visible status,
+ // so add it to the count + map.
if !inReplies {
// Main thread entry hidden.
wCtx.ThreadHidden++