diff options
author | Jarka Kadlecova <jarka@gitlab.com> | 2017-05-03 10:48:01 +0200 |
---|---|---|
committer | Jarka Kadlecova <jarka@gitlab.com> | 2017-05-05 15:45:49 +0200 |
commit | e4f7b87ddb4ba83456871eb83b841192b1b56799 (patch) | |
tree | cf79d159784d2c5573acf8a56a8ea09bccaf2d81 /app/services/notes | |
parent | 729c006ff82fcb87afe8eb3e6a21254892f43afd (diff) | |
download | gitlab-ce-e4f7b87ddb4ba83456871eb83b841192b1b56799.tar.gz |
Support comments for personal snippets
Diffstat (limited to 'app/services/notes')
-rw-r--r-- | app/services/notes/build_service.rb | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/app/services/notes/build_service.rb b/app/services/notes/build_service.rb index ea7cacc956c..abf25bb778b 100644 --- a/app/services/notes/build_service.rb +++ b/app/services/notes/build_service.rb @@ -3,8 +3,8 @@ module Notes def execute in_reply_to_discussion_id = params.delete(:in_reply_to_discussion_id) - if project && in_reply_to_discussion_id.present? - discussion = project.notes.find_discussion(in_reply_to_discussion_id) + if in_reply_to_discussion_id.present? + discussion = find_discussion(in_reply_to_discussion_id) unless discussion note = Note.new @@ -21,5 +21,19 @@ module Notes note end + + def find_discussion(discussion_id) + if project + project.notes.find_discussion(discussion_id) + else + # only PersonalSnippets can have discussions without project association + discussion = Note.find_discussion(discussion_id) + noteable = discussion.noteable + + return nil unless noteable.is_a?(PersonalSnippet) && can?(current_user, :comment_personal_snippet, noteable) + + discussion + end + end end end |