Browse Source

Better comparison of "local" domain

closed-social-glitch-2
Eugen Rochko 7 years ago
parent
commit
15d01a5e08
4 changed files with 7 additions and 3 deletions
  1. +1
    -1
      app/controllers/api/v1/follows_controller.rb
  2. +4
    -0
      app/lib/tag_manager.rb
  3. +1
    -1
      app/services/follow_remote_account_service.rb
  4. +1
    -1
      app/services/process_feed_service.rb

+ 1
- 1
app/controllers/api/v1/follows_controller.rb View File

@ -5,7 +5,7 @@ class Api::V1::FollowsController < ApiController
def create
raise ActiveRecord::RecordNotFound if params[:uri].blank?
@account = FollowService.new.call(current_user.account, params[:uri]).try(:target_account)
@account = FollowService.new.call(current_user.account, params[:uri].strip).try(:target_account)
render action: :show
end
end

+ 4
- 0
app/lib/tag_manager.rb View File

@ -17,6 +17,10 @@ class TagManager
id.start_with?("tag:#{Rails.configuration.x.local_domain}")
end
def local_domain?(domain)
domain.nil? || domain.gsub(/[\/]/, '') == Rails.configuration.x.local_domain
end
def uri_for(target)
return target.uri if target.respond_to?(:local?) && !target.local?

+ 1
- 1
app/services/follow_remote_account_service.rb View File

@ -7,7 +7,7 @@ class FollowRemoteAccountService < BaseService
def call(uri)
username, domain = uri.split('@')
return Account.find_local(username) if domain == Rails.configuration.x.local_domain || domain.nil?
return Account.find_local(username) if TagManager.instance.local_domain?(domain)
account = Account.find_remote(username, domain)

+ 1
- 1
app/services/process_feed_service.rb View File

@ -63,7 +63,7 @@ class ProcessFeedService < BaseService
href = Addressable::URI.parse(href_val)
if href.host == Rails.configuration.x.local_domain
if TagManager.instance.local_domain?(href.host)
# A local user is mentioned
mentioned_account = Account.find_local(href.path.gsub('/users/', ''))

Loading…
Cancel
Save