Commit 28487423 authored by Alex Kalderimis's avatar Alex Kalderimis

Merge branch 'prevent-notifications-from-ghost-user' into 'master'

Prevent new note notifications from Ghost user

See merge request gitlab-org/gitlab!53699
parents e6884003 0d75c6cc
...@@ -13,7 +13,7 @@ class NewNoteWorker # rubocop:disable Scalability/IdempotentWorker ...@@ -13,7 +13,7 @@ class NewNoteWorker # rubocop:disable Scalability/IdempotentWorker
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def perform(note_id, _params = {}) def perform(note_id, _params = {})
if note = Note.find_by(id: note_id) if note = Note.find_by(id: note_id)
NotificationService.new.new_note(note) unless note.skip_notification? NotificationService.new.new_note(note) unless note.skip_notification? || note.author.ghost?
Notes::PostProcessService.new(note).execute Notes::PostProcessService.new(note).execute
else else
Gitlab::AppLogger.error("NewNoteWorker: couldn't find note with ID=#{note_id}, skipping job") Gitlab::AppLogger.error("NewNoteWorker: couldn't find note with ID=#{note_id}, skipping job")
......
---
title: Skip new note notifications when author is deleted
merge_request: 53699
author:
type: changed
...@@ -65,4 +65,14 @@ RSpec.describe NewNoteWorker do ...@@ -65,4 +65,14 @@ RSpec.describe NewNoteWorker do
subject.perform(note.id) subject.perform(note.id)
end end
end end
context 'when Note author has been deleted' do
let_it_be(:note) { create(:note, author: User.ghost) }
it "does not call NotificationService" do
expect(NotificationService).not_to receive(:new)
described_class.new.perform(note.id)
end
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment