diff options
Diffstat (limited to 'app/models/note.rb')
-rw-r--r-- | app/models/note.rb | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/app/models/note.rb b/app/models/note.rb index 4b6748053ff..585d8c4ad84 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -88,9 +88,22 @@ class Note < ActiveRecord::Base table = arel_table pattern = "%#{query}%" - Note.joins('LEFT JOIN issues ON issues.id = noteable_id'). - where(table[:note].matches(pattern)). - merge(Issue.visible_to_user(as_user)) + found_notes = joins('LEFT JOIN issues ON issues.id = noteable_id'). + where(table[:note].matches(pattern)) + + if as_user + found_notes.where(' + issues.confidential IS NULL + OR issues.confidential IS FALSE + OR (issues.confidential IS TRUE + AND (issues.author_id = :user_id + OR issues.assignee_id = :user_id + OR issues.project_id IN(:project_ids)))', + user_id: as_user.id, + project_ids: as_user.authorized_projects.select(:id)) + else + found_notes.where('issues.confidential IS NULL OR issues.confidential IS FALSE') + end end end @@ -187,10 +200,6 @@ class Note < ActiveRecord::Base award_emoji_supported? && contains_emoji_only? end - def emoji_awardable? - !system? - end - def clear_blank_line_code! self.line_code = nil if self.line_code.blank? end |