Add interstitial for Terms of Service updates (#34527)

This commit is contained in:
Claire 2025-05-16 16:03:05 +02:00 committed by GitHub
parent c4f47adb49
commit 8cc5084ca1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 72 additions and 4 deletions

View file

@ -23,6 +23,8 @@ class TermsOfService < ApplicationRecord
validate :effective_date_cannot_be_in_the_past
NOTIFICATION_ACTIVITY_CUTOFF = 1.year.freeze
def published?
published_at.present?
end
@ -39,8 +41,20 @@ class TermsOfService < ApplicationRecord
notification_sent_at.present?
end
def base_user_scope
User.confirmed.where(created_at: ..published_at).joins(:account)
end
def email_notification_cutoff
published_at - NOTIFICATION_ACTIVITY_CUTOFF
end
def scope_for_interstitial
base_user_scope.merge(Account.suspended).or(base_user_scope.where(current_sign_in_at: [nil, ...email_notification_cutoff]))
end
def scope_for_notification
User.confirmed.joins(:account).merge(Account.without_suspended).where(created_at: (..published_at))
base_user_scope.merge(Account.without_suspended).where(current_sign_in_at: email_notification_cutoff...)
end
private

View file

@ -25,6 +25,7 @@
# otp_backup_codes :string is an Array
# otp_required_for_login :boolean default(FALSE), not null
# otp_secret :string
# require_tos_interstitial :boolean default(FALSE), not null
# reset_password_sent_at :datetime
# reset_password_token :string
# settings :text