update users last_logged_in_at more frequently, disable tag subscription processing for users who have been inactive for more than one year
This commit is contained in:
@@ -19,7 +19,8 @@ class SessionLoader
|
||||
else
|
||||
CurrentUser.user = AnonymousUser.new
|
||||
end
|
||||
|
||||
|
||||
update_last_logged_in_at
|
||||
set_time_zone
|
||||
end
|
||||
|
||||
@@ -43,6 +44,12 @@ private
|
||||
cookies[:cookie_password_hash] && User.authenticate_cookie_hash(cookies[:user_name], cookies[:cookie_password_hash])
|
||||
end
|
||||
|
||||
def update_last_logged_in_at
|
||||
return if CurrentUser.is_anonymous?
|
||||
return if CurrentUser.last_logged_in_at && CurrentUser.last_logged_in_at > 1.week.ago
|
||||
CurrentUser.user.update_attribute(:last_logged_in_at, Time.now)
|
||||
end
|
||||
|
||||
def set_time_zone
|
||||
Time.zone = CurrentUser.user.time_zone
|
||||
end
|
||||
|
||||
@@ -34,6 +34,10 @@ class TagSubscription < ActiveRecord::Base
|
||||
self.post_ids = post_ids.sort.reverse.slice(0, Danbooru.config.tag_subscription_post_limit).join(",")
|
||||
end
|
||||
|
||||
def is_active?
|
||||
creator.last_logged_in_at && creator.last_logged_in_at > 1.year.ago
|
||||
end
|
||||
|
||||
def editable_by?(user)
|
||||
user.is_moderator? || creator_id == user.id
|
||||
end
|
||||
@@ -86,7 +90,7 @@ class TagSubscription < ActiveRecord::Base
|
||||
|
||||
def self.process_all
|
||||
find_each do |tag_subscription|
|
||||
if $job_task_daemon_active != false && tag_subscription.creator.is_privileged?
|
||||
if $job_task_daemon_active != false && tag_subscription.creator.is_privileged? && tag_subscription.is_active?
|
||||
begin
|
||||
tag_subscription.process
|
||||
tag_subscription.save
|
||||
|
||||
Reference in New Issue
Block a user