FEATURE: unconditionally omit no-follow for staff

Previously TL2 and below staff would have links
no-followed which was never intended
This commit is contained in:
Sam 2018-09-17 12:02:20 +10:00
parent 37c5280f73
commit 33541c4096
2 changed files with 13 additions and 7 deletions

View File

@ -239,6 +239,7 @@ class Post < ActiveRecord::Base
end
def add_nofollow?
return false if user&.staff?
user.blank? || SiteSetting.tl3_links_no_follow? || !user.has_trust_level?(TrustLevel[3])
end
@ -256,14 +257,9 @@ class Post < ActiveRecord::Base
post_user = self.user
options[:user_id] = post_user.id if post_user
options[:omit_nofollow] = true if omit_nofollow?
if add_nofollow?
cooked = post_analyzer.cook(raw, options)
else
# At trust level 3, we don't apply nofollow to links
options[:omit_nofollow] = true
cooked = post_analyzer.cook(raw, options)
end
cooked = post_analyzer.cook(raw, options)
new_cooked = Plugin::Filter.apply(:after_post_cook, self, cooked)

View File

@ -940,6 +940,16 @@ describe Post do
describe "cooking" do
let(:post) { Fabricate.build(:post, post_args.merge(raw: "please read my blog http://blog.example.com")) }
it "should unconditionally follow links for staff" do
SiteSetting.tl3_links_no_follow = true
post.user.trust_level = 1
post.user.moderator = true
post.save
expect(post.cooked).not_to match(/nofollow/)
end
it "should add nofollow to links in the post for trust levels below 3" do
post.user.trust_level = 2
post.save