about summary refs log tree commit diff
path: root/app/services
diff options
context:
space:
mode:
Diffstat (limited to 'app/services')
-rw-r--r--app/services/account_statuses_cleanup_service.rb2
-rw-r--r--app/services/activitypub/process_status_update_service.rb24
-rw-r--r--app/services/fan_out_on_write_service.rb12
-rw-r--r--app/services/follow_service.rb4
-rw-r--r--app/services/import_service.rb4
-rw-r--r--app/services/reblog_service.rb2
-rw-r--r--app/services/resolve_account_service.rb2
7 files changed, 29 insertions, 21 deletions
diff --git a/app/services/account_statuses_cleanup_service.rb b/app/services/account_statuses_cleanup_service.rb
index cbadecc63..3918b5ba4 100644
--- a/app/services/account_statuses_cleanup_service.rb
+++ b/app/services/account_statuses_cleanup_service.rb
@@ -15,7 +15,7 @@ class AccountStatusesCleanupService < BaseService
 
     account_policy.statuses_to_delete(budget, cutoff_id, account_policy.last_inspected).reorder(nil).find_each(order: :asc) do |status|
       status.discard
-      RemovalWorker.perform_async(status.id, redraft: false)
+      RemovalWorker.perform_async(status.id, { 'redraft' => false })
       num_deleted += 1
       last_deleted = status.id
     end
diff --git a/app/services/activitypub/process_status_update_service.rb b/app/services/activitypub/process_status_update_service.rb
index ed10a0063..977928127 100644
--- a/app/services/activitypub/process_status_update_service.rb
+++ b/app/services/activitypub/process_status_update_service.rb
@@ -10,6 +10,7 @@ class ActivityPub::ProcessStatusUpdateService < BaseService
     @status                    = status
     @account                   = status.account
     @media_attachments_changed = false
+    @poll_changed              = false
 
     # Only native types can be updated at the moment
     return if !expected_type? || already_updated_more_recently?
@@ -27,6 +28,9 @@ class ActivityPub::ProcessStatusUpdateService < BaseService
         end
 
         queue_poll_notifications!
+
+        next unless significant_changes?
+
         reset_preview_card!
         broadcast_updates!
       else
@@ -92,7 +96,7 @@ class ActivityPub::ProcessStatusUpdateService < BaseService
       # If for some reasons the options were changed, it invalidates all previous
       # votes, so we need to remove them
       if poll_parser.significantly_changes?(poll)
-        @media_attachments_changed = true
+        @poll_changed = true
         poll.votes.delete_all unless poll.new_record?
       end
 
@@ -107,7 +111,7 @@ class ActivityPub::ProcessStatusUpdateService < BaseService
       @status.poll_id = poll.id
     elsif previous_poll.present?
       previous_poll.destroy!
-      @media_attachments_changed = true
+      @poll_changed = true
       @status.poll_id = nil
     end
   end
@@ -117,7 +121,7 @@ class ActivityPub::ProcessStatusUpdateService < BaseService
     @status.spoiler_text = @status_parser.spoiler_text || ''
     @status.sensitive    = @account.sensitized? || @status_parser.sensitive || false
     @status.language     = @status_parser.language || detected_language
-    @status.edited_at    = @status_parser.edited_at || Time.now.utc
+    @status.edited_at    = @status_parser.edited_at || Time.now.utc if significant_changes?
 
     @status.save!
   end
@@ -227,12 +231,12 @@ class ActivityPub::ProcessStatusUpdateService < BaseService
   end
 
   def create_edit!
-    return unless @status.text_previously_changed? || @status.spoiler_text_previously_changed? || @media_attachments_changed
+    return unless significant_changes?
 
     @status_edit = @status.edits.create(
       text: @status.text,
       spoiler_text: @status.spoiler_text,
-      media_attachments_changed: @media_attachments_changed,
+      media_attachments_changed: @media_attachments_changed || @poll_changed,
       account_id: @account.id,
       created_at: @status.edited_at
     )
@@ -248,17 +252,21 @@ class ActivityPub::ProcessStatusUpdateService < BaseService
     mime_type.present? && !MediaAttachment.supported_mime_types.include?(mime_type)
   end
 
+  def significant_changes?
+    @status.text_changed? || @status.text_previously_changed? || @status.spoiler_text_changed? || @status.spoiler_text_previously_changed? || @media_attachments_changed || @poll_changed
+  end
+
   def already_updated_more_recently?
     @status.edited_at.present? && @status_parser.edited_at.present? && @status.edited_at > @status_parser.edited_at
   end
 
   def reset_preview_card!
-    @status.preview_cards.clear if @status.text_previously_changed? || @status.spoiler_text.present?
-    LinkCrawlWorker.perform_in(rand(1..59).seconds, @status.id) if @status.spoiler_text.blank?
+    @status.preview_cards.clear
+    LinkCrawlWorker.perform_in(rand(1..59).seconds, @status.id)
   end
 
   def broadcast_updates!
-    ::DistributionWorker.perform_async(@status.id, update: true)
+    ::DistributionWorker.perform_async(@status.id, { 'update' => true })
   end
 
   def queue_poll_notifications!
diff --git a/app/services/fan_out_on_write_service.rb b/app/services/fan_out_on_write_service.rb
index 169a2411d..46feec5aa 100644
--- a/app/services/fan_out_on_write_service.rb
+++ b/app/services/fan_out_on_write_service.rb
@@ -61,7 +61,7 @@ class FanOutOnWriteService < BaseService
   def notify_mentioned_accounts!
     @status.active_mentions.where.not(id: @options[:silenced_account_ids] || []).joins(:account).merge(Account.local).select(:id, :account_id).reorder(nil).find_in_batches do |mentions|
       LocalNotificationWorker.push_bulk(mentions) do |mention|
-        [mention.account_id, mention.id, 'Mention', :mention]
+        [mention.account_id, mention.id, 'Mention', 'mention']
       end
     end
   end
@@ -69,7 +69,7 @@ class FanOutOnWriteService < BaseService
   def deliver_to_all_followers!
     @account.followers_for_local_distribution.select(:id).reorder(nil).find_in_batches do |followers|
       FeedInsertWorker.push_bulk(followers) do |follower|
-        [@status.id, follower.id, :home, update: update?]
+        [@status.id, follower.id, 'home', { 'update' => update? }]
       end
     end
   end
@@ -77,7 +77,7 @@ class FanOutOnWriteService < BaseService
   def deliver_to_lists!
     @account.lists_for_local_distribution.select(:id).reorder(nil).find_in_batches do |lists|
       FeedInsertWorker.push_bulk(lists) do |list|
-        [@status.id, list.id, :list, update: update?]
+        [@status.id, list.id, 'list', { 'update' => update? }]
       end
     end
   end
@@ -85,14 +85,14 @@ class FanOutOnWriteService < BaseService
   def deliver_to_mentioned_followers!
     @status.mentions.joins(:account).merge(@account.followers_for_local_distribution).select(:id, :account_id).reorder(nil).find_in_batches do |mentions|
       FeedInsertWorker.push_bulk(mentions) do |mention|
-        [@status.id, mention.account_id, :home, update: update?]
+        [@status.id, mention.account_id, 'home', { 'update' => update? }]
       end
     end
   end
 
   def deliver_to_direct_timelines!
     FeedInsertWorker.push_bulk(@status.mentions.includes(:account).map(&:account).select { |mentioned_account| mentioned_account.local? }) do |account|
-      [@status.id, account.id, :direct, update: update?]
+      [@status.id, account.id, 'direct', { 'update' => update? }]
     end
   end
 
@@ -127,7 +127,7 @@ class FanOutOnWriteService < BaseService
   end
 
   def update?
-    @is_update
+    @options[:update]
   end
 
   def broadcastable?
diff --git a/app/services/follow_service.rb b/app/services/follow_service.rb
index 329262cca..ed28e1371 100644
--- a/app/services/follow_service.rb
+++ b/app/services/follow_service.rb
@@ -68,7 +68,7 @@ class FollowService < BaseService
     follow_request = @source_account.request_follow!(@target_account, reblogs: @options[:reblogs], notify: @options[:notify], rate_limit: @options[:with_rate_limit], bypass_limit: @options[:bypass_limit])
 
     if @target_account.local?
-      LocalNotificationWorker.perform_async(@target_account.id, follow_request.id, follow_request.class.name, :follow_request)
+      LocalNotificationWorker.perform_async(@target_account.id, follow_request.id, follow_request.class.name, 'follow_request')
     elsif @target_account.activitypub?
       ActivityPub::DeliveryWorker.perform_async(build_json(follow_request), @source_account.id, @target_account.inbox_url)
     end
@@ -79,7 +79,7 @@ class FollowService < BaseService
   def direct_follow!
     follow = @source_account.follow!(@target_account, reblogs: @options[:reblogs], notify: @options[:notify], rate_limit: @options[:with_rate_limit], bypass_limit: @options[:bypass_limit])
 
-    LocalNotificationWorker.perform_async(@target_account.id, follow.id, follow.class.name, :follow)
+    LocalNotificationWorker.perform_async(@target_account.id, follow.id, follow.class.name, 'follow')
     MergeWorker.perform_async(@target_account.id, @source_account.id)
 
     follow
diff --git a/app/services/import_service.rb b/app/services/import_service.rb
index 74ad5b79f..8e6640b9d 100644
--- a/app/services/import_service.rb
+++ b/app/services/import_service.rb
@@ -76,7 +76,7 @@ class ImportService < BaseService
         if presence_hash[target_account.acct]
           items.delete(target_account.acct)
           extra = presence_hash[target_account.acct][1]
-          Import::RelationshipWorker.perform_async(@account.id, target_account.acct, action, extra)
+          Import::RelationshipWorker.perform_async(@account.id, target_account.acct, action, extra.stringify_keys)
         else
           Import::RelationshipWorker.perform_async(@account.id, target_account.acct, undo_action)
         end
@@ -87,7 +87,7 @@ class ImportService < BaseService
     tail_items = items - head_items
 
     Import::RelationshipWorker.push_bulk(head_items + tail_items) do |acct, extra|
-      [@account.id, acct, action, extra]
+      [@account.id, acct, action, extra.stringify_keys]
     end
   end
 
diff --git a/app/services/reblog_service.rb b/app/services/reblog_service.rb
index 42f8b9512..6556fbff7 100644
--- a/app/services/reblog_service.rb
+++ b/app/services/reblog_service.rb
@@ -47,7 +47,7 @@ class ReblogService < BaseService
     reblogged_status = reblog.reblog
 
     if reblogged_status.account.local?
-      LocalNotificationWorker.perform_async(reblogged_status.account_id, reblog.id, reblog.class.name, :reblog)
+      LocalNotificationWorker.perform_async(reblogged_status.account_id, reblog.id, reblog.class.name, 'reblog')
     elsif reblogged_status.account.activitypub? && !reblogged_status.account.following?(reblog.account)
       ActivityPub::DeliveryWorker.perform_async(build_json(reblog), reblog.account_id, reblogged_status.account.inbox_url)
     end
diff --git a/app/services/resolve_account_service.rb b/app/services/resolve_account_service.rb
index b266c019e..3a372ef2a 100644
--- a/app/services/resolve_account_service.rb
+++ b/app/services/resolve_account_service.rb
@@ -143,7 +143,7 @@ class ResolveAccountService < BaseService
 
   def queue_deletion!
     @account.suspend!(origin: :remote)
-    AccountDeletionWorker.perform_async(@account.id, reserve_username: false, skip_activitypub: true)
+    AccountDeletionWorker.perform_async(@account.id, { 'reserve_username' => false, 'skip_activitypub' => true })
   end
 
   def lock_options