Browse Source

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

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

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

* Fix searching by `id` field instead of `uri`
master
ThibG 4 years ago
committed by Eugen Rochko
parent
commit
0d5f3ae331
1 changed files with 6 additions and 0 deletions
  1. +6
    -0
      app/services/resolve_url_service.rb

+ 6
- 0
app/services/resolve_url_service.rb View File

@ -24,6 +24,12 @@ class ResolveURLService < BaseService
status = FetchRemoteStatusService.new.call(resource_url, body, protocol)
authorize_with @on_behalf_of, status, :show? unless status.nil?
status
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(uri: @url) || Status.find_by(url: @url)
authorize_with @on_behalf_of, status, :show? unless status.nil?
status
end
end

Loading…
Cancel
Save