about summary refs log tree commit diff
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2022-10-05 00:16:40 +0200
committerGitHub <noreply@github.com>2022-10-05 00:16:40 +0200
commitcedcece0ccba626d97a910f2e3fecf93c2729ca4 (patch)
tree08fd1eb885aa3356f8dec77baa51fabc9c5a6a6d
parent02ba9cfa35c7b2285950955619ae3431391e9625 (diff)
Fix deleted pinned posts potentially counting towards the pinned posts limit (#19005)
Fixes #18938
-rw-r--r--app/controllers/api/v1/statuses_controller.rb1
-rw-r--r--app/services/remove_status_service.rb2
2 files changed, 3 insertions, 0 deletions
diff --git a/app/controllers/api/v1/statuses_controller.rb b/app/controllers/api/v1/statuses_controller.rb
index 9270117da..1cc5aa32e 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 8dc521eed..f9fdea2cb 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