[bugfix] Return 404 when web context target status hidden (#3792)
This commit is contained in:
parent
24f6760c0e
commit
dfcb7862a9
1 changed files with 27 additions and 0 deletions
|
@ -442,6 +442,33 @@ func (p *Processor) WebContextGet(
|
||||||
_, parentHidden := hiddenStatuses[status.InReplyToID]
|
_, parentHidden := hiddenStatuses[status.InReplyToID]
|
||||||
v, err := p.visFilter.StatusVisible(ctx, nil, status)
|
v, err := p.visFilter.StatusVisible(ctx, nil, status)
|
||||||
if err != nil || !v || parentHidden {
|
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 {
|
if !inReplies {
|
||||||
// Main thread entry hidden.
|
// Main thread entry hidden.
|
||||||
wCtx.ThreadHidden++
|
wCtx.ThreadHidden++
|
||||||
|
|
Loading…
Reference in a new issue