about summary refs log tree commit diff
path: root/app/workers
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2019-09-18 17:25:56 +0200
committerThibaut Girka <thib@sitedethib.com>2019-09-18 17:25:56 +0200
commit5cadb4723832b91068ee51955b9d4b1336502369 (patch)
tree2e915e53ee0d25ea63ee3910ae8ced44f3295e21 /app/workers
parentab646fac5f582fe9bef22d8b9a4995fbb4b42d7d (diff)
parentd0c2c5278391b82ba7fa2f230bf237805ff61a0c (diff)
Merge branch 'master' into glitch-soc/merge-upstream
Conflicts:
- app/controllers/auth/sessions_controller.rb
  Minor conflict due to glitch-soc's theming code
Diffstat (limited to 'app/workers')
-rw-r--r--app/workers/scheduler/ip_cleanup_scheduler.rb4
-rw-r--r--app/workers/unfollow_follow_worker.rb2
-rw-r--r--app/workers/web/push_notification_worker.rb8
3 files changed, 10 insertions, 4 deletions
diff --git a/app/workers/scheduler/ip_cleanup_scheduler.rb b/app/workers/scheduler/ip_cleanup_scheduler.rb
index 42620332e..4f44078d8 100644
--- a/app/workers/scheduler/ip_cleanup_scheduler.rb
+++ b/app/workers/scheduler/ip_cleanup_scheduler.rb
@@ -9,7 +9,7 @@ class Scheduler::IpCleanupScheduler
 
   def perform
     time_ago = RETENTION_PERIOD.ago
-    SessionActivation.where('updated_at < ?', time_ago).destroy_all
-    User.where('last_sign_in_at < ?', time_ago).update_all(last_sign_in_ip: nil)
+    SessionActivation.where('updated_at < ?', time_ago).in_batches.destroy_all
+    User.where('last_sign_in_at < ?', time_ago).where.not(last_sign_in_ip: nil).in_batches.update_all(last_sign_in_ip: nil)
   end
 end
diff --git a/app/workers/unfollow_follow_worker.rb b/app/workers/unfollow_follow_worker.rb
index 50d3bf034..95549e107 100644
--- a/app/workers/unfollow_follow_worker.rb
+++ b/app/workers/unfollow_follow_worker.rb
@@ -11,7 +11,7 @@ class UnfollowFollowWorker
     new_target_account = Account.find(new_target_account_id)
 
     FollowService.new.call(follower_account, new_target_account)
-    UnfollowService.new.call(follower_account, old_target_account)
+    UnfollowService.new.call(follower_account, old_target_account, skip_unmerge: true)
   rescue ActiveRecord::RecordNotFound, Mastodon::NotPermittedError
     true
   end
diff --git a/app/workers/web/push_notification_worker.rb b/app/workers/web/push_notification_worker.rb
index 901043975..46aeaa30b 100644
--- a/app/workers/web/push_notification_worker.rb
+++ b/app/workers/web/push_notification_worker.rb
@@ -11,7 +11,13 @@ class Web::PushNotificationWorker
 
     subscription.push(notification) unless notification.activity.nil?
   rescue Webpush::ResponseError => e
-    subscription.destroy! if (400..499).cover?(e.response.code.to_i)
+    code = e.response.code.to_i
+
+    if (400..499).cover?(code) && ![408, 429].include?(code)
+      subscription.destroy!
+    else
+      raise e
+    end
   rescue ActiveRecord::RecordNotFound
     true
   end