diff options
Diffstat (limited to 'app/workers')
-rw-r--r-- | app/workers/activitypub/reply_distribution_worker.rb | 4 | ||||
-rw-r--r-- | app/workers/pubsubhubbub/subscribe_worker.rb | 2 | ||||
-rw-r--r-- | app/workers/refollow_worker.rb | 24 | ||||
-rw-r--r-- | app/workers/scheduler/ip_cleanup_scheduler.rb | 12 |
4 files changed, 39 insertions, 3 deletions
diff --git a/app/workers/activitypub/reply_distribution_worker.rb b/app/workers/activitypub/reply_distribution_worker.rb index f9127340f..fe99fc05f 100644 --- a/app/workers/activitypub/reply_distribution_worker.rb +++ b/app/workers/activitypub/reply_distribution_worker.rb @@ -7,9 +7,9 @@ class ActivityPub::ReplyDistributionWorker def perform(status_id) @status = Status.find(status_id) - @account = @status.thread.account + @account = @status.thread&.account - return if skip_distribution? + return if @account.nil? || skip_distribution? ActivityPub::DeliveryWorker.push_bulk(inboxes) do |inbox_url| [signed_payload, @status.account_id, inbox_url] diff --git a/app/workers/pubsubhubbub/subscribe_worker.rb b/app/workers/pubsubhubbub/subscribe_worker.rb index 130c967e0..7560c2671 100644 --- a/app/workers/pubsubhubbub/subscribe_worker.rb +++ b/app/workers/pubsubhubbub/subscribe_worker.rb @@ -3,7 +3,7 @@ class Pubsubhubbub::SubscribeWorker include Sidekiq::Worker - sidekiq_options queue: 'push', retry: 10, unique: :until_executed, dead: false, unique_retry: true + sidekiq_options queue: 'push', retry: 10, unique: :until_executed, dead: false sidekiq_retry_in do |count| case count diff --git a/app/workers/refollow_worker.rb b/app/workers/refollow_worker.rb new file mode 100644 index 000000000..66bcd27c3 --- /dev/null +++ b/app/workers/refollow_worker.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +class RefollowWorker + include Sidekiq::Worker + + sidekiq_options queue: 'pull', retry: false + + def perform(target_account_id) + target_account = Account.find(target_account_id) + return unless target_account.protocol == :activitypub + + target_account.followers.where(domain: nil).find_each do |follower| + # Locally unfollow remote account + follower.unfollow!(target_account) + + # Schedule re-follow + begin + FollowService.new.call(follower, target_account) + rescue Mastodon::NotPermittedError, ActiveRecord::RecordNotFound, Mastodon::UnexpectedResponseError, HTTP::Error, OpenSSL::SSL::SSLError + next + end + end + end +end diff --git a/app/workers/scheduler/ip_cleanup_scheduler.rb b/app/workers/scheduler/ip_cleanup_scheduler.rb new file mode 100644 index 000000000..9f1593c91 --- /dev/null +++ b/app/workers/scheduler/ip_cleanup_scheduler.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true +require 'sidekiq-scheduler' + +class Scheduler::IpCleanupScheduler + include Sidekiq::Worker + + def perform + time_ago = 5.years.ago + SessionActivation.where('updated_at < ?', time_ago).destroy_all + User.where('last_sign_in_at < ?', time_ago).update_all(last_sign_in_ip: nil) + end +end |