about summary refs log tree commit diff
path: root/app/controllers/api
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2017-01-20 01:00:14 +0100
committerEugen Rochko <eugen@zeonfederated.com>2017-01-20 01:00:14 +0100
commitf0de621e76b5a5ba3f7e67bd88c0183aac22b985 (patch)
tree06ecec4ca807eadc7ec743d64074fb9030e172f7 /app/controllers/api
parent8d0284f8d9bc22a6dd3bad1054fd8d78cbf32060 (diff)
Fix #463 - Fetch and display previews of URLs using OpenGraph tags
Diffstat (limited to 'app/controllers/api')
-rw-r--r--app/controllers/api/v1/statuses_controller.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/app/controllers/api/v1/statuses_controller.rb b/app/controllers/api/v1/statuses_controller.rb
index c661d81c1..37ed5e6dd 100644
--- a/app/controllers/api/v1/statuses_controller.rb
+++ b/app/controllers/api/v1/statuses_controller.rb
@@ -3,8 +3,8 @@
 class Api::V1::StatusesController < ApiController
   before_action -> { doorkeeper_authorize! :read }, except: [:create, :destroy, :reblog, :unreblog, :favourite, :unfavourite]
   before_action -> { doorkeeper_authorize! :write }, only:  [:create, :destroy, :reblog, :unreblog, :favourite, :unfavourite]
-  before_action :require_user!, except: [:show, :context, :reblogged_by, :favourited_by]
-  before_action :set_status, only:      [:show, :context, :reblogged_by, :favourited_by]
+  before_action :require_user!, except: [:show, :context, :card, :reblogged_by, :favourited_by]
+  before_action :set_status, only:      [:show, :context, :card, :reblogged_by, :favourited_by]
 
   respond_to :json
 
@@ -21,6 +21,10 @@ class Api::V1::StatusesController < ApiController
     set_counters_maps(statuses)
   end
 
+  def card
+    @card = PreviewCard.find_by!(status: @status)
+  end
+
   def reblogged_by
     results   = @status.reblogs.paginate_by_max_id(DEFAULT_ACCOUNTS_LIMIT, params[:max_id], params[:since_id])
     accounts  = Account.where(id: results.map(&:account_id)).map { |a| [a.id, a] }.to_h