diff options
Diffstat (limited to 'app/workers/remove_old_user.rb')
-rw-r--r-- | app/workers/remove_old_user.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/app/workers/remove_old_user.rb b/app/workers/remove_old_user.rb new file mode 100644 index 000000000..d8619b4bf --- /dev/null +++ b/app/workers/remove_old_user.rb @@ -0,0 +1,27 @@ +# Copyright (c) 2010-2011, Diaspora Inc. This file is +# licensed under the Affero General Public License version 3 or later. See +# the COPYRIGHT file. + +module Workers + class RemoveOldUser < Base + sidekiq_options queue: :maintenance + + def safe_remove_after + # extra safety time to compare in addition to remove_after + Time.now- + (AppConfig.settings.maintenance.remove_old_users.after_days.to_i).days- + (AppConfig.settings.maintenance.remove_old_users.warn_days.to_i).days + end + + def perform(user_id) + # if user has been flagged as to be removed (see settings.maintenance.remove_old_users) + # and hasn't logged in since that flag has been set, we remove the user + if AppConfig.settings.maintenance.remove_old_users.enable? + user = User.find(user_id) + if user.remove_after < Time.now and user.last_seen < self.safe_remove_after + user.close_account! + end + end + end + end +end
\ No newline at end of file |