From cedcece0ccba626d97a910f2e3fecf93c2729ca4 Mon Sep 17 00:00:00 2001 From: Claire Date: Wed, 5 Oct 2022 00:16:40 +0200 Subject: [PATCH] Fix deleted pinned posts potentially counting towards the pinned posts limit (#19005) Fixes #18938 --- app/controllers/api/v1/statuses_controller.rb | 1 + app/services/remove_status_service.rb | 2 ++ 2 files changed, 3 insertions(+) diff --git a/app/controllers/api/v1/statuses_controller.rb b/app/controllers/api/v1/statuses_controller.rb index 9270117dad..1cc5aa32ee 100644 --- a/app/controllers/api/v1/statuses_controller.rb +++ b/app/controllers/api/v1/statuses_controller.rb @@ -77,6 +77,7 @@ class Api::V1::StatusesController < Api::BaseController authorize @status, :destroy? @status.discard + StatusPin.find_by(status: @status)&.destroy @status.account.statuses_count = @status.account.statuses_count - 1 json = render_to_body json: @status, serializer: REST::StatusSerializer, source_requested: true diff --git a/app/services/remove_status_service.rb b/app/services/remove_status_service.rb index 8dc521eedf..f9fdea2cb0 100644 --- a/app/services/remove_status_service.rb +++ b/app/services/remove_status_service.rb @@ -21,6 +21,8 @@ class RemoveStatusService < BaseService with_lock("distribute:#{@status.id}") do @status.discard + StatusPin.find_by(status: @status)&.destroy + remove_from_self if @account.local? remove_from_followers remove_from_lists