From: Tom Hughes Date: Wed, 22 Dec 2021 15:36:25 +0000 (+0000) Subject: Merge remote-tracking branch 'upstream/pull/3404' X-Git-Tag: live~2348 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/0ca2e10b1d42fc08ca024364be06955af71ed932?ds=sidebyside;hp=-c Merge remote-tracking branch 'upstream/pull/3404' --- 0ca2e10b1d42fc08ca024364be06955af71ed932 diff --combined app/models/user.rb index 1bb532152,abd001f06..8c75b4ef4 --- a/app/models/user.rb +++ b/app/models/user.rb @@@ -45,7 -45,6 +45,6 @@@ class User < ApplicationRecord require "digest" - require "xml/libxml" has_many :traces, -> { where(:visible => true) } has_many :diary_entries, -> { order(:created_at => :desc) } @@@ -114,8 -113,7 +113,8 @@@ 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 -240,8 +241,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 -307,7 +308,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 -316,7 +317,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 -326,10 +327,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)