Skip to content

Commit e8fd40f

Browse files
authored
[bugfix] Fix replies not being stored pending approval (#3409)
1 parent 2c3f1f4 commit e8fd40f

File tree

1 file changed

+39
-22
lines changed

1 file changed

+39
-22
lines changed

internal/federation/dereferencing/status_permitted.go

+39-22
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ func (d *Dereferencer) isPermittedReply(
235235

236236
// Status doesn't claim to be approved.
237237
// Check interaction policy of inReplyTo
238-
// to see if it doesn't require approval.
238+
// to see what we need to do with it.
239239
replyable, err := d.intFilter.StatusReplyable(ctx,
240240
reply.Account,
241241
inReplyTo,
@@ -260,35 +260,52 @@ func (d *Dereferencer) isPermittedReply(
260260
)
261261
}
262262

263-
// Reply is permitted according to the interaction
264-
// policy set on the replied-to status (if any).
265-
266-
if !replyable.MatchedOnCollection() {
267-
// If we didn't match on a collection,
268-
// then we don't require an acceptIRI,
269-
// and we don't need to send an Accept;
270-
// just permit the reply full stop.
263+
if replyable.Permitted() &&
264+
!replyable.MatchedOnCollection() {
265+
// Reply is permitted and match was *not* made
266+
// based on inclusion in a followers/following
267+
// collection. Just permit the reply full stop
268+
// as no approval / accept URI is necessary.
271269
return true, nil
272270
}
273271

274-
// Reply is permitted, but match was made based
275-
// on inclusion in a followers/following collection.
276-
//
277-
// If the status is ours, mark it as PreApproved
278-
// so the processor knows to create and send out
279-
// an Accept for it immediately.
280-
if inReplyTo.IsLocal() {
272+
// Reply is either permitted based on inclusion in a
273+
// followers/following collection, *or* is permitted
274+
// pending approval, though we know at this point
275+
// that the status did not include an approvedBy URI.
276+
277+
if !inReplyTo.IsLocal() {
278+
// If the replied-to status is remote, we should just
279+
// drop this reply at this point, as we can't verify
280+
// that the remote replied-to account approves it, and
281+
// we can't verify the presence of a remote account
282+
// in one of another remote account's collections.
283+
//
284+
// It's possible we'll get an Accept from the replied-
285+
// to account later, and we can store this reply then.
286+
return false, nil
287+
}
288+
289+
// Replied-to status is ours, so the
290+
// replied-to account is ours as well.
291+
292+
if replyable.MatchedOnCollection() {
293+
// If permission was granted based on inclusion in
294+
// a followers/following collection, pre-approve the
295+
// reply, as we ourselves can validate presence of the
296+
// replier in the appropriate collection. Pre-approval
297+
// lets the processor know it should send out an Accept
298+
// straight away on behalf of the replied-to account.
281299
reply.PendingApproval = util.Ptr(true)
282300
reply.PreApproved = true
283301
return true, nil
284302
}
285303

286-
// For replies to remote statuses, which matched
287-
// on a followers/following collection, but did not
288-
// include an acceptIRI, we should just drop it.
289-
// It's possible we'll get an Accept for it later
290-
// and we can check everything again.
291-
return false, nil
304+
// Reply just requires approval from the local account
305+
// it replies to. Set PendingApproval so the processor
306+
// knows to create a pending interaction request.
307+
reply.PendingApproval = util.Ptr(true)
308+
return true, nil
292309
}
293310

294311
// unpermittedByParent marks the given reply as rejected

0 commit comments

Comments
 (0)