diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2018-04-05 12:41:01 +0000 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2018-04-05 12:41:01 +0000 |
commit | 63a1a57024e54ff6aee1f099ca7b431a7bb0e669 (patch) | |
tree | 2cc4cf8dc4fe6a874edfe763d9a498cb41f7f457 /app | |
parent | f9607db7a4db87b07ed2f2634794f99084a6534d (diff) | |
parent | c1946364707947f56048cc00caa6d67fe635f3c7 (diff) | |
download | gitlab-ce-63a1a57024e54ff6aee1f099ca7b431a7bb0e669.tar.gz |
Merge branch 'jprovazn-comment-refs' into 'master'
Better group support in notes-related code
See merge request gitlab-org/gitlab-ce!18150
Diffstat (limited to 'app')
-rw-r--r-- | app/models/note.rb | 4 | ||||
-rw-r--r-- | app/services/notes/post_process_service.rb | 4 | ||||
-rw-r--r-- | app/services/system_note_service.rb | 4 | ||||
-rw-r--r-- | app/workers/new_note_worker.rb | 2 |
4 files changed, 10 insertions, 4 deletions
diff --git a/app/models/note.rb b/app/models/note.rb index 109405d3f17..e426f84832b 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -317,6 +317,10 @@ class Note < ActiveRecord::Base !system? && !for_snippet? end + def can_create_notification? + true + end + def discussion_class(noteable = nil) # When commit notes are rendered on an MR's Discussion page, they are # displayed in one discussion instead of individually. diff --git a/app/services/notes/post_process_service.rb b/app/services/notes/post_process_service.rb index f0cab2ade6d..199b8028dbc 100644 --- a/app/services/notes/post_process_service.rb +++ b/app/services/notes/post_process_service.rb @@ -11,7 +11,7 @@ module Notes unless @note.system? EventCreateService.new.leave_note(@note, @note.author) - return unless @note.for_project_noteable? + return if @note.for_personal_snippet? @note.create_cross_references! execute_note_hooks @@ -23,6 +23,8 @@ module Notes end def execute_note_hooks + return unless @note.project + note_data = hook_data hooks_scope = @note.confidential? ? :confidential_note_hooks : :note_hooks diff --git a/app/services/system_note_service.rb b/app/services/system_note_service.rb index 2253d638e93..00bf5434b7f 100644 --- a/app/services/system_note_service.rb +++ b/app/services/system_note_service.rb @@ -429,7 +429,7 @@ module SystemNoteService def cross_reference(noteable, mentioner, author) return if cross_reference_disallowed?(noteable, mentioner) - gfm_reference = mentioner.gfm_reference(noteable.project) + gfm_reference = mentioner.gfm_reference(noteable.project || noteable.group) body = cross_reference_note_content(gfm_reference) if noteable.is_a?(ExternalIssue) @@ -582,7 +582,7 @@ module SystemNoteService text = "#{cross_reference_note_prefix}%#{mentioner.to_reference(nil)}" notes.where('(note LIKE ? OR note LIKE ?)', text, text.capitalize) else - gfm_reference = mentioner.gfm_reference(noteable.project) + gfm_reference = mentioner.gfm_reference(noteable.project || noteable.group) text = cross_reference_note_content(gfm_reference) notes.where(note: [text, text.capitalize]) end diff --git a/app/workers/new_note_worker.rb b/app/workers/new_note_worker.rb index 67c54fbf10e..b925741934a 100644 --- a/app/workers/new_note_worker.rb +++ b/app/workers/new_note_worker.rb @@ -5,7 +5,7 @@ class NewNoteWorker # old `NewNoteWorker` jobs (can remove later) def perform(note_id, _params = {}) if note = Note.find_by(id: note_id) - NotificationService.new.new_note(note) + NotificationService.new.new_note(note) if note.can_create_notification? Notes::PostProcessService.new(note).execute else Rails.logger.error("NewNoteWorker: couldn't find note with ID=#{note_id}, skipping job") |