diff options
author | Fire Demon <firedemon@creature.cafe> | 2020-11-12 17:42:53 -0600 |
---|---|---|
committer | Fire Demon <firedemon@creature.cafe> | 2020-11-14 17:39:08 -0600 |
commit | f60e0b62f4e5300645f235983e5b75bcf16b370d (patch) | |
tree | 0c437e6600b7a8bdf806d63fa76ce751bbe66d58 /app/services/resolve_url_service.rb | |
parent | ec3abd7c87116ad2df5b1da5701afe68a7f74844 (diff) | |
parent | 265b26489a9214a6c98a4dfa88f08ce490211ebc (diff) |
Merge remote-tracking branch 'upstream/master' into merge-glitch
Diffstat (limited to 'app/services/resolve_url_service.rb')
-rw-r--r-- | app/services/resolve_url_service.rb | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/app/services/resolve_url_service.rb b/app/services/resolve_url_service.rb index bac41f961..8e7ae82de 100644 --- a/app/services/resolve_url_service.rb +++ b/app/services/resolve_url_service.rb @@ -34,7 +34,17 @@ class ResolveURLService < BaseService # 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) + uris = [@url] + + # We don't have an index on `url`, so try guessing the `uri` from `url` + parsed_url = Addressable::URI.parse(@url) + parsed_url.path.match(%r{/@(?<username>#{Account::USERNAME_RE})/(?<status_id>[0-9]+)\Z}) do |matched| + parsed_url.path = "/users/#{matched[:username]}/statuses/#{matched[:status_id]}" + uris << parsed_url.to_s + end + + status = Status.find_by(uri: uris) + authorize_with @on_behalf_of, status, :show? unless status.nil? status rescue Mastodon::NotPermittedError |