about summary refs log tree commit diff
path: root/app/validators
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2023-02-19 10:42:55 +0100
committerClaire <claire.github-309c@sitedethib.com>2023-02-19 10:42:55 +0100
commit7452a959989f1259b68d08814437bab53ee89bb0 (patch)
tree389c2be7b7a326729e4687019a58950a07bd2dde /app/validators
parent4c68189d2b8b6a9a74fc13862b11bf6c6d523409 (diff)
parentfef6c59b3abe349132dbe910b6aa243e59b732bb (diff)
Merge branch 'main' into glitch-soc/merge-upstream
Conflicts:
- `.github/dependabot.yml`:
  Upstream made changes while we have dropped this file.
  Keep the file deleted.
- `.prettierignore`:
  Upstream made changes at the end of the file, where we
  had our extra lines.
  Just moved our extra lines back at the end.
- `app/serializers/initial_state_serializer.rb`:
  Upstream code style changes.
  Applied them.
- `app/services/backup_service.rb`:
  Upstream code style changes.
  Applied them.
Diffstat (limited to 'app/validators')
-rw-r--r--app/validators/domain_validator.rb12
-rw-r--r--app/validators/existing_username_validator.rb14
-rw-r--r--app/validators/import_validator.rb12
3 files changed, 16 insertions, 22 deletions
diff --git a/app/validators/domain_validator.rb b/app/validators/domain_validator.rb
index 6e4a854ff..3a951f9a7 100644
--- a/app/validators/domain_validator.rb
+++ b/app/validators/domain_validator.rb
@@ -4,13 +4,11 @@ class DomainValidator < ActiveModel::EachValidator
   def validate_each(record, attribute, value)
     return if value.blank?
 
-    domain = begin
-      if options[:acct]
-        value.split('@').last
-      else
-        value
-      end
-    end
+    domain = if options[:acct]
+               value.split('@').last
+             else
+               value
+             end
 
     record.errors.add(attribute, I18n.t('domain_validator.invalid_domain')) unless compliant?(domain)
   end
diff --git a/app/validators/existing_username_validator.rb b/app/validators/existing_username_validator.rb
index 1c5596821..45de4f4a4 100644
--- a/app/validators/existing_username_validator.rb
+++ b/app/validators/existing_username_validator.rb
@@ -4,16 +4,14 @@ class ExistingUsernameValidator < ActiveModel::EachValidator
   def validate_each(record, attribute, value)
     return if value.blank?
 
-    usernames_and_domains = begin
-      value.split(',').map do |str|
-        username, domain = str.strip.gsub(/\A@/, '').split('@', 2)
-        domain = nil if TagManager.instance.local_domain?(domain)
+    usernames_and_domains = value.split(',').map do |str|
+      username, domain = str.strip.gsub(/\A@/, '').split('@', 2)
+      domain = nil if TagManager.instance.local_domain?(domain)
 
-        next if username.blank?
+      next if username.blank?
 
-        [str, username, domain]
-      end.compact
-    end
+      [str, username, domain]
+    end.compact
 
     usernames_with_no_accounts = usernames_and_domains.filter_map do |(str, username, domain)|
       str unless Account.find_remote(username, domain)
diff --git a/app/validators/import_validator.rb b/app/validators/import_validator.rb
index cbad56df6..782baf5d6 100644
--- a/app/validators/import_validator.rb
+++ b/app/validators/import_validator.rb
@@ -35,13 +35,11 @@ class ImportValidator < ActiveModel::Validator
   def validate_following_import(import, row_count)
     base_limit = FollowLimitValidator.limit_for_account(import.account)
 
-    limit = begin
-      if import.overwrite?
-        base_limit
-      else
-        base_limit - import.account.following_count
-      end
-    end
+    limit = if import.overwrite?
+              base_limit
+            else
+              base_limit - import.account.following_count
+            end
 
     import.errors.add(:data, I18n.t('users.follow_limit_reached', limit: base_limit)) if row_count > limit
   end