about summary refs log tree commit diff
path: root/app/models/list.rb
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2017-12-09 01:32:29 +0100
committerGitHub <noreply@github.com>2017-12-09 01:32:29 +0100
commit2f4c5f504fa5edc2a826afa9645371f529ae904d (patch)
tree4123afd91c72f58ef0262ef97ee5e2ff1e6f5f26 /app/models/list.rb
parentf08e6e9ab54a72cc20b33b270789c245b5cfde39 (diff)
Limit users to 50 lists, remove pagination from lists API (#5933)
Diffstat (limited to 'app/models/list.rb')
-rw-r--r--app/models/list.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/app/models/list.rb b/app/models/list.rb
index 910864b26..f45e4973d 100644
--- a/app/models/list.rb
+++ b/app/models/list.rb
@@ -13,6 +13,8 @@
 class List < ApplicationRecord
   include Paginable
 
+  PER_ACCOUNT_LIMIT = 50
+
   belongs_to :account
 
   has_many :list_accounts, inverse_of: :list, dependent: :destroy
@@ -20,6 +22,10 @@ class List < ApplicationRecord
 
   validates :title, presence: true
 
+  validates_each :account_id, on: :create do |record, _attr, value|
+    record.errors.add(:base, I18n.t('lists.errors.limit')) if List.where(account_id: value).count >= PER_ACCOUNT_LIMIT
+  end
+
   before_destroy :clean_feed_manager
 
   private