fixes for #1865
This commit is contained in:
@@ -46,6 +46,14 @@ class CurrentUser
|
||||
Thread.current[:safe_mode]
|
||||
end
|
||||
|
||||
def self.without_safe_mode
|
||||
prev = Thread.current[:safe_mode]
|
||||
Thread.current[:safe_mode] = false
|
||||
yield
|
||||
ensure
|
||||
Thread.current[:safe_mode] = prev
|
||||
end
|
||||
|
||||
def self.set_safe_mode(req)
|
||||
if req.host =~ /safe/
|
||||
Thread.current[:safe_mode] = true
|
||||
|
||||
@@ -10,10 +10,12 @@ module Moderator
|
||||
|
||||
updater = User.find(updater_id)
|
||||
|
||||
CurrentUser.scoped(updater, updater_ip_addr) do
|
||||
::Post.tag_match(antecedent).each do |post|
|
||||
tags = (post.tag_array - normalized_antecedent + normalized_consequent).join(" ")
|
||||
post.update_attributes(:tag_string => tags)
|
||||
CurrentUser.without_safe_mode do
|
||||
CurrentUser.scoped(updater, updater_ip_addr) do
|
||||
::Post.tag_match(antecedent).each do |post|
|
||||
tags = (post.tag_array - normalized_antecedent + normalized_consequent).join(" ")
|
||||
post.update_attributes(:tag_string => tags)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -114,7 +114,6 @@ class PostQueryBuilder
|
||||
|
||||
if CurrentUser.safe_mode?
|
||||
relation = relation.where(:rating => "s")
|
||||
# relation = relation.where("created_at <= ?", 3.months.ago)
|
||||
end
|
||||
|
||||
relation = add_range_relation(q[:post_id], "posts.id", relation)
|
||||
|
||||
Reference in New Issue
Block a user