FIX: correctly notifies subscribers with post_action_destroyer (#16084)

This commit is contained in:
Joffrey JAFFEUX
2022-03-03 09:49:36 +01:00
committed by GitHub
parent 3bf5692c72
commit a558c5bd30
2 changed files with 100 additions and 1 deletions

View File

@@ -48,15 +48,29 @@ class PostActionDestroyer
UserActionManager.post_action_destroyed(post_action)
PostActionNotifier.post_action_deleted(post_action)
result.success = true
result.post = @post.reload
notify_subscribers
result
end
protected
def self.notify_types
@notify_types ||= PostActionType.notify_flag_types.keys
end
def notify_subscribers
name = PostActionType.types[@post_action_type_id]
if name == :like
@post.publish_change_to_clients!(:liked, { likes_count: @post.like_count })
elsif self.class.notify_types.include?(name)
@post.publish_change_to_clients!(:acted)
end
end
def guardian
@guardian ||= Guardian.new(@destroyed_by)
end