diff --git a/app/models/user_history.rb b/app/models/user_history.rb index 9f0291fc91d..a68c1a0233b 100644 --- a/app/models/user_history.rb +++ b/app/models/user_history.rb @@ -5,7 +5,6 @@ class UserHistory < ActiveRecord::Base belongs_to :acting_user, class_name: 'User' belongs_to :target_user, class_name: 'User' - validates_presence_of :acting_user_id validates_presence_of :action scope :only_staff_actions, ->{ where("action IN (?)", UserHistory.staff_action_ids) } @@ -15,7 +14,9 @@ class UserHistory < ActiveRecord::Base :change_trust_level, :change_site_setting, :change_site_customization, - :delete_site_customization) + :delete_site_customization, + :checked_for_custom_avatar, + :notified_about_avatar) end # Staff actions is a subset of all actions, used to audit actions taken by staff users. diff --git a/db/migrate/20130912185218_acting_user_null.rb b/db/migrate/20130912185218_acting_user_null.rb new file mode 100644 index 00000000000..fe99e3783cc --- /dev/null +++ b/db/migrate/20130912185218_acting_user_null.rb @@ -0,0 +1,10 @@ +class ActingUserNull < ActiveRecord::Migration + def up + change_column :user_histories, :acting_user_id, :integer, :null => true + end + + def down + execute "DELETE FROM user_histories WHERE acting_user_id IS NULL" + change_column :user_histories, :acting_user_id, :integer, :null => false + end +end diff --git a/lib/jobs/detect_avatars.rb b/lib/jobs/detect_avatars.rb index 25987ac8794..1c2c6ce004b 100644 --- a/lib/jobs/detect_avatars.rb +++ b/lib/jobs/detect_avatars.rb @@ -17,6 +17,10 @@ module Jobs if user_stats.present? user_stats.each do |us| us.update_column(:has_custom_avatar, true) if AvatarDetector.new(us.user).has_custom_avatar? + UserHistory.create!( + action: UserHistory.actions[:checked_for_custom_avatar], + target_user_id: us.user_id + ) end end end