diff options
Diffstat (limited to 'app/controllers/api')
-rw-r--r-- | app/controllers/api/oembed_controller.rb | 21 | ||||
-rw-r--r-- | app/controllers/api/v1/statuses_controller.rb | 4 |
2 files changed, 23 insertions, 2 deletions
diff --git a/app/controllers/api/oembed_controller.rb b/app/controllers/api/oembed_controller.rb new file mode 100644 index 000000000..4a591dc22 --- /dev/null +++ b/app/controllers/api/oembed_controller.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class Api::OembedController < ApiController + respond_to :json + + def show + @stream_entry = stream_entry_from_url(params[:url]) + @width = [300, params[:maxwidth].to_i].min + @height = [200, params[:maxheight].to_i].min + end + + private + + def stream_entry_from_url(url) + params = Rails.application.routes.recognize_path(url) + + raise ActiveRecord::NotFound unless params[:controller] == 'stream_entries' && params[:action] == 'show' + + StreamEntry.find(params[:id]) + end +end diff --git a/app/controllers/api/v1/statuses_controller.rb b/app/controllers/api/v1/statuses_controller.rb index a0b15cfbc..8b7690850 100644 --- a/app/controllers/api/v1/statuses_controller.rb +++ b/app/controllers/api/v1/statuses_controller.rb @@ -52,7 +52,7 @@ class Api::V1::StatusesController < ApiController end def create - @status = PostStatusService.new.call(current_user.account, params[:status], params[:in_reply_to_id].blank? ? nil : Status.find(params[:in_reply_to_id]), media_ids: params[:media_ids], sensitive: params[:sensitive]) + @status = PostStatusService.new.call(current_user.account, params[:status], params[:in_reply_to_id].blank? ? nil : Status.find(params[:in_reply_to_id]), media_ids: params[:media_ids], sensitive: params[:sensitive], unlisted: params[:unlisted]) render action: :show end @@ -73,7 +73,7 @@ class Api::V1::StatusesController < ApiController @reblogged_map = { @status.id => false } RemovalWorker.perform_async(reblog.id) - + render action: :show end |