0
0
Fork 0

API for updating attribution domains (#32730)

This commit is contained in:
Christian Schmidt 2025-01-17 09:18:55 +01:00 committed by GitHub
parent 3af6739f21
commit a3baae0b99
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
108 changed files with 141 additions and 251 deletions

View file

@ -4,21 +4,9 @@ module Account::AttributionDomains
extend ActiveSupport::Concern
included do
validates :attribution_domains_as_text, domain: { multiline: true }, lines: { maximum: 100 }, if: -> { local? && will_save_change_to_attribution_domains? }
end
normalizes :attribution_domains, with: ->(arr) { arr.filter_map { |str| str.to_s.strip.delete_prefix('http://').delete_prefix('https://').delete_prefix('*.').presence }.uniq }
def attribution_domains_as_text
self[:attribution_domains].join("\n")
end
def attribution_domains_as_text=(str)
self[:attribution_domains] = str.split.filter_map do |line|
line
.strip
.delete_prefix('http://')
.delete_prefix('https://')
.delete_prefix('*.')
end
validates :attribution_domains, domain: true, length: { maximum: 100 }, if: -> { local? && will_save_change_to_attribution_domains? }
end
def can_be_attributed_from?(domain)