From: Tom Hughes Date: Wed, 22 Dec 2021 15:26:23 +0000 (+0000) Subject: Merge remote-tracking branch 'upstream/pull/3403' X-Git-Tag: live~2349 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/5a70476d38447d7b57d9bb96b55097d9d0873e3a?ds=sidebyside;hp=-c Merge remote-tracking branch 'upstream/pull/3403' --- 5a70476d38447d7b57d9bb96b55097d9d0873e3a diff --combined app/models/user.rb index 8f02e35cf,177a29984..1bb532152 --- a/app/models/user.rb +++ b/app/models/user.rb @@@ -114,8 -114,7 +114,8 @@@ class User < ApplicationRecor validates_email_format_of :email, :if => proc { |u| u.email_changed? } validates_email_format_of :new_email, :allow_blank => true, :if => proc { |u| u.new_email_changed? } - after_initialize :set_defaults + alias_attribute :created_at, :creation_time + before_save :encrypt_password before_save :update_tile after_save :spam_check @@@ -242,8 -241,8 +242,8 @@@ end ## - # delete a user - leave the account but purge most personal data - def delete + # destroy a user - leave the account but purge most personal data + def destroy avatar.purge_later self.display_name = "user_#{id}" @@@ -309,7 -308,7 +309,7 @@@ end def max_messages_per_hour - account_age_in_seconds = Time.now.utc - creation_time + account_age_in_seconds = Time.now.utc - created_at account_age_in_hours = account_age_in_seconds / 3600 recent_messages = messages.where("sent_on >= ?", Time.now.utc - 3600).count active_reports = issues.with_status(:open).sum(:reports_count) @@@ -318,7 -317,7 +318,7 @@@ end def max_friends_per_hour - account_age_in_seconds = Time.now.utc - creation_time + account_age_in_seconds = Time.now.utc - created_at account_age_in_hours = account_age_in_seconds / 3600 recent_friends = Friendship.where(:befriendee => self).where("created_at >= ?", Time.now.utc - 3600).count active_reports = issues.with_status(:open).sum(:reports_count) @@@ -328,6 -327,10 +328,6 @@@ private - def set_defaults - self.creation_time = Time.now.getutc unless attribute_present?(:creation_time) - end - def encrypt_password if pass_crypt_confirmation self.pass_crypt, self.pass_salt = PasswordHash.create(pass_crypt)