diff --git a/lib/cooked_post_processor.rb b/lib/cooked_post_processor.rb index 58c599b75eb..bab2cee5164 100644 --- a/lib/cooked_post_processor.rb +++ b/lib/cooked_post_processor.rb @@ -33,6 +33,8 @@ class CookedPostProcessor end def create_firsts + return unless Guardian.new.can_see?(@post) + created = false if @doc.css("img.emoji").size > 0 diff --git a/spec/models/user_firsts_spec.rb b/spec/models/user_firsts_spec.rb index 69bc5996d28..d956875bc3f 100644 --- a/spec/models/user_firsts_spec.rb +++ b/spec/models/user_firsts_spec.rb @@ -30,4 +30,17 @@ describe UserFirst do end end + context "privacy" do + let(:codinghorror) { Fabricate(:codinghorror) } + + it "doesn't create the userfirst on private posts" do + post = PostCreator.create(user, + target_usernames: ['codinghorror'], + title: "this topic is about candy", + raw: "time to eat some sweet :candy: mmmm") + + uf = UserFirst.where(user_id: user.id, first_type: UserFirst.types[:used_emoji]).first + expect(uf).to be_blank + end + end end