mirror of
https://github.com/discourse/discourse.git
synced 2025-06-06 23:07:28 +08:00
Fix broken specs since all urls will be oneboxed.
This commit is contained in:
@ -31,15 +31,17 @@ class UserDestroyer
|
|||||||
# block all external urls
|
# block all external urls
|
||||||
if opts[:block_urls]
|
if opts[:block_urls]
|
||||||
post.topic_links.each do |link|
|
post.topic_links.each do |link|
|
||||||
unless link.internal or Oneboxer.oneboxer_exists_for_url?(link.url)
|
unless link.internal ||
|
||||||
ScreenedUrl.watch(link.url, link.domain, ip_address: user.ip_address).try(:record_match!)
|
(Oneboxer.engine(link.url) != Onebox::Engine::WhitelistedGenericOnebox)
|
||||||
|
|
||||||
|
ScreenedUrl.watch(link.url, link.domain, ip_address: user.ip_address)&.record_match!
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
PostDestroyer.new(@actor.staff? ? @actor : Discourse.system_user, post).destroy
|
PostDestroyer.new(@actor.staff? ? @actor : Discourse.system_user, post).destroy
|
||||||
|
|
||||||
if post.topic and post.is_first_post?
|
if post.topic && post.is_first_post?
|
||||||
Topic.unscoped.where(id: post.topic.id).update_all(user_id: nil)
|
Topic.unscoped.where(id: post.topic.id).update_all(user_id: nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -46,10 +46,6 @@ module Oneboxer
|
|||||||
""
|
""
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.oneboxer_exists_for_url?(url)
|
|
||||||
Onebox.has_matcher?(url)
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.invalidate(url)
|
def self.invalidate(url)
|
||||||
Rails.cache.delete(onebox_cache_key(url))
|
Rails.cache.delete(onebox_cache_key(url))
|
||||||
end
|
end
|
||||||
@ -124,6 +120,10 @@ module Oneboxer
|
|||||||
$redis.del(preview_key(user_id))
|
$redis.del(preview_key(user_id))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.engine(url)
|
||||||
|
Onebox::Matcher.new(url).oneboxed
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def self.preview_key(user_id)
|
def self.preview_key(user_id)
|
||||||
|
@ -239,12 +239,12 @@ describe UserDestroyer do
|
|||||||
|
|
||||||
it "doesn't add ScreenedUrl records by default" do
|
it "doesn't add ScreenedUrl records by default" do
|
||||||
ScreenedUrl.expects(:watch).never
|
ScreenedUrl.expects(:watch).never
|
||||||
UserDestroyer.new(@admin).destroy(@user, {delete_posts: true})
|
UserDestroyer.new(@admin).destroy(@user, delete_posts: true)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "adds ScreenedUrl records when :block_urls is true" do
|
it "adds ScreenedUrl records when :block_urls is true" do
|
||||||
ScreenedUrl.expects(:watch).with(anything, anything, has_key(:ip_address)).at_least_once
|
ScreenedUrl.expects(:watch).with(anything, anything, has_key(:ip_address)).at_least_once
|
||||||
UserDestroyer.new(@admin).destroy(@user, {delete_posts: true, block_urls: true})
|
UserDestroyer.new(@admin).destroy(@user, delete_posts: true, block_urls: true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user