From 015cd99f41403db71cc918f430da9b9b5cf57aa3 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Wed, 30 Nov 2016 15:17:03 +0100 Subject: [PATCH] Make User#current_sign_in_at actually track when user was last active, by updating it at least every 24h if the user visits the site --- app/controllers/application_controller.rb | 5 +++++ app/helpers/stream_entries_helper.rb | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index ba0098c71e..bb52646a75 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -14,6 +14,7 @@ class ApplicationController < ActionController::Base before_action :store_current_location, except: :raise_not_found, unless: :devise_controller? before_action :set_locale + before_action :set_user_activity def raise_not_found raise ActionController::RoutingError, "No route matches #{params[:unmatched_route]}" @@ -35,6 +36,10 @@ class ApplicationController < ActionController::Base redirect_to root_path unless current_user&.admin? end + def set_user_activity + current_user.touch(:current_sign_in_at) if !current_user.nil? && current_user.current_sign_in_at < 24.hours.ago + end + protected def not_found diff --git a/app/helpers/stream_entries_helper.rb b/app/helpers/stream_entries_helper.rb index 2ba50edc3f..1eb2ed0586 100644 --- a/app/helpers/stream_entries_helper.rb +++ b/app/helpers/stream_entries_helper.rb @@ -6,7 +6,7 @@ module StreamEntriesHelper end def avatar_for_status_url(status) - status.reblog? ? status.reblog.account.avatar.url(:medium) : status.account.avatar.url(:medium) + status.reblog? ? status.reblog.account.avatar.url(:large) : status.account.avatar.url(:large) end def entry_classes(status, is_predecessor, is_successor, include_threads)