From e9bc4a4a0822235afebbefa0c4d660b1be9ae52f Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sun, 25 Sep 2016 15:26:56 +0200 Subject: Limit usernames to 30 chars, statuses to 500, open account after follow form success --- app/models/account.rb | 2 +- app/models/status.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'app/models') diff --git a/app/models/account.rb b/app/models/account.rb index 25316c9a4..16db2d719 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -6,7 +6,7 @@ class Account < ApplicationRecord # Local users has_one :user, inverse_of: :account - validates :username, presence: true, format: { with: /\A[a-z0-9_]+\z/i, message: 'only letters, numbers and underscores' }, uniqueness: { scope: :domain, case_sensitive: false }, if: 'local?' + validates :username, presence: true, format: { with: /\A[a-z0-9_]+\z/i, message: 'only letters, numbers and underscores' }, uniqueness: { scope: :domain, case_sensitive: false }, length: { maximum: 30 }, if: 'local?' validates :username, presence: true, uniqueness: { scope: :domain, case_sensitive: true }, unless: 'local?' # Avatar upload diff --git a/app/models/status.rb b/app/models/status.rb index ae5c4b496..cbcde69f4 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -15,7 +15,7 @@ class Status < ApplicationRecord validates :account, presence: true validates :uri, uniqueness: true, unless: 'local?' - validates :text, presence: true, if: Proc.new { |s| s.local? && !s.reblog? } + validates :text, presence: true, length: { maximum: 500 }, if: Proc.new { |s| s.local? && !s.reblog? } scope :with_counters, -> { select('statuses.*, (select count(r.id) from statuses as r where r.reblog_of_id = statuses.id) as reblogs_count, (select count(f.id) from favourites as f where f.status_id = statuses.id) as favourites_count') } scope :with_includes, -> { includes(:account, :media_attachments, :stream_entry, mentions: :account, reblog: [:account, mentions: :account], thread: :account) } -- cgit