API for updating attribution domains (#32730)
This commit is contained in:
parent
3af6739f21
commit
a3baae0b99
108 changed files with 141 additions and 251 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue