diff options
author | 2024-02-18 10:49:40 +0100 | |
---|---|---|
committer | 2024-02-18 09:49:40 +0000 | |
commit | 40f9eefc2153ee8811abb750e07064c4f98f549c (patch) | |
tree | bc0c26490dea9442025a43833b2c56a831f83ba4 /internal/federation/dereferencing/thread.go | |
parent | [chore] Disable Move API endpoints for now until Move is fully implemented in... (diff) | |
download | gotosocial-40f9eefc2153ee8811abb750e07064c4f98f549c.tar.xz |
[bugfix] Fix dereferencing ancestors on new status create (#2652)
* [bugfix] Pass `latest` to dereferenceThread instead of barebones status
* only mark status orphaned if visibility suggests parent is really deleted
* tone down "not deref'd" warnings, since they represent a legit visibility situation
* remove FAQ entry for "status not deref'd yet"
Diffstat (limited to 'internal/federation/dereferencing/thread.go')
-rw-r--r-- | internal/federation/dereferencing/thread.go | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/internal/federation/dereferencing/thread.go b/internal/federation/dereferencing/thread.go index 2814c0e7d..28f7ffa8a 100644 --- a/internal/federation/dereferencing/thread.go +++ b/internal/federation/dereferencing/thread.go @@ -124,9 +124,34 @@ func (d *Dereferencer) DereferenceStatusAncestors(ctx context.Context, username // Check for a returned HTTP code via error. switch code := gtserror.StatusCode(err); { - // Status codes 404 and 410 incicate the status does not exist anymore. - // Gone (410) is the preferred for deletion, but we accept NotFound too. - case code == http.StatusNotFound || code == http.StatusGone: + // 404 may indicate deletion, but can also + // indicate that we don't have permission to + // view the status (it's followers-only and + // we don't follow, for example). + case code == http.StatusNotFound: + // If this reply is followers-only or stricter, + // we can safely assume the status it replies + // to is also followers only or stricter. + // + // In this case we should leave the inReplyTo + // URI in place for visibility filtering, + // and just return since we can go no further. + if status.Visibility == gtsmodel.VisibilityFollowersOnly || + status.Visibility == gtsmodel.VisibilityMutualsOnly || + status.Visibility == gtsmodel.VisibilityDirect { + return nil + } + + // If the reply is public or unlisted then + // likely the replied-to status is/was public + // or unlisted and has indeed been deleted, + // fall through to the Gone case to clean up. + fallthrough + + // Gone (410) definitely indicates deletion. + // Update the status to remove references to + // the now-gone parent. + case code == http.StatusGone: l.Trace("status orphaned") current.InReplyToID = "" current.InReplyToURI = "" |