Updated LinkBlock checks for if status text contains blocked domain
• Updated: - LinkBlock checks for if status text contains blocked domain - normalize_link to use domain instead of normalized_host • Added: - normalize_link_domain to check for if entire domains are blocked or not for spam
This commit is contained in:
parent
d73b4afa28
commit
e3af1b4a26
|
@ -25,7 +25,13 @@ class TagManager
|
||||||
def normalize_link(link)
|
def normalize_link(link)
|
||||||
return if link.nil?
|
return if link.nil?
|
||||||
uri = Addressable::URI.parse(link)
|
uri = Addressable::URI.parse(link)
|
||||||
return "#{uri.normalized_host}#{uri.normalized_path}".strip
|
return "#{uri.domain}#{uri.normalized_path}".strip
|
||||||
|
end
|
||||||
|
|
||||||
|
def normalize_link_domain(link)
|
||||||
|
return if link.nil?
|
||||||
|
uri = Addressable::URI.parse(link)
|
||||||
|
return "#{uri.domain}".strip
|
||||||
end
|
end
|
||||||
|
|
||||||
def same_acct?(canonical, needle)
|
def same_acct?(canonical, needle)
|
||||||
|
|
|
@ -32,6 +32,10 @@ class LinkBlock < ApplicationRecord
|
||||||
link_for_fetch = TagManager.instance.normalize_link(url)
|
link_for_fetch = TagManager.instance.normalize_link(url)
|
||||||
link_for_fetch = link_for_fetch.chomp("/")
|
link_for_fetch = link_for_fetch.chomp("/")
|
||||||
|
|
||||||
where("LOWER(link) LIKE LOWER(?)", "%#{link_for_fetch}%").exists?
|
domain_for_fetch = TagManager.instance.normalize_link_domain(url)
|
||||||
|
|
||||||
|
where("LOWER(link) LIKE LOWER(?)", "%#{link_for_fetch}").or(
|
||||||
|
where("LOWER(link) LIKE LOWER(?)", "#{domain_for_fetch}")
|
||||||
|
).exists?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue