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
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],
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,
};
};
-export function showAlertForError(error) {
+export function showAlertForError(error, skipNotFound = false) {
if (error.response) {
const { data, status, statusText, headers } = error.response;
- if (status === 404 || status === 410) {
+ if (skipNotFound && (status === 404 || status === 410)) {
// Skip these errors as they are reflected in the UI
return { type: ALERT_NOOP };
}
const isFail = new RegExp(`${defaultFailSuffix}$`, 'g');
if (action.type.match(isFail)) {
- dispatch(showAlertForError(action.error));
+ dispatch(showAlertForError(action.error, action.skipNotFound));
}
}
disallowed_hashtags:
one: 'contained a disallowed hashtag: %{tags}'
other: 'contained the disallowed hashtags: %{tags}'
+ errors:
+ in_reply_not_found: The status you are trying to reply to does not appear to exist.
language_detection: Automatically detect language
open_in_web: Open in web
over_character_limit: character limit of %{max} exceeded