Remove thread vars usage from API notes and mr's
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
		
							parent
							
								
									a7be3dfa30
								
							
						
					
					
						commit
						f8ea52c3a0
					
				|  | @ -5,7 +5,7 @@ class NoteObserver < BaseObserver | ||||||
|     # Skip system notes, like status changes and cross-references. |     # Skip system notes, like status changes and cross-references. | ||||||
|     # Skip wall notes to prevent spamming of dashboard |     # Skip wall notes to prevent spamming of dashboard | ||||||
|     if note.noteable_type.present? && !note.system |     if note.noteable_type.present? && !note.system | ||||||
|       event_service.leave_note(note, current_user) |       event_service.leave_note(note, note.author) | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     unless note.system? |     unless note.system? | ||||||
|  | @ -18,6 +18,6 @@ class NoteObserver < BaseObserver | ||||||
|   end |   end | ||||||
| 
 | 
 | ||||||
|   def after_update(note) |   def after_update(note) | ||||||
|     note.notice_added_references(note.project, current_user) |     note.notice_added_references(note.project, note.author) | ||||||
|   end |   end | ||||||
| end | end | ||||||
|  |  | ||||||
|  | @ -184,21 +184,18 @@ module API | ||||||
|       #   POST /projects/:id/merge_request/:merge_request_id/comments |       #   POST /projects/:id/merge_request/:merge_request_id/comments | ||||||
|       # |       # | ||||||
|       post ":id/merge_request/:merge_request_id/comments" do |       post ":id/merge_request/:merge_request_id/comments" do | ||||||
|         set_current_user_for_thread do |         required_attributes! [:note] | ||||||
|           required_attributes! [:note] |  | ||||||
| 
 | 
 | ||||||
|           merge_request = user_project.merge_requests.find(params[:merge_request_id]) |         merge_request = user_project.merge_requests.find(params[:merge_request_id]) | ||||||
|           note = merge_request.notes.new(note: params[:note], project_id: user_project.id) |         note = merge_request.notes.new(note: params[:note], project_id: user_project.id) | ||||||
|           note.author = current_user |         note.author = current_user | ||||||
| 
 | 
 | ||||||
|           if note.save |         if note.save | ||||||
|             present note, with: Entities::MRNote |           present note, with: Entities::MRNote | ||||||
|           else |         else | ||||||
|             not_found! |           not_found! | ||||||
|           end |  | ||||||
|         end |         end | ||||||
|       end |       end | ||||||
| 
 |  | ||||||
|     end |     end | ||||||
|   end |   end | ||||||
| end | end | ||||||
|  |  | ||||||
|  | @ -41,19 +41,17 @@ module API | ||||||
|       # Example Request: |       # Example Request: | ||||||
|       #   POST /projects/:id/notes |       #   POST /projects/:id/notes | ||||||
|       post ":id/notes" do |       post ":id/notes" do | ||||||
|         set_current_user_for_thread do |         required_attributes! [:body] | ||||||
|           required_attributes! [:body] |  | ||||||
| 
 | 
 | ||||||
|           @note = user_project.notes.new(note: params[:body]) |         @note = user_project.notes.new(note: params[:body]) | ||||||
|           @note.author = current_user |         @note.author = current_user | ||||||
| 
 | 
 | ||||||
|           if @note.save |         if @note.save | ||||||
|             present @note, with: Entities::Note |           present @note, with: Entities::Note | ||||||
|           else |         else | ||||||
|             # :note is exposed as :body, but :note is set on error |           # :note is exposed as :body, but :note is set on error | ||||||
|             bad_request!(:note) if @note.errors[:note].any? |           bad_request!(:note) if @note.errors[:note].any? | ||||||
|             not_found! |           not_found! | ||||||
|           end |  | ||||||
|         end |         end | ||||||
|       end |       end | ||||||
| 
 | 
 | ||||||
|  | @ -99,19 +97,17 @@ module API | ||||||
|         #   POST /projects/:id/issues/:noteable_id/notes |         #   POST /projects/:id/issues/:noteable_id/notes | ||||||
|         #   POST /projects/:id/snippets/:noteable_id/notes |         #   POST /projects/:id/snippets/:noteable_id/notes | ||||||
|         post ":id/#{noteables_str}/:#{noteable_id_str}/notes" do |         post ":id/#{noteables_str}/:#{noteable_id_str}/notes" do | ||||||
|           set_current_user_for_thread do |           required_attributes! [:body] | ||||||
|             required_attributes! [:body] |  | ||||||
| 
 | 
 | ||||||
|             @noteable = user_project.send(:"#{noteables_str}").find(params[:"#{noteable_id_str}"]) |           @noteable = user_project.send(:"#{noteables_str}").find(params[:"#{noteable_id_str}"]) | ||||||
|             @note = @noteable.notes.new(note: params[:body]) |           @note = @noteable.notes.new(note: params[:body]) | ||||||
|             @note.author = current_user |           @note.author = current_user | ||||||
|             @note.project = user_project |           @note.project = user_project | ||||||
| 
 | 
 | ||||||
|             if @note.save |           if @note.save | ||||||
|               present @note, with: Entities::Note |             present @note, with: Entities::Note | ||||||
|             else |           else | ||||||
|               not_found! |             not_found! | ||||||
|             end |  | ||||||
|           end |           end | ||||||
|         end |         end | ||||||
|       end |       end | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue