diff options
author | ThibG <thib@sitedethib.com> | 2020-03-28 17:59:45 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-28 17:59:45 +0100 |
commit | 0d117c106aa72f78dd5cdd371849dd8ce3120198 (patch) | |
tree | 756c9a48d18fde716a6f57553a32d5f6e548d2b6 /app/controllers/api/v1 | |
parent | 7ddbbdea6d4591e6cfe032a0dd212703776e5bb4 (diff) |
Fix 404 and 410 API errors being silently discarded in WebUI (#13279)
* Fix 404 and 410 API errors being silently discarded in WebUI Fixes #13278 * Return more appropriate error when user replies to a deleted toot * Please CodeClimate * Fix 404/410 errors on fetching account timelines & identity proofs * Refactor error handling * Move error message string to statuses.errors
Diffstat (limited to 'app/controllers/api/v1')
-rw-r--r-- | app/controllers/api/v1/statuses_controller.rb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/app/controllers/api/v1/statuses_controller.rb b/app/controllers/api/v1/statuses_controller.rb index 2f55e95fd..93a253cbb 100644 --- a/app/controllers/api/v1/statuses_controller.rb +++ b/app/controllers/api/v1/statuses_controller.rb @@ -7,6 +7,7 @@ class Api::V1::StatusesController < Api::BaseController before_action -> { doorkeeper_authorize! :write, :'write:statuses' }, only: [:create, :destroy] before_action :require_user!, except: [:show, :context] before_action :set_status, only: [:show, :context] + before_action :set_thread, only: [:create] override_rate_limit_headers :create, family: :statuses @@ -36,7 +37,7 @@ class Api::V1::StatusesController < Api::BaseController def create @status = PostStatusService.new.call(current_user.account, text: status_params[:status], - thread: status_params[:in_reply_to_id].blank? ? nil : Status.find(status_params[:in_reply_to_id]), + thread: @thread, media_ids: status_params[:media_ids], sensitive: status_params[:sensitive], spoiler_text: status_params[:spoiler_text], @@ -69,6 +70,12 @@ class Api::V1::StatusesController < Api::BaseController raise ActiveRecord::RecordNotFound end + def set_thread + @thread = status_params[:in_reply_to_id].blank? ? nil : Status.find(status_params[:in_reply_to_id]) + rescue ActiveRecord::RecordNotFound + render json: { error: I18n.t('statuses.errors.in_reply_not_found') }, status: 404 + end + def status_params params.permit( :status, |