about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--app/controllers/xrd_controller.rb2
-rw-r--r--app/helpers/application_helper.rb4
-rw-r--r--app/services/follow_service.rb2
-rw-r--r--app/services/post_status_service.rb2
-rw-r--r--app/services/process_feed_service.rb2
-rw-r--r--app/services/reblog_service.rb2
-rw-r--r--app/views/accounts/show.atom.ruby2
-rw-r--r--app/views/stream_entries/show.atom.ruby4
-rw-r--r--config/initializers/ostatus.rb10
-rw-r--r--spec/helpers/application_helper_spec.rb2
-rw-r--r--spec/services/reblog_service_spec.rb2
11 files changed, 17 insertions, 17 deletions
diff --git a/app/controllers/xrd_controller.rb b/app/controllers/xrd_controller.rb
index 28e0a47b8..2946e9999 100644
--- a/app/controllers/xrd_controller.rb
+++ b/app/controllers/xrd_controller.rb
@@ -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
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 5d696316d..e683d9f51 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -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
diff --git a/app/services/follow_service.rb b/app/services/follow_service.rb
index b0bfdf4f2..785ae583f 100644
--- a/app/services/follow_service.rb
+++ b/app/services/follow_service.rb
@@ -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
diff --git a/app/services/post_status_service.rb b/app/services/post_status_service.rb
index aa25de4dc..388639175 100644
--- a/app/services/post_status_service.rb
+++ b/app/services/post_status_service.rb
@@ -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
 
diff --git a/app/services/process_feed_service.rb b/app/services/process_feed_service.rb
index f6584bbda..7d8563a58 100644
--- a/app/services/process_feed_service.rb
+++ b/app/services/process_feed_service.rb
@@ -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?
diff --git a/app/services/reblog_service.rb b/app/services/reblog_service.rb
index e3e091fa7..086f297f4 100644
--- a/app/services/reblog_service.rb
+++ b/app/services/reblog_service.rb
@@ -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
diff --git a/app/views/accounts/show.atom.ruby b/app/views/accounts/show.atom.ruby
index 12d2bb233..54f1185e4 100644
--- a/app/views/accounts/show.atom.ruby
+++ b/app/views/accounts/show.atom.ruby
@@ -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|
diff --git a/app/views/stream_entries/show.atom.ruby b/app/views/stream_entries/show.atom.ruby
index e0e089f46..a298f3269 100644
--- a/app/views/stream_entries/show.atom.ruby
+++ b/app/views/stream_entries/show.atom.ruby
@@ -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
diff --git a/config/initializers/ostatus.rb b/config/initializers/ostatus.rb
index 624ea9ca0..3cb17c718 100644
--- a/config/initializers/ostatus.rb
+++ b/config/initializers/ostatus.rb
@@ -1,7 +1,7 @@
-LOCAL_DOMAIN       = ENV['LOCAL_DOMAIN'] || 'localhost'
-HUB_URL            = ENV['HUB_URL']      || 'https://pubsubhubbub.superfeedr.com'
-CANONICAL_PROTOCOL = ENV['LOCAL_HTTPS'] == 'true' ? 'https://' : 'http://'
-
 Rails.application.configure do
-  config.action_mailer.default_url_options = { host: LOCAL_DOMAIN, protocol: CANONICAL_PROTOCOL }
+  config.x.local_domain = ENV['LOCAL_DOMAIN'] || 'localhost'
+  config.x.hub_url      = ENV['HUB_URL']      || 'https://pubsubhubbub.superfeedr.com'
+  config.x.use_https    = ENV['LOCAL_HTTPS'] == 'true'
+
+  config.action_mailer.default_url_options = { host: config.x.local_domain, protocol: config.x.use_https ? 'https://' : 'http://' }
 end
diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb
index b36954b78..c19f636ca 100644
--- a/spec/helpers/application_helper_spec.rb
+++ b/spec/helpers/application_helper_spec.rb
@@ -4,7 +4,7 @@ RSpec.describe ApplicationHelper, type: :helper do
   let(:local_domain) { 'local.tld' }
 
   before do
-    stub_const('LOCAL_DOMAIN', local_domain)
+    Rails.configuration.x.local_domain = local_domain
   end
 
   describe '#unique_tag' do
diff --git a/spec/services/reblog_service_spec.rb b/spec/services/reblog_service_spec.rb
index f12fdb837..25ea35e94 100644
--- a/spec/services/reblog_service_spec.rb
+++ b/spec/services/reblog_service_spec.rb
@@ -8,7 +8,7 @@ RSpec.describe ReblogService do
   subject { ReblogService.new }
 
   before do
-    stub_const('HUB_URL', 'http://hub.example.com')
+    Rails.configuration.x.hub_url = 'http://hub.example.com'
 
     stub_request(:post, 'http://hub.example.com')
     stub_request(:post, 'http://salmon.example.com')