Compare commits

..

No commits in common. "a69142a403ebe82575d8afd2863d57e05c9b5f79" and "2c3f1f4ddb3b91c9a70b929aed51b4bffcc6d6ee" have entirely different histories.

3 changed files with 29 additions and 67 deletions

View file

@ -235,7 +235,7 @@ func (d *Dereferencer) isPermittedReply(
// Status doesn't claim to be approved. // Status doesn't claim to be approved.
// Check interaction policy of inReplyTo // Check interaction policy of inReplyTo
// to see what we need to do with it. // to see if it doesn't require approval.
replyable, err := d.intFilter.StatusReplyable(ctx, replyable, err := d.intFilter.StatusReplyable(ctx,
reply.Account, reply.Account,
inReplyTo, inReplyTo,
@ -260,52 +260,35 @@ func (d *Dereferencer) isPermittedReply(
) )
} }
if replyable.Permitted() && // Reply is permitted according to the interaction
!replyable.MatchedOnCollection() { // policy set on the replied-to status (if any).
// Reply is permitted and match was *not* made
// based on inclusion in a followers/following if !replyable.MatchedOnCollection() {
// collection. Just permit the reply full stop // If we didn't match on a collection,
// as no approval / accept URI is necessary. // then we don't require an acceptIRI,
// and we don't need to send an Accept;
// just permit the reply full stop.
return true, nil return true, nil
} }
// Reply is either permitted based on inclusion in a // Reply is permitted, but match was made based
// followers/following collection, *or* is permitted // on inclusion in a followers/following collection.
// pending approval, though we know at this point //
// that the status did not include an approvedBy URI. // If the status is ours, mark it as PreApproved
// so the processor knows to create and send out
if !inReplyTo.IsLocal() { // an Accept for it immediately.
// If the replied-to status is remote, we should just if inReplyTo.IsLocal() {
// drop this reply at this point, as we can't verify
// that the remote replied-to account approves it, and
// we can't verify the presence of a remote account
// in one of another remote account's collections.
//
// It's possible we'll get an Accept from the replied-
// to account later, and we can store this reply then.
return false, nil
}
// Replied-to status is ours, so the
// replied-to account is ours as well.
if replyable.MatchedOnCollection() {
// If permission was granted based on inclusion in
// a followers/following collection, pre-approve the
// reply, as we ourselves can validate presence of the
// replier in the appropriate collection. Pre-approval
// lets the processor know it should send out an Accept
// straight away on behalf of the replied-to account.
reply.PendingApproval = util.Ptr(true) reply.PendingApproval = util.Ptr(true)
reply.PreApproved = true reply.PreApproved = true
return true, nil return true, nil
} }
// Reply just requires approval from the local account // For replies to remote statuses, which matched
// it replies to. Set PendingApproval so the processor // on a followers/following collection, but did not
// knows to create a pending interaction request. // include an acceptIRI, we should just drop it.
reply.PendingApproval = util.Ptr(true) // It's possible we'll get an Accept for it later
return true, nil // and we can check everything again.
return false, nil
} }
// unpermittedByParent marks the given reply as rejected // unpermittedByParent marks the given reply as rejected

View file

@ -19,7 +19,6 @@
import ( import (
"context" "context"
"errors"
"slices" "slices"
"strings" "strings"
@ -403,10 +402,6 @@ func (p *Processor) WebContextGet(
// We should mark the next **VISIBLE** // We should mark the next **VISIBLE**
// reply as the first reply. // reply as the first reply.
markNextVisibleAsFirstReply bool markNextVisibleAsFirstReply bool
// Map of statuses that didn't pass visi
// checks and won't be shown via the web.
hiddenStatuses = make(map[string]struct{})
) )
for idx, status := range wholeThread { for idx, status := range wholeThread {
@ -432,16 +427,11 @@ func (p *Processor) WebContextGet(
} }
} }
// Ensure status is actually visible to just // Ensure status is actually
// anyone, and hide / don't include it if not. // visible to just anyone, and
// // hide / don't include it if not.
// Include a check to see if the parent status
// is hidden; if so, we shouldn't show the child
// as it leads to weird-looking threading where
// a status seems to reply to nothing.
_, 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 {
if !inReplies { if !inReplies {
// Main thread entry hidden. // Main thread entry hidden.
wCtx.ThreadHidden++ wCtx.ThreadHidden++
@ -449,15 +439,12 @@ func (p *Processor) WebContextGet(
// Reply hidden. // Reply hidden.
wCtx.ThreadRepliesHidden++ wCtx.ThreadRepliesHidden++
} }
hiddenStatuses[status.ID] = struct{}{}
continue continue
} }
// Prepare visible status to add to thread context. // Prepare visible status to add to thread context.
webStatus, err := p.converter.StatusToWebStatus(ctx, status) webStatus, err := p.converter.StatusToWebStatus(ctx, status)
if err != nil { if err != nil {
hiddenStatuses[status.ID] = struct{}{}
continue continue
} }
@ -525,17 +512,9 @@ func (p *Processor) WebContextGet(
wCtx.ThreadLength = threadLength wCtx.ThreadLength = threadLength
} }
// Jot down number of "main" thread entries shown. // Jot down number of hidden posts so template doesn't have to do it.
wCtx.ThreadShown = wCtx.ThreadLength - wCtx.ThreadHidden wCtx.ThreadShown = wCtx.ThreadLength - wCtx.ThreadHidden
// If there's no posts visible in the
// "main" thread we shouldn't show replies
// via the web as that's just weird.
if wCtx.ThreadShown < 1 {
const text = "no statuses visible in main thread"
return nil, gtserror.NewErrorNotFound(errors.New(text))
}
// Mark the last "main" visible status. // Mark the last "main" visible status.
wCtx.Statuses[wCtx.ThreadShown-1].ThreadLastMain = true wCtx.Statuses[wCtx.ThreadShown-1].ThreadLastMain = true
@ -544,7 +523,7 @@ func (p *Processor) WebContextGet(
// part of the "main" thread. // part of the "main" thread.
wCtx.ThreadReplies = threadLength - wCtx.ThreadLength wCtx.ThreadReplies = threadLength - wCtx.ThreadLength
// Jot down number of "replies" shown. // Jot down number of hidden replies so template doesn't have to do it.
wCtx.ThreadRepliesShown = wCtx.ThreadReplies - wCtx.ThreadRepliesHidden wCtx.ThreadRepliesShown = wCtx.ThreadReplies - wCtx.ThreadRepliesHidden
// Return the finished context. // Return the finished context.

View file

@ -91,7 +91,7 @@ Polls can have up to
<li><a href="#contact">Contact</a></li> <li><a href="#contact">Contact</a></li>
<li><a href="#features">Features</a></li> <li><a href="#features">Features</a></li>
<li><a href="#languages">Languages</a></li> <li><a href="#languages">Languages</a></li>
<li><a href="#signup">Register an Account on {{ .instance.Title -}}</a></li> <li><a href="#signup">Register an Account on {{ .instance.Title -}}</li>
<li><a href="#rules">Rules</a></li> <li><a href="#rules">Rules</a></li>
<li><a href="#terms">Terms and Conditions</a></li> <li><a href="#terms">Terms and Conditions</a></li>
<li><a href="#moderated-servers">Moderated Servers</a></li> <li><a href="#moderated-servers">Moderated Servers</a></li>