Handle local_only param when creating statuses.

This commit is contained in:
Surinna Curtis 2017-12-17 04:57:44 +00:00
parent 578438b360
commit 920d25f8c9
2 changed files with 4 additions and 1 deletions

View File

@ -42,6 +42,7 @@ class Api::V1::StatusesController < Api::BaseController
@status = PostStatusService.new.call(current_user.account,
status_params[:status],
status_params[:in_reply_to_id].blank? ? nil : Status.find(status_params[:in_reply_to_id]),
local_only: status_params[:local_only],
media_ids: status_params[:media_ids],
sensitive: status_params[:sensitive],
spoiler_text: status_params[:spoiler_text],
@ -72,7 +73,7 @@ class Api::V1::StatusesController < Api::BaseController
end
def status_params
params.permit(:status, :in_reply_to_id, :sensitive, :spoiler_text, :visibility, media_ids: [])
params.permit(:status, :in_reply_to_id, :local_only, :sensitive, :spoiler_text, :visibility, media_ids: [])
end
def pagination_params(core_params)

View File

@ -6,6 +6,7 @@ class PostStatusService < BaseService
# @param [String] text Message
# @param [Status] in_reply_to Optional status to reply to
# @param [Hash] options
# @option [Boolean] :local_only
# @option [Boolean] :sensitive
# @option [String] :visibility
# @option [String] :spoiler_text
@ -25,6 +26,7 @@ class PostStatusService < BaseService
ApplicationRecord.transaction do
status = account.statuses.create!(text: text,
thread: in_reply_to,
local_only: options[:local_only],
sensitive: options[:sensitive],
spoiler_text: options[:spoiler_text] || '',
visibility: options[:visibility] || account.user&.setting_default_privacy,