From 55e048412166afe4202682ce22ced4f88841010f Mon Sep 17 00:00:00 2001 From: multiple creatures Date: Tue, 21 May 2019 01:54:08 -0500 Subject: add `skip_notify` option to service objects we might use for post imports --- app/services/favourite_service.rb | 4 ++-- app/services/process_mentions_service.rb | 3 ++- app/services/reblog_service.rb | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) (limited to 'app/services') diff --git a/app/services/favourite_service.rb b/app/services/favourite_service.rb index 32699d132..ee3248877 100644 --- a/app/services/favourite_service.rb +++ b/app/services/favourite_service.rb @@ -7,7 +7,7 @@ class FavouriteService < BaseService # @param [Account] account # @param [Status] status # @return [Favourite] - def call(account, status) + def call(account, status, skip_notify = false) authorize_with account, status, :favourite? favourite = Favourite.find_by(account: account, status: status) @@ -17,7 +17,7 @@ class FavouriteService < BaseService favourite = Favourite.create!(account: account, status: status) curate_status(status) - create_notification(favourite) + create_notification(favourite) unless skip_notify bump_potential_friendship(account, status) favourite diff --git a/app/services/process_mentions_service.rb b/app/services/process_mentions_service.rb index f0d3d5fcb..738bfa2d6 100644 --- a/app/services/process_mentions_service.rb +++ b/app/services/process_mentions_service.rb @@ -4,7 +4,7 @@ class ProcessMentionsService < BaseService # Scan status for mentions and fetch remote mentioned users, create # local mention pointers # @param [Status] status - def call(status) + def call(status, skip_notify = false) return unless status.local? && !status.draft? @status = status @@ -31,6 +31,7 @@ class ProcessMentionsService < BaseService status.save! + return if skip_notify mentions.each { |mention| create_notification(mention) } end diff --git a/app/services/reblog_service.rb b/app/services/reblog_service.rb index 847bd6fbf..9ac38ac9d 100644 --- a/app/services/reblog_service.rb +++ b/app/services/reblog_service.rb @@ -28,7 +28,7 @@ class ReblogService < BaseService end curate_status(reblogged_status) - create_notification(reblog) + create_notification(reblog) unless options[:skip_notify] bump_potential_friendship(account, reblog) reblog -- cgit