mirror of
https://github.com/lunaisnotaboy/mastodon.git
synced 2024-11-17 20:32:56 +00:00
parent
b241cb2704
commit
352bae8c3e
|
@ -9,6 +9,7 @@ class ApplicationController < ActionController::Base
|
||||||
|
|
||||||
include Localized
|
include Localized
|
||||||
include UserTrackingConcern
|
include UserTrackingConcern
|
||||||
|
include SessionTrackingConcern
|
||||||
|
|
||||||
helper_method :current_account
|
helper_method :current_account
|
||||||
helper_method :current_session
|
helper_method :current_session
|
||||||
|
|
22
app/controllers/concerns/session_tracking_concern.rb
Normal file
22
app/controllers/concerns/session_tracking_concern.rb
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module SessionTrackingConcern
|
||||||
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
|
UPDATE_SIGN_IN_HOURS = 24
|
||||||
|
|
||||||
|
included do
|
||||||
|
before_action :set_session_activity
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def set_session_activity
|
||||||
|
return unless session_needs_update?
|
||||||
|
current_session.touch
|
||||||
|
end
|
||||||
|
|
||||||
|
def session_needs_update?
|
||||||
|
!current_session.nil? && current_session.updated_at < UPDATE_SIGN_IN_HOURS.hours.ago
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue