2018-06-27 07:23:28 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-02-19 18:09:10 +00:00
|
|
|
class NewNoteWorker # rubocop:disable Scalability/IdempotentWorker
|
2017-11-28 16:08:30 +00:00
|
|
|
include ApplicationWorker
|
2016-01-27 15:59:16 +00:00
|
|
|
|
2019-10-18 11:11:44 +00:00
|
|
|
feature_category :issue_tracking
|
2020-03-02 18:07:42 +00:00
|
|
|
urgency :high
|
2019-10-30 15:14:17 +00:00
|
|
|
worker_resource_boundary :cpu
|
2020-01-24 18:09:00 +00:00
|
|
|
weight 2
|
2019-10-18 11:11:44 +00:00
|
|
|
|
2016-11-19 18:18:44 +00:00
|
|
|
# Keep extra parameter to preserve backwards compatibility with
|
|
|
|
# old `NewNoteWorker` jobs (can remove later)
|
2018-08-27 15:31:01 +00:00
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2016-11-19 18:18:44 +00:00
|
|
|
def perform(note_id, _params = {})
|
2016-10-13 15:26:44 +00:00
|
|
|
if note = Note.find_by(id: note_id)
|
2018-12-07 14:24:37 +00:00
|
|
|
NotificationService.new.new_note(note) unless skip_notification?(note)
|
2016-10-13 15:26:44 +00:00
|
|
|
Notes::PostProcessService.new(note).execute
|
|
|
|
else
|
2020-05-21 21:08:31 +00:00
|
|
|
Gitlab::AppLogger.error("NewNoteWorker: couldn't find note with ID=#{note_id}, skipping job")
|
2016-10-13 15:26:44 +00:00
|
|
|
end
|
2016-01-27 15:59:16 +00:00
|
|
|
end
|
2020-05-28 09:08:05 +00:00
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2018-12-07 14:24:37 +00:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def skip_notification?(note)
|
2020-05-28 09:08:05 +00:00
|
|
|
note.review.present?
|
2018-12-07 14:24:37 +00:00
|
|
|
end
|
2016-01-27 15:59:16 +00:00
|
|
|
end
|