about summary refs log tree commit diff
path: root/app/services/update_status_service.rb
diff options
context:
space:
mode:
authorFire Demon <firedemon@creature.cafe>2020-08-06 18:05:18 -0500
committerFire Demon <firedemon@creature.cafe>2020-08-30 05:45:17 -0500
commit7f20d94d252f372821c2d476e69416a0bfce9dae (patch)
tree6cc4aaea89e2d700187a5339c5fc31c5ec06432f /app/services/update_status_service.rb
parent8a37068c79da7b0f1b7cf89182d7321f271cd2d9 (diff)
[Major Bug] Fix processing and removal of removed tags in updated posts
Diffstat (limited to 'app/services/update_status_service.rb')
-rw-r--r--app/services/update_status_service.rb9
1 files changed, 2 insertions, 7 deletions
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)