about summary refs log tree commit diff
path: root/app/workers
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2019-09-19 00:22:39 +0200
committerGitHub <noreply@github.com>2019-09-19 00:22:39 +0200
commitfebcdad2e2c98aee62b55ee21bdf0debf7c6fd6b (patch)
tree1a99988dd7a46824527e59ee1861aa72ad7412ce /app/workers
parentab646fac5f582fe9bef22d8b9a4995fbb4b42d7d (diff)
parent2ecc7106d7fc222ca84777fc279e9f46f80afd5a (diff)
Merge pull request #1221 from ThibG/glitch-soc/merge-upstream
Merge upstream changes
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