From c43f4cd3bbeaf4a6db5aa39477bb0c708422b49b Mon Sep 17 00:00:00 2001 From: ThibG Date: Sat, 21 Nov 2020 06:18:09 +0100 Subject: [PATCH 01/17] Fix not being able to unfavorite toots one has lost access to (#15192) Fixes #15191 --- .../api/v1/statuses/favourites_controller.rb | 15 +++++++++-- .../v1/statuses/favourites_controller_spec.rb | 25 +++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/v1/statuses/favourites_controller.rb b/app/controllers/api/v1/statuses/favourites_controller.rb index 7afa822ed8..2e21ce6a06 100644 --- a/app/controllers/api/v1/statuses/favourites_controller.rb +++ b/app/controllers/api/v1/statuses/favourites_controller.rb @@ -5,7 +5,7 @@ class Api::V1::Statuses::FavouritesController < Api::BaseController before_action -> { doorkeeper_authorize! :write, :'write:favourites' } before_action :require_user! - before_action :set_status + before_action :set_status, only: [:create] def create FavouriteService.new.call(current_account, @status) @@ -13,8 +13,19 @@ class Api::V1::Statuses::FavouritesController < Api::BaseController end def destroy - UnfavouriteWorker.perform_async(current_account.id, @status.id) + fav = current_account.favourites.find_by(status_id: params[:status_id]) + + if fav + @status = fav.status + UnfavouriteWorker.perform_async(current_account.id, @status.id) + else + @status = Status.find(params[:status_id]) + authorize @status, :show? + end + render json: @status, serializer: REST::StatusSerializer, relationships: StatusRelationshipsPresenter.new([@status], current_account.id, favourites_map: { @status.id => false }) + rescue Mastodon::NotPermittedError + not_found end private diff --git a/spec/controllers/api/v1/statuses/favourites_controller_spec.rb b/spec/controllers/api/v1/statuses/favourites_controller_spec.rb index 6e947f5d2b..4716ecae3c 100644 --- a/spec/controllers/api/v1/statuses/favourites_controller_spec.rb +++ b/spec/controllers/api/v1/statuses/favourites_controller_spec.rb @@ -82,6 +82,31 @@ describe Api::V1::Statuses::FavouritesController do end end + context 'with public status when blocked by its author' do + let(:status) { Fabricate(:status) } + + before do + FavouriteService.new.call(user.account, status) + status.account.block!(user.account) + post :destroy, params: { status_id: status.id } + end + + it 'returns http success' do + expect(response).to have_http_status(200) + end + + it 'updates the favourite attribute' do + expect(user.account.favourited?(status)).to be false + end + + it 'returns json with updated attributes' do + hash_body = body_as_json + + expect(hash_body[:id]).to eq status.id.to_s + expect(hash_body[:favourited]).to be false + end + end + context 'with private status that was not favourited' do let(:status) { Fabricate(:status, visibility: :private) } From 66832cbf33c0800f53bc0beb5e684053259e2b36 Mon Sep 17 00:00:00 2001 From: ThibG Date: Sat, 21 Nov 2020 21:27:00 +0100 Subject: [PATCH 02/17] Undo outgoing follows when suspending a remote account (#15188) --- app/services/delete_account_service.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/services/delete_account_service.rb b/app/services/delete_account_service.rb index 778d064de0..9cb80c95ae 100644 --- a/app/services/delete_account_service.rb +++ b/app/services/delete_account_service.rb @@ -56,6 +56,7 @@ class DeleteAccountService < BaseService @options[:skip_activitypub] = true if @options[:skip_side_effects] reject_follows! + undo_follows! purge_user! purge_profile! purge_content! @@ -79,6 +80,20 @@ class DeleteAccountService < BaseService end end + def undo_follows! + return if @account.local? || !@account.activitypub? || @options[:skip_activitypub] + + # When deleting a remote account, the account obviously doesn't + # actually become deleted on its origin server, but following relationships + # are severed on our end. Therefore, make the remote server aware that the + # follow relationships are severed to avoid confusion and potential issues + # if the remote account gets un-suspended. + + ActivityPub::DeliveryWorker.push_bulk(Follow.where(target_account: @account)) do |follow| + [Oj.dump(serialize_payload(follow, ActivityPub::UndoFollowSerializer)), follow.account_id, @account.inbox_url] + end + end + def purge_user! return if !@account.local? || @account.user.nil? From f970e1fab6ca5d2334604b86d6e472e64510ea40 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sat, 21 Nov 2020 23:19:04 +0100 Subject: [PATCH 03/17] Fix hardcoded frame rate for frame by frame video navigation in web UI (#15198) --- app/javascript/mastodon/components/status.js | 1 + .../status/components/detailed_status.js | 1 + .../ui/components/focal_point_modal.js | 1 + .../features/ui/components/video_modal.js | 1 + .../mastodon/features/video/index.js | 18 +++++++++++++++++- 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/app/javascript/mastodon/components/status.js b/app/javascript/mastodon/components/status.js index f4ed25f1eb..8f288bdf9b 100644 --- a/app/javascript/mastodon/components/status.js +++ b/app/javascript/mastodon/components/status.js @@ -391,6 +391,7 @@ class Status extends ImmutablePureComponent { {Component => (