0
0
Fork 0

Changing the use of config constants to the Rails configuration object

This commit is contained in:
Eugen Rochko 2016-02-29 20:06:39 +01:00
parent 0e8f59c16f
commit 23d08c6749
11 changed files with 17 additions and 17 deletions

View file

@ -7,7 +7,7 @@ class XrdController < ApplicationController
def webfinger
@account = Account.find_by!(username: username_from_resource, domain: nil)
@canonical_account_uri = "acct:#{@account.username}@#{LOCAL_DOMAIN}"
@canonical_account_uri = "acct:#{@account.username}@#{Rails.configuration.x.local_domain}"
@magic_key = pem_to_magic_key(@account.keypair.public_key)
rescue ActiveRecord::RecordNotFound
render nothing: true, status: 404

View file

@ -1,6 +1,6 @@
module ApplicationHelper
def unique_tag(date, id, type)
"tag:#{LOCAL_DOMAIN},#{date.strftime('%Y-%m-%d')}:objectId=#{id}:objectType=#{type}"
"tag:#{Rails.configuration.x.local_domain},#{date.strftime('%Y-%m-%d')}:objectId=#{id}:objectType=#{type}"
end
def unique_tag_to_local_id(tag, expected_type)
@ -9,6 +9,6 @@ module ApplicationHelper
end
def local_id?(id)
id.start_with?("tag:#{LOCAL_DOMAIN}")
id.start_with?("tag:#{Rails.configuration.x.local_domain}")
end
end

View file

@ -9,7 +9,7 @@ class FollowService < BaseService
follow = source_account.follow!(target_account)
send_interaction_service.(follow.stream_entry, target_account)
source_account.ping!(account_url(account, format: 'atom'), [HUB_URL])
source_account.ping!(account_url(account, format: 'atom'), [Rails.configuration.x.hub_url])
end
private

View file

@ -7,7 +7,7 @@ class PostStatusService < BaseService
def call(account, text, in_reply_to = nil)
status = account.statuses.create!(text: text, thread: in_reply_to)
process_mentions_service.(status)
account.ping!(account_url(account, format: 'atom'), [HUB_URL])
account.ping!(account_url(account, format: 'atom'), [Rails.configuration.x.hub_url])
status
end

View file

@ -38,7 +38,7 @@ class ProcessFeedService < BaseService
href = Addressable::URI.parse(mention_link.attribute('href').value)
if href.host == LOCAL_DOMAIN
if href.host == Rails.configuration.x.local_domain
mentioned_account = Account.find_by(username: href.path.gsub('/users/', ''), domain: nil)
unless mentioned_account.nil?

View file

@ -5,7 +5,7 @@ class ReblogService < BaseService
# @return [Status]
def call(account, reblogged_status)
reblog = account.statuses.create!(reblog: reblogged_status, text: '')
account.ping!(account_url(account, format: 'atom'), [HUB_URL])
account.ping!(account_url(account, format: 'atom'), [Rails.configuration.x.hub_url])
return reblog if reblogged_status.local?
send_interaction_service.(reblog.stream_entry, reblogged_status.account)
reblog

View file

@ -12,7 +12,7 @@ Nokogiri::XML::Builder.new do |xml|
link_alternate xml, url_for_target(@account)
link_self xml, account_url(@account, format: 'atom')
link_hub xml, HUB_URL
link_hub xml, Rails.configuration.x.hub_url
link_salmon xml, api_salmon_url(@account.id)
@account.stream_entries.order('id desc').each do |stream_entry|

View file

@ -1,9 +1,9 @@
Nokogiri::XML::Builder.new do |xml|
entry(xml, true) do
author(xml) do
include_author xml, @entry.account
include_author xml, @stream_entry.account
end
include_entry xml, @entry
include_entry xml, @stream_entry
end
end.to_xml