Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix already-known remote private toots not being searchable by URL #12336

Merged

Conversation

ClearlyClaire
Copy link
Contributor

Whenever an URL search fails, and an account is provided, try getting a
private status matching that URL from database.

Drawbacks of this approach:

  • Only works for toots that are already known (but this should be fine in most cases, as in most cases, people who would have access to the toot would have followed the person and received already—this wouldn't be the case for significantly old toots, though), does not fetch them
  • While it shouldn't be the case in practice, the url attribute may not be unique, as that cannot be enforced without fetching it. Thus, a misbehaving server may cause an URL to resolve in non-deterministic ways. I can't see any reason for someone to do that, though.
  • The search may be slow, as there is no index on url.

Whenever an URL search fails, and an account is provided, try getting a
private status matching that URL from database.
elsif fetched_resource.nil? && @on_behalf_of.present?
# It may happen that the resource is a private toot, and thus not fetchable,
# but we can return the toot if we already know about it.
status = Status.find_by(id: @url) || Status.find_by(url: @url)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean uri instead of id?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

… yes

@Gargron Gargron merged commit 0d5f3ae into mastodon:master Nov 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants