about summary refs log tree commit diff
path: root/app/services
diff options
context:
space:
mode:
authorFire Demon <firedemon@creature.cafe>2020-08-01 15:23:46 -0500
committerFire Demon <firedemon@creature.cafe>2020-08-30 05:45:16 -0500
commitc48f3c650af39b1108fb266d07c01d3e23be4620 (patch)
tree67ab21ae9ceb7e5730deb2e2dc51d254d91e3e88 /app/services
parent6869d85edebd142271ff7229f95b6ce42bd0c6cb (diff)
[Bug] Fix handling of mention in updates
Diffstat (limited to 'app/services')
-rw-r--r--app/services/update_status_service.rb11
1 files changed, 6 insertions, 5 deletions
diff --git a/app/services/update_status_service.rb b/app/services/update_status_service.rb
index 887384991..f250e5cb0 100644
--- a/app/services/update_status_service.rb
+++ b/app/services/update_status_service.rb
@@ -40,15 +40,12 @@ class UpdateStatusService < BaseService
 
     update_tags if @status.local?
     filter_tags
-    update_mentions
 
     @delete_payload         = Oj.dump(event: :delete, payload: @status.id.to_s)
     @deleted_tag_ids        = @status.tag_ids - @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) || [])
 
-    @new_mention_ids = @mentions.pluck(:id) - @status.mention_ids
-
     ApplicationRecord.transaction do
       @status.update!(@params)
 
@@ -56,9 +53,11 @@ class UpdateStatusService < BaseService
         ProcessCommandTagsService.new.call(@account, @status)
       else
         process_inline_images!
-        @status.save!
       end
 
+      update_mentions
+      @status.save!
+
       detach_deleted_tags
       attach_updated_tags
     end
@@ -113,7 +112,9 @@ class UpdateStatusService < BaseService
   end
 
   def update_mentions
-    @params[:text], @mentions = ResolveMentionsService.new.call(@status, text: @params[:text], mentions: @mentions)
+    @new_mention_ids = @mentions.pluck(:id) - @status.mention_ids
+    @status.text, @mentions = ResolveMentionsService.new.call(@status, mentions: @mentions)
+    @new_mention_ids |= (@mentions.pluck(:id) - @new_mention_ids)
   end
 
   def attach_updated_tags