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