]> cat aescling's git repositories - mastodon.git/commitdiff
Make User#current_sign_in_at actually track when user was last active,
authorEugen Rochko <eugen@zeonfederated.com>
Wed, 30 Nov 2016 14:17:03 +0000 (15:17 +0100)
committerEugen Rochko <eugen@zeonfederated.com>
Wed, 30 Nov 2016 14:17:03 +0000 (15:17 +0100)
by updating it at least every 24h if the user visits the site

app/controllers/application_controller.rb
app/helpers/stream_entries_helper.rb

index ba0098c71e803366c3dd230f3728b9798b497d73..bb52646a7560a875cbfe3fd2091b46806f012c01 100644 (file)
@@ -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
index 2ba50edc3f3886c34fe0dc9f27b12c5fd6aec8dd..1eb2ed05861e79db94077c20f2b23ab2d41768e7 100644 (file)
@@ -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)