diff --git a/app/services/resolve_url_service.rb b/app/services/resolve_url_service.rb index d8e795f3b0..2bcbbf200c 100644 --- a/app/services/resolve_url_service.rb +++ b/app/services/resolve_url_service.rb @@ -5,6 +5,7 @@ class ResolveURLService < BaseService include Authorization USERNAME_STATUS_RE = %r{/@(?#{Account::USERNAME_RE})/(?[0-9]+)\Z} + REMOTE_USERNAME_STATUS_RE = %r{/@(?#{Account::USERNAME_RE}@#{Account::USERNAME_RE})/(?[0-9]+)\Z} def call(url, on_behalf_of: nil) @url = url @@ -89,13 +90,17 @@ class ResolveURLService < BaseService def process_local_url recognized_params = Rails.application.routes.recognize_path(@url) - return unless recognized_params[:action] == 'show' - if recognized_params[:controller] == 'statuses' status = Status.find_by(id: recognized_params[:id]) check_local_status(status) elsif recognized_params[:controller] == 'accounts' Account.find_local(recognized_params[:username]) + elsif recognized_params[:controller] == 'home' && recognized_params[:action] == 'index' + parsed_url = Addressable::URI.parse(@url) + parsed_url.path.match(REMOTE_USERNAME_STATUS_RE) do |matched| + status = Status.find_by(id: matched[:status_id]) + check_local_status(status) + end end end