From 7f20d94d252f372821c2d476e69416a0bfce9dae Mon Sep 17 00:00:00 2001 From: Fire Demon Date: Thu, 6 Aug 2020 18:05:18 -0500 Subject: [Major Bug] Fix processing and removal of removed tags in updated posts --- app/services/update_status_service.rb | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'app') diff --git a/app/services/update_status_service.rb b/app/services/update_status_service.rb index f250e5cb0..05586aa1b 100644 --- a/app/services/update_status_service.rb +++ b/app/services/update_status_service.rb @@ -39,10 +39,9 @@ class UpdateStatusService < BaseService (@params[:edited] ||= 1 + @status.edited) if @params[:published].presence || @status.published? update_tags if @status.local? - filter_tags @delete_payload = Oj.dump(event: :delete, payload: @status.id.to_s) - @deleted_tag_ids = @status.tag_ids - @tags.pluck(:id) + @deleted_tag_ids = @status.tags.pluck(:id) - @tags.pluck(:id) @deleted_tag_names = @status.tags.pluck(:name) - @tags.pluck(:name) @deleted_attachment_ids = @status.media_attachment_ids - (@params[:media_attachment_ids] || @params[:media_attachments]&.pluck(:id) || []) @@ -80,7 +79,7 @@ class UpdateStatusService < BaseService end def detach_deleted_tags - @status.tags.where(id: @deleted_tag_ids).destroy_all if @deleted_tag_ids.present? + @status.tags -= Tag.where(id: @deleted_tag_ids) if @deleted_tag_ids.present? end def prune_tags @@ -107,10 +106,6 @@ class UpdateStatusService < BaseService @tags |= @status.tags.where.not(id: old_explicit_tags.select(:id)) end - def filter_tags - @tags.select! { |tag| tag =~ /\A(#{Tag::HASHTAG_NAME_RE})\z/i } - end - def update_mentions @new_mention_ids = @mentions.pluck(:id) - @status.mention_ids @status.text, @mentions = ResolveMentionsService.new.call(@status, mentions: @mentions) -- cgit