Repository navigation
[2.x] fix(mentions): only link mentioned posts the viewer can see - #5454
Merged
Merged
Conversation
A post mention links to the mentioned post's discussion by slug, which carries the discussion's title. Mentioned posts were looked up without a visibility scope, so a mention of a post in a discussion the viewer can't see still rendered that discussion's title in the link. The lookup is now scoped by the request's actor, and the posts returned under mentionedBy only load mentions of posts the actor can see. Mentions of posts the actor can't see render as deleted. Renders without an actor, such as emails, follow core's rule for links to discussions: they only name what guests can see, and link the rest by discussion ID alone.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes proposed in this pull request:
A post mention links to the mentioned post's discussion by slug, and the slug carries the discussion's title. Mentioned posts were looked up without a visibility scope, so on the post show, discussion show and
include=mentionedByresponses a mention of a post in a discussion the viewer can't see (restricted tag, private, hidden) still carried that discussion's title in its link. The lookup is now scoped by the request's actor and mentions of posts the actor can't see render as deleted, as the post list already did. Renders without an actor, such as emails, follow core's rule for links to discussions: they only name what guests can see and link the rest by discussion ID alone.Reviewers should focus on:
/d/<id>/<number>instead of/d/<id>-<slug>/<number>, rather than becoming "deleted".LooksUpMentionedModels::mentionedModels()now also takes a closure, so the scoped query (and its permission lookup) is only built when there is something to look up;MentionRenderingQueriesTestpins that.mentionsPostsrelation is still trusted; every eager load in the monorepo is scoped (core's eager-load scoping, andmentionedBy's nested load now explicitly).Necessity
Confirmed
yarn testinjs/).composer test).