about summary refs log tree commit diff
path: root/app/lib
diff options
context:
space:
mode:
authorStarfall <us@starfall.systems>2022-08-26 18:09:33 -0500
committerStarfall <us@starfall.systems>2022-08-26 18:09:33 -0500
commitb581e6b6d4a5ba9ed4ae17427b7f2d5d158be4e5 (patch)
tree06c3f6859d5cee4794d678a0aa57d15c31036ce4 /app/lib
parent3871928aa4f660cdf1a0c451ac3396052b59ddea (diff)
parent978dd7e73c911441503ff803ffdce544ce50a33d (diff)
Merge remote-tracking branch 'glitch/main'
Diffstat (limited to 'app/lib')
-rw-r--r--app/lib/importer/statuses_index_importer.rb2
-rw-r--r--app/lib/request.rb18
2 files changed, 16 insertions, 4 deletions
diff --git a/app/lib/importer/statuses_index_importer.rb b/app/lib/importer/statuses_index_importer.rb
index 7c6532560..5b5153d5c 100644
--- a/app/lib/importer/statuses_index_importer.rb
+++ b/app/lib/importer/statuses_index_importer.rb
@@ -84,6 +84,6 @@ class Importer::StatusesIndexImporter < Importer::BaseImporter
   end
 
   def local_statuses_scope
-    Status.local.select('id, coalesce(reblog_of_id, id) as status_id')
+    Status.local.select('"statuses"."id", COALESCE("statuses"."reblog_of_id", "statuses"."id") AS status_id')
   end
 end
diff --git a/app/lib/request.rb b/app/lib/request.rb
index 4289da933..f5123d776 100644
--- a/app/lib/request.rb
+++ b/app/lib/request.rb
@@ -31,7 +31,7 @@ class Request
     @url         = Addressable::URI.parse(url).normalize
     @http_client = options.delete(:http_client)
     @options     = options.merge(socket_class: use_proxy? ? ProxySocket : Socket)
-    @options     = @options.merge(Rails.configuration.x.http_client_proxy) if use_proxy?
+    @options     = @options.merge(proxy_url) if use_proxy?
     @headers     = {}
 
     raise Mastodon::HostValidationError, 'Instance does not support hidden service connections' if block_hidden_service?
@@ -141,11 +141,23 @@ class Request
   end
 
   def use_proxy?
-    Rails.configuration.x.http_client_proxy.present?
+    proxy_url.present?
+  end
+
+  def proxy_url
+    if hidden_service? && Rails.configuration.x.http_client_hidden_proxy.present?
+      Rails.configuration.x.http_client_hidden_proxy
+    else
+      Rails.configuration.x.http_client_proxy
+    end
   end
 
   def block_hidden_service?
-    !Rails.configuration.x.access_to_hidden_service && /\.(onion|i2p)$/.match?(@url.host)
+    !Rails.configuration.x.access_to_hidden_service && hidden_service?
+  end
+
+  def hidden_service?
+    /\.(onion|i2p)$/.match?(@url.host)
   end
 
   module ClientLimit