]> cat aescling's git repositories - mastodon.git/commitdiff
Fix already-known remote private toots not being searchable by URL (#12336)
authorThibG <thib@sitedethib.com>
Sun, 10 Nov 2019 22:04:48 +0000 (23:04 +0100)
committerEugen Rochko <eugen@zeonfederated.com>
Sun, 10 Nov 2019 22:04:48 +0000 (00:04 +0200)
* 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`

app/services/resolve_url_service.rb

index aa883597a467e3d133cc2627cff34aaac785ee0a..4e971a4b8e1743087809c609b15691fd72094463 100644 (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