Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/users')
-rw-r--r--app/models/users/callout.rb4
-rw-r--r--app/models/users/credit_card_validation.rb2
-rw-r--r--app/models/users/in_product_marketing_email.rb75
-rw-r--r--app/models/users/phone_number_validation.rb35
4 files changed, 36 insertions, 80 deletions
diff --git a/app/models/users/callout.rb b/app/models/users/callout.rb
index c32414be312..8d330e4eb6e 100644
--- a/app/models/users/callout.rb
+++ b/app/models/users/callout.rb
@@ -79,7 +79,9 @@ module Users
vulnerability_report_grouping: 77, # EE-only
new_nav_for_everyone_callout: 78,
code_suggestions_ga_non_owner_alert: 79, # EE-only
- duo_chat_callout: 80 # EE-only
+ duo_chat_callout: 80, # EE-only
+ code_suggestions_ga_owner_alert: 81, # EE-only
+ product_analytics_dashboard_feedback: 82 # EE-only
}
validates :feature_name,
diff --git a/app/models/users/credit_card_validation.rb b/app/models/users/credit_card_validation.rb
index 6d0a22c8b0a..33e7ba72d5a 100644
--- a/app/models/users/credit_card_validation.rb
+++ b/app/models/users/credit_card_validation.rb
@@ -8,7 +8,7 @@ module Users
self.table_name = 'user_credit_card_validations'
- ignore_columns %i[last_digits network holder_name expiration_date], remove_with: '16.8', remove_after: '2023-12-22'
+ ignore_columns %i[last_digits network holder_name expiration_date], remove_with: '16.9', remove_after: '2024-01-22'
attr_accessor :last_digits, :network, :holder_name, :expiration_date
diff --git a/app/models/users/in_product_marketing_email.rb b/app/models/users/in_product_marketing_email.rb
deleted file mode 100644
index 5362a726ff5..00000000000
--- a/app/models/users/in_product_marketing_email.rb
+++ /dev/null
@@ -1,75 +0,0 @@
-# frozen_string_literal: true
-
-module Users
- class InProductMarketingEmail < ApplicationRecord
- include BulkInsertSafe
-
- belongs_to :user
-
- validates :user, presence: true
- validates :track, presence: true
- validates :series, presence: true
-
- validates :user_id, uniqueness: {
- scope: [:track, :series],
- message: 'track series email has already been sent'
- }, if: -> { track.present? }
-
- enum track: {
- create: 0,
- verify: 1,
- trial: 2,
- team: 3,
- experience: 4,
- team_short: 5,
- trial_short: 6,
- admin_verify: 7,
- invite_team: 8
- }, _suffix: true
-
- # Tracks we don't send emails for (e.g. unsuccessful experiment). These
- # are kept since we already have DB records that use the enum value.
- INACTIVE_TRACK_NAMES = %w[invite_team experience].freeze
- ACTIVE_TRACKS = tracks.except(*INACTIVE_TRACK_NAMES)
-
- scope :for_user_with_track_and_series, ->(user, track, series) do
- where(user: user, track: track, series: series)
- end
-
- scope :without_track_and_series, ->(track, series) do
- join_condition = for_user.and(for_track_and_series(track, series))
- users_without_records(join_condition)
- end
-
- def self.users_table
- User.arel_table
- end
-
- def self.distinct_users_sql
- name = users_table.name
- Arel.sql("DISTINCT ON(#{name}.id) #{name}.*")
- end
-
- def self.users_without_records(condition)
- arel_join = users_table.join(arel_table, Arel::Nodes::OuterJoin).on(condition)
- joins(arel_join.join_sources)
- .where(in_product_marketing_emails: { id: nil })
- .select(distinct_users_sql)
- end
-
- def self.for_user
- arel_table[:user_id].eq(users_table[:id])
- end
-
- def self.for_track_and_series(track, series)
- arel_table[:track].eq(ACTIVE_TRACKS[track])
- .and(arel_table[:series]).eq(series)
- end
-
- def self.save_cta_click(user, track, series)
- email = for_user_with_track_and_series(user, track, series).take
-
- email.update(cta_clicked_at: Time.zone.now) if email && email.cta_clicked_at.blank?
- end
- end
-end
diff --git a/app/models/users/phone_number_validation.rb b/app/models/users/phone_number_validation.rb
index 072b75a1c90..ffb8d3a95a2 100644
--- a/app/models/users/phone_number_validation.rb
+++ b/app/models/users/phone_number_validation.rb
@@ -4,12 +4,17 @@ module Users
class PhoneNumberValidation < ApplicationRecord
include IgnorableColumns
+ # SMS send attempts subsequent to the first one will have wait times of 1
+ # min, 3 min, 5 min after each one respectively. Wait time between the fifth
+ # attempt and so on will be 10 minutes.
+ SMS_SEND_WAIT_TIMES = [1.minute, 3.minutes, 5.minutes, 10.minutes].freeze
+
self.primary_key = :user_id
self.table_name = 'user_phone_number_validations'
ignore_column :verification_attempts, remove_with: '16.7', remove_after: '2023-11-17'
- belongs_to :user, foreign_key: :user_id
+ belongs_to :user
belongs_to :banned_user, class_name: '::Users::BannedUser', foreign_key: :user_id
validates :country, presence: true, length: { maximum: 3 }
@@ -26,13 +31,24 @@ module Users
presence: true,
format: {
with: /\A\d+\Z/,
- message: -> (object, data) { _('can contain only digits') }
+ message: ->(_object, _data) { _('can contain only digits') }
},
length: { maximum: 12 }
validates :telesign_reference_xid, length: { maximum: 255 }
- scope :for_user, -> (user_id) { where(user_id: user_id) }
+ scope :for_user, ->(user_id) { where(user_id: user_id) }
+
+ scope :similar_to, ->(phone_number_validation) do
+ where(
+ international_dial_code: phone_number_validation.international_dial_code,
+ phone_number: phone_number_validation.phone_number
+ )
+ end
+
+ def similar_records
+ self.class.similar_to(self).includes(:user)
+ end
def self.related_to_banned_user?(international_dial_code, phone_number)
joins(:banned_user)
@@ -51,5 +67,18 @@ module Users
def validated?
validated_at.present?
end
+
+ def sms_send_allowed_after
+ return unless Feature.enabled?(:sms_send_wait_time, user)
+
+ # first send is allowed anytime
+ return if sms_send_count < 1
+ return unless sms_sent_at
+
+ max_wait_time = SMS_SEND_WAIT_TIMES.last
+ wait_time = SMS_SEND_WAIT_TIMES.fetch(sms_send_count - 1, max_wait_time)
+
+ sms_sent_at + wait_time
+ end
end
end