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/banned_user.rb2
-rw-r--r--app/models/users/callout.rb3
-rw-r--r--app/models/users/namespace_callout.rb33
-rw-r--r--app/models/users/phone_number_validation.rb41
-rw-r--r--app/models/users/project_callout.rb6
-rw-r--r--app/models/users/user_follow_user.rb15
6 files changed, 64 insertions, 36 deletions
diff --git a/app/models/users/banned_user.rb b/app/models/users/banned_user.rb
index c52b6d4b728..615668e2b55 100644
--- a/app/models/users/banned_user.rb
+++ b/app/models/users/banned_user.rb
@@ -7,6 +7,6 @@ module Users
belongs_to :user
validates :user, presence: true
- validates :user_id, uniqueness: { message: _("banned user already exists") }
+ validates :user_id, uniqueness: { message: N_("banned user already exists") }
end
end
diff --git a/app/models/users/callout.rb b/app/models/users/callout.rb
index 03841ee48fa..ae6950d800c 100644
--- a/app/models/users/callout.rb
+++ b/app/models/users/callout.rb
@@ -61,7 +61,8 @@ module Users
namespace_storage_limit_banner_alert_threshold: 57, # EE-only
namespace_storage_limit_banner_error_threshold: 58, # EE-only
project_quality_summary_feedback: 59, # EE-only
- merge_request_settings_moved_callout: 60
+ merge_request_settings_moved_callout: 60,
+ new_top_level_group_alert: 61
}
validates :feature_name,
diff --git a/app/models/users/namespace_callout.rb b/app/models/users/namespace_callout.rb
deleted file mode 100644
index 4e655a96b57..00000000000
--- a/app/models/users/namespace_callout.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-# frozen_string_literal: true
-
-module Users
- class NamespaceCallout < ApplicationRecord
- include Users::Calloutable
-
- self.table_name = 'user_namespace_callouts'
-
- belongs_to :namespace
-
- enum feature_name: {
- invite_members_banner: 1,
- approaching_seat_count_threshold: 2, # EE-only
- storage_enforcement_banner_first_enforcement_threshold: 3, # EE-only
- storage_enforcement_banner_second_enforcement_threshold: 4, # EE-only
- storage_enforcement_banner_third_enforcement_threshold: 5, # EE-only
- storage_enforcement_banner_fourth_enforcement_threshold: 6, # EE-only
- preview_user_over_limit_free_plan_alert: 7, # EE-only
- user_reached_limit_free_plan_alert: 8, # EE-only
- web_hook_disabled: 9
- }
-
- validates :namespace, presence: true
- validates :feature_name,
- presence: true,
- uniqueness: { scope: [:user_id, :namespace_id] },
- inclusion: { in: NamespaceCallout.feature_names.keys }
-
- def source_feature_name
- "#{feature_name}_#{namespace_id}"
- end
- end
-end
diff --git a/app/models/users/phone_number_validation.rb b/app/models/users/phone_number_validation.rb
new file mode 100644
index 00000000000..f6123c01fd0
--- /dev/null
+++ b/app/models/users/phone_number_validation.rb
@@ -0,0 +1,41 @@
+# frozen_string_literal: true
+
+module Users
+ class PhoneNumberValidation < ApplicationRecord
+ self.primary_key = :user_id
+ self.table_name = 'user_phone_number_validations'
+
+ belongs_to :user, foreign_key: :user_id
+ belongs_to :banned_user, class_name: '::Users::BannedUser', foreign_key: :user_id
+
+ validates :country,
+ presence: true,
+ length: { maximum: 3 }
+
+ validates :international_dial_code,
+ presence: true,
+ numericality: {
+ only_integer: true,
+ greater_than_or_equal_to: 1,
+ less_than_or_equal_to: 999
+ }
+
+ validates :phone_number,
+ presence: true,
+ format: {
+ with: /\A\d+\Z/,
+ message: -> (object, data) { _('can contain only digits') }
+ },
+ length: { maximum: 12 }
+
+ validates :telesign_reference_xid,
+ length: { maximum: 255 }
+
+ def self.related_to_banned_user?(international_dial_code, phone_number)
+ joins(:banned_user).where(
+ international_dial_code: international_dial_code,
+ phone_number: phone_number
+ ).exists?
+ end
+ end
+end
diff --git a/app/models/users/project_callout.rb b/app/models/users/project_callout.rb
index 98dacbe394a..c73b3a4ee71 100644
--- a/app/models/users/project_callout.rb
+++ b/app/models/users/project_callout.rb
@@ -11,7 +11,11 @@ module Users
enum feature_name: {
awaiting_members_banner: 1, # EE-only
web_hook_disabled: 2,
- ultimate_feature_removal_banner: 3
+ ultimate_feature_removal_banner: 3,
+ storage_enforcement_banner_first_enforcement_threshold: 4, # EE-only
+ storage_enforcement_banner_second_enforcement_threshold: 5, # EE-only
+ storage_enforcement_banner_third_enforcement_threshold: 6, # EE-only
+ storage_enforcement_banner_fourth_enforcement_threshold: 7 # EE-only
}
validates :project, presence: true
diff --git a/app/models/users/user_follow_user.rb b/app/models/users/user_follow_user.rb
index a94239a746c..5a82a81364a 100644
--- a/app/models/users/user_follow_user.rb
+++ b/app/models/users/user_follow_user.rb
@@ -1,7 +1,22 @@
# frozen_string_literal: true
module Users
class UserFollowUser < ApplicationRecord
+ MAX_FOLLOWEE_LIMIT = 300
+
belongs_to :follower, class_name: 'User'
belongs_to :followee, class_name: 'User'
+
+ validate :max_follow_limit
+
+ private
+
+ def max_follow_limit
+ followee_count = self.class.where(follower_id: follower_id).limit(MAX_FOLLOWEE_LIMIT).count
+ return if followee_count < MAX_FOLLOWEE_LIMIT
+
+ errors.add(:base, format(
+ _("You can't follow more than %{limit} users. To follow more users, unfollow some others."),
+ limit: MAX_FOLLOWEE_LIMIT))
+ end
end
end