From 0d117c106aa72f78dd5cdd371849dd8ce3120198 Mon Sep 17 00:00:00 2001 From: ThibG Date: Sat, 28 Mar 2020 17:59:45 +0100 Subject: 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 --- app/controllers/api/v1/statuses_controller.rb | 9 ++++++++- app/javascript/mastodon/actions/accounts.js | 3 +++ app/javascript/mastodon/actions/alerts.js | 4 ++-- app/javascript/mastodon/actions/identity_proofs.js | 1 + app/javascript/mastodon/actions/timelines.js | 1 + app/javascript/mastodon/middleware/errors.js | 2 +- 6 files changed, 16 insertions(+), 4 deletions(-) (limited to 'app') 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, diff --git a/app/javascript/mastodon/actions/accounts.js b/app/javascript/mastodon/actions/accounts.js index 4af36e998..cb2c682a4 100644 --- a/app/javascript/mastodon/actions/accounts.js +++ b/app/javascript/mastodon/actions/accounts.js @@ -396,6 +396,7 @@ export function fetchFollowersFail(id, error) { type: FOLLOWERS_FETCH_FAIL, id, error, + skipNotFound: true, }; }; @@ -482,6 +483,7 @@ export function fetchFollowingFail(id, error) { type: FOLLOWING_FETCH_FAIL, id, error, + skipNotFound: true, }; }; @@ -571,6 +573,7 @@ export function fetchRelationshipsFail(error) { type: RELATIONSHIPS_FETCH_FAIL, error, skipLoading: true, + skipNotFound: true, }; }; diff --git a/app/javascript/mastodon/actions/alerts.js b/app/javascript/mastodon/actions/alerts.js index cd36d8007..1670f9c10 100644 --- a/app/javascript/mastodon/actions/alerts.js +++ b/app/javascript/mastodon/actions/alerts.js @@ -34,11 +34,11 @@ export function showAlert(title = messages.unexpectedTitle, message = messages.u }; }; -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 }; } diff --git a/app/javascript/mastodon/actions/identity_proofs.js b/app/javascript/mastodon/actions/identity_proofs.js index 449debf61..103983956 100644 --- a/app/javascript/mastodon/actions/identity_proofs.js +++ b/app/javascript/mastodon/actions/identity_proofs.js @@ -27,4 +27,5 @@ export const fetchAccountIdentityProofsFail = (accountId, err) => ({ type: IDENTITY_PROOFS_ACCOUNT_FETCH_FAIL, accountId, err, + skipNotFound: true, }); diff --git a/app/javascript/mastodon/actions/timelines.js b/app/javascript/mastodon/actions/timelines.js index 054668655..cdd2111f8 100644 --- a/app/javascript/mastodon/actions/timelines.js +++ b/app/javascript/mastodon/actions/timelines.js @@ -149,6 +149,7 @@ export function expandTimelineFail(timeline, error, isLoadingMore) { timeline, error, skipLoading: !isLoadingMore, + skipNotFound: timeline.startsWith('account:'), }; }; diff --git a/app/javascript/mastodon/middleware/errors.js b/app/javascript/mastodon/middleware/errors.js index 3cebb42e0..0a65fd321 100644 --- a/app/javascript/mastodon/middleware/errors.js +++ b/app/javascript/mastodon/middleware/errors.js @@ -8,7 +8,7 @@ export default function errorsMiddleware() { const isFail = new RegExp(`${defaultFailSuffix}$`, 'g'); if (action.type.match(isFail)) { - dispatch(showAlertForError(action.error)); + dispatch(showAlertForError(action.error, action.skipNotFound)); } } -- cgit From 11169367e4a999b19cc9140be38bdb5a1f3bb144 Mon Sep 17 00:00:00 2001 From: Takeshi Umeda Date: Tue, 31 Mar 2020 03:32:34 +0900 Subject: Fix incorrect deletion of local accounts imported by overwriting (#13350) --- app/services/import_service.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/services/import_service.rb b/app/services/import_service.rb index 4ee431ea3..c0d741d57 100644 --- a/app/services/import_service.rb +++ b/app/services/import_service.rb @@ -64,7 +64,8 @@ class ImportService < BaseService end def import_relationships!(action, undo_action, overwrite_scope, limit, extra_fields = {}) - items = @data.take(limit).map { |row| [row['Account address']&.strip, Hash[extra_fields.map { |key, header| [key, row[header]&.strip] }]] }.reject { |(id, _)| id.blank? } + local_domain_suffix = "@#{Rails.configuration.x.local_domain}" + items = @data.take(limit).map { |row| [row['Account address']&.strip&.delete_suffix(local_domain_suffix), Hash[extra_fields.map { |key, header| [key, row[header]&.strip] }]] }.reject { |(id, _)| id.blank? } if @import.overwrite? presence_hash = items.each_with_object({}) { |(id, extra), mapping| mapping[id] = [true, extra] } -- cgit From be2f1597cf6b010a7ea0ffdc45550f87a7ae9dad Mon Sep 17 00:00:00 2001 From: "Mélanie Chauvel (ariasuni)" Date: Tue, 31 Mar 2020 12:39:50 +0200 Subject: Fix wrong color for ellipsis in boost confirmation dialog in Web UI (#13355) --- app/javascript/styles/mastodon/components.scss | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'app') diff --git a/app/javascript/styles/mastodon/components.scss b/app/javascript/styles/mastodon/components.scss index 7d3644d16..725f5c369 100644 --- a/app/javascript/styles/mastodon/components.scss +++ b/app/javascript/styles/mastodon/components.scss @@ -1028,13 +1028,11 @@ } .display-name { + color: $light-text-color; + strong { color: $inverted-text-color; } - - span { - color: $light-text-color; - } } .status__content { -- cgit From e4617c8ed87f5269566694f01554b5a9347691e5 Mon Sep 17 00:00:00 2001 From: Takeshi Umeda Date: Tue, 31 Mar 2020 19:43:42 +0900 Subject: Fix ImportsController param to permit :mode (#13347) --- app/controllers/settings/imports_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/controllers/settings/imports_controller.rb b/app/controllers/settings/imports_controller.rb index 38f2e39c1..7b8c4ae23 100644 --- a/app/controllers/settings/imports_controller.rb +++ b/app/controllers/settings/imports_controller.rb @@ -29,6 +29,6 @@ class Settings::ImportsController < Settings::BaseController end def import_params - params.require(:import).permit(:data, :type) + params.require(:import).permit(:data, :type, :mode) end end -- cgit From cf1fa73347c9ca2b1c4f14521e990feba7509e2e Mon Sep 17 00:00:00 2001 From: ThibG Date: Tue, 31 Mar 2020 14:10:18 +0200 Subject: Fix content warning being unnecessarily cleared when enabling/disabling CW (#13348) --- app/javascript/mastodon/reducers/compose.js | 1 - 1 file changed, 1 deletion(-) (limited to 'app') diff --git a/app/javascript/mastodon/reducers/compose.js b/app/javascript/mastodon/reducers/compose.js index c6653fe4c..e6e6d2ae1 100644 --- a/app/javascript/mastodon/reducers/compose.js +++ b/app/javascript/mastodon/reducers/compose.js @@ -261,7 +261,6 @@ export default function compose(state = initialState, action) { }); case COMPOSE_SPOILERNESS_CHANGE: return state.withMutations(map => { - map.set('spoiler_text', ''); map.set('spoiler', !state.get('spoiler')); map.set('idempotencyKey', uuid()); -- cgit From 1fb92037e432913902a5e5c8a5b673b036d84cb8 Mon Sep 17 00:00:00 2001 From: "Mélanie Chauvel (ariasuni)" Date: Tue, 31 Mar 2020 19:40:23 +0200 Subject: Improve toot clicking areas (#13327) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Make the area to the left “Show Thread” also expand the toot in Web UI * Clicking the left part of a conversation with the avatars now opens it in Web UI --- app/javascript/mastodon/components/status.js | 8 +------- app/javascript/mastodon/components/status_content.js | 14 ++++++++++++++ .../features/direct_timeline/components/conversation.js | 2 +- app/javascript/styles/mastodon/components.scss | 2 +- 4 files changed, 17 insertions(+), 9 deletions(-) (limited to 'app') diff --git a/app/javascript/mastodon/components/status.js b/app/javascript/mastodon/components/status.js index 0dc00cb98..075ee1b87 100644 --- a/app/javascript/mastodon/components/status.js +++ b/app/javascript/mastodon/components/status.js @@ -432,16 +432,10 @@ class Status extends ImmutablePureComponent { - + {media} - {showThread && status.get('in_reply_to_id') && status.get('in_reply_to_account_id') === status.getIn(['account', 'id']) && ( - - )} - diff --git a/app/javascript/mastodon/components/status_content.js b/app/javascript/mastodon/components/status_content.js index 5d921fd41..3200f2d82 100644 --- a/app/javascript/mastodon/components/status_content.js +++ b/app/javascript/mastodon/components/status_content.js @@ -20,6 +20,7 @@ export default class StatusContent extends React.PureComponent { static propTypes = { status: ImmutablePropTypes.map.isRequired, expanded: PropTypes.bool, + showThread: PropTypes.bool, onExpandedToggle: PropTypes.func, onClick: PropTypes.func, collapsable: PropTypes.bool, @@ -181,6 +182,7 @@ export default class StatusContent extends React.PureComponent { const hidden = this.props.onExpandedToggle ? !this.props.expanded : this.state.hidden; const renderReadMore = this.props.onClick && status.get('collapsed'); + const renderViewThread = this.props.showThread && status.get('in_reply_to_id') && status.get('in_reply_to_account_id') === status.getIn(['account', 'id']); const content = { __html: status.get('contentHtml') }; const spoilerContent = { __html: status.get('spoilerHtml') }; @@ -195,6 +197,12 @@ export default class StatusContent extends React.PureComponent { directionStyle.direction = 'rtl'; } + const showThreadButton = ( + + ); + const readMoreButton = (