Commit f8ea52c3a0fe29daf76fbd7a0e65399c09c95f5a
1 parent
a7be3dfa
Exists in
spb-stable
and in
2 other branches
Remove thread vars usage from API notes and mr's
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Showing
3 changed files
with
28 additions
and
35 deletions
Show diff stats
app/observers/note_observer.rb
| ... | ... | @@ -5,7 +5,7 @@ class NoteObserver < BaseObserver |
| 5 | 5 | # Skip system notes, like status changes and cross-references. |
| 6 | 6 | # Skip wall notes to prevent spamming of dashboard |
| 7 | 7 | if note.noteable_type.present? && !note.system |
| 8 | - event_service.leave_note(note, current_user) | |
| 8 | + event_service.leave_note(note, note.author) | |
| 9 | 9 | end |
| 10 | 10 | |
| 11 | 11 | unless note.system? |
| ... | ... | @@ -18,6 +18,6 @@ class NoteObserver < BaseObserver |
| 18 | 18 | end |
| 19 | 19 | |
| 20 | 20 | def after_update(note) |
| 21 | - note.notice_added_references(note.project, current_user) | |
| 21 | + note.notice_added_references(note.project, note.author) | |
| 22 | 22 | end |
| 23 | 23 | end | ... | ... |
lib/api/merge_requests.rb
| ... | ... | @@ -184,21 +184,18 @@ module API |
| 184 | 184 | # POST /projects/:id/merge_request/:merge_request_id/comments |
| 185 | 185 | # |
| 186 | 186 | post ":id/merge_request/:merge_request_id/comments" do |
| 187 | - set_current_user_for_thread do | |
| 188 | - required_attributes! [:note] | |
| 187 | + required_attributes! [:note] | |
| 189 | 188 | |
| 190 | - merge_request = user_project.merge_requests.find(params[:merge_request_id]) | |
| 191 | - note = merge_request.notes.new(note: params[:note], project_id: user_project.id) | |
| 192 | - note.author = current_user | |
| 189 | + merge_request = user_project.merge_requests.find(params[:merge_request_id]) | |
| 190 | + note = merge_request.notes.new(note: params[:note], project_id: user_project.id) | |
| 191 | + note.author = current_user | |
| 193 | 192 | |
| 194 | - if note.save | |
| 195 | - present note, with: Entities::MRNote | |
| 196 | - else | |
| 197 | - not_found! | |
| 198 | - end | |
| 193 | + if note.save | |
| 194 | + present note, with: Entities::MRNote | |
| 195 | + else | |
| 196 | + not_found! | |
| 199 | 197 | end |
| 200 | 198 | end |
| 201 | - | |
| 202 | 199 | end |
| 203 | 200 | end |
| 204 | 201 | end | ... | ... |
lib/api/notes.rb
| ... | ... | @@ -41,19 +41,17 @@ module API |
| 41 | 41 | # Example Request: |
| 42 | 42 | # POST /projects/:id/notes |
| 43 | 43 | post ":id/notes" do |
| 44 | - set_current_user_for_thread do | |
| 45 | - required_attributes! [:body] | |
| 44 | + required_attributes! [:body] | |
| 46 | 45 | |
| 47 | - @note = user_project.notes.new(note: params[:body]) | |
| 48 | - @note.author = current_user | |
| 46 | + @note = user_project.notes.new(note: params[:body]) | |
| 47 | + @note.author = current_user | |
| 49 | 48 | |
| 50 | - if @note.save | |
| 51 | - present @note, with: Entities::Note | |
| 52 | - else | |
| 53 | - # :note is exposed as :body, but :note is set on error | |
| 54 | - bad_request!(:note) if @note.errors[:note].any? | |
| 55 | - not_found! | |
| 56 | - end | |
| 49 | + if @note.save | |
| 50 | + present @note, with: Entities::Note | |
| 51 | + else | |
| 52 | + # :note is exposed as :body, but :note is set on error | |
| 53 | + bad_request!(:note) if @note.errors[:note].any? | |
| 54 | + not_found! | |
| 57 | 55 | end |
| 58 | 56 | end |
| 59 | 57 | |
| ... | ... | @@ -99,19 +97,17 @@ module API |
| 99 | 97 | # POST /projects/:id/issues/:noteable_id/notes |
| 100 | 98 | # POST /projects/:id/snippets/:noteable_id/notes |
| 101 | 99 | post ":id/#{noteables_str}/:#{noteable_id_str}/notes" do |
| 102 | - set_current_user_for_thread do | |
| 103 | - required_attributes! [:body] | |
| 100 | + required_attributes! [:body] | |
| 104 | 101 | |
| 105 | - @noteable = user_project.send(:"#{noteables_str}").find(params[:"#{noteable_id_str}"]) | |
| 106 | - @note = @noteable.notes.new(note: params[:body]) | |
| 107 | - @note.author = current_user | |
| 108 | - @note.project = user_project | |
| 102 | + @noteable = user_project.send(:"#{noteables_str}").find(params[:"#{noteable_id_str}"]) | |
| 103 | + @note = @noteable.notes.new(note: params[:body]) | |
| 104 | + @note.author = current_user | |
| 105 | + @note.project = user_project | |
| 109 | 106 | |
| 110 | - if @note.save | |
| 111 | - present @note, with: Entities::Note | |
| 112 | - else | |
| 113 | - not_found! | |
| 114 | - end | |
| 107 | + if @note.save | |
| 108 | + present @note, with: Entities::Note | |
| 109 | + else | |
| 110 | + not_found! | |
| 115 | 111 | end |
| 116 | 112 | end |
| 117 | 113 | end | ... | ... |