mirror of
https://github.com/discourse/discourse.git
synced 2025-05-29 00:00:46 +08:00
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:
@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user