mirror of
https://github.com/mastodon/mastodon.git
synced 2025-07-13 15:58:13 +00:00
Compare commits
2 Commits
a5ae5dda96
...
6524925c58
Author | SHA1 | Date | |
---|---|---|---|
![]() |
6524925c58 | ||
![]() |
103e42b7f6 |
|
@ -3,10 +3,12 @@
|
|||
module Account::AttributionDomains
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
ATTRIBUTION_DOMAINS_LIMIT = 100
|
||||
|
||||
included do
|
||||
normalizes :attribution_domains, with: ->(arr) { arr.filter_map { |str| str.to_s.strip.delete_prefix('http://').delete_prefix('https://').delete_prefix('*.').presence }.uniq }
|
||||
|
||||
validates :attribution_domains, domain: true, length: { maximum: 100 }, if: -> { local? && will_save_change_to_attribution_domains? }
|
||||
validates :attribution_domains, domain: true, length: { maximum: ATTRIBUTION_DOMAINS_LIMIT }, if: -> { local? && will_save_change_to_attribution_domains? }
|
||||
end
|
||||
|
||||
def can_be_attributed_from?(domain)
|
||||
|
|
|
@ -547,8 +547,8 @@ RSpec.describe Account do
|
|||
it { is_expected.to validate_absence_of(:shared_inbox_url).on(:create) }
|
||||
it { is_expected.to validate_absence_of(:uri).on(:create) }
|
||||
|
||||
it { is_expected.to allow_values([], ['example.com'], (1..100).to_a).for(:attribution_domains) }
|
||||
it { is_expected.to_not allow_values(['example com'], ['@'], (1..101).to_a).for(:attribution_domains) }
|
||||
it { is_expected.to allow_values([], ['example.com'], Array.new(described_class::ATTRIBUTION_DOMAINS_LIMIT, &:to_s)).for(:attribution_domains) }
|
||||
it { is_expected.to_not allow_values(['example com'], ['@'], Array.new(described_class::ATTRIBUTION_DOMAINS_LIMIT * 2, &:to_s)).for(:attribution_domains) }
|
||||
end
|
||||
|
||||
context 'when account is remote' do
|
||||
|
|
Loading…
Reference in New Issue
Block a user