about summary refs log tree commit diff
path: root/app/services/resolve_url_service.rb
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2018-08-17 17:43:54 +0200
committerThibaut Girka <thib@sitedethib.com>2018-08-17 17:43:54 +0200
commit280d7b1df8566239f15130d8bf1e0e2c1d467fc0 (patch)
tree7903e071b0013fb15dcc5a74f6143239dcbaa2c2 /app/services/resolve_url_service.rb
parent4a6bc2482a26aa0441485ca360a3d3c0eeea7fe4 (diff)
parent59f7f4c923494bb8dd6f2881a1610c7b51240d9c (diff)
Merge branch 'master' into glitch-soc/merge-upstream
Conflicts:
	app/models/status.rb
	db/migrate/20180528141303_fix_accounts_unique_index.rb
	db/schema.rb

Resolved by taking upstream changes (no real conflicts, just glitch-soc
specific code too close to actual changes).
Diffstat (limited to 'app/services/resolve_url_service.rb')
-rw-r--r--app/services/resolve_url_service.rb10
1 files changed, 8 insertions, 2 deletions
diff --git a/app/services/resolve_url_service.rb b/app/services/resolve_url_service.rb
index a068c1ed8..1db1917e2 100644
--- a/app/services/resolve_url_service.rb
+++ b/app/services/resolve_url_service.rb
@@ -2,11 +2,13 @@
 
 class ResolveURLService < BaseService
   include JsonLdHelper
+  include Authorization
 
   attr_reader :url
 
-  def call(url)
+  def call(url, on_behalf_of: nil)
     @url = url
+    @on_behalf_of = on_behalf_of
 
     return process_local_url if local_url?
 
@@ -84,6 +86,10 @@ class ResolveURLService < BaseService
 
   def check_local_status(status)
     return if status.nil?
-    status if status.public_visibility? || status.unlisted_visibility?
+    authorize_with @on_behalf_of, status, :show?
+    status
+  rescue Mastodon::NotPermittedError
+    # Do not disclose the existence of status the user is not authorized to see
+    nil
   end
 end