FEATURE: New site setting, whitelisted_link_domains

If provided, users who normally couldn't post links (say, due to a
low trust level), can post links to those specific hosts.
This commit is contained in:
Robin Ward
2018-06-13 14:57:32 -04:00
parent debbb5be16
commit fd54c92a52
10 changed files with 96 additions and 21 deletions

View File

@ -109,10 +109,12 @@ class Validators::PostValidator < ActiveModel::Validator
end
def can_post_links_validator(post)
if (post.link_count == 0 && !post.has_oneboxes?) ||
Guardian.new(post.acting_user).can_post_link? ||
private_message?(post)
if (post.link_count == 0 && !post.has_oneboxes?) || private_message?(post)
return newuser_links_validator(post)
end
guardian = Guardian.new(post.acting_user)
if post.linked_hosts.keys.all? { |h| guardian.can_post_link?(host: h) }
return newuser_links_validator(post)
end