diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-15 03:07:23 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-15 03:07:23 +0300 |
commit | afd8f58f2d0d42d21496fe4652c1664add9b68b7 (patch) | |
tree | 38741f62cac6fafb42d30632596db951ec955850 /app/services/notes | |
parent | beabc7d164276a8bb35c2b497a0c4dc0dc824e3c (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services/notes')
-rw-r--r-- | app/services/notes/update_service.rb | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/app/services/notes/update_service.rb b/app/services/notes/update_service.rb index ff9f39ce0be..52940281018 100644 --- a/app/services/notes/update_service.rb +++ b/app/services/notes/update_service.rb @@ -9,6 +9,8 @@ module Notes note.assign_attributes(params) + return note unless note.valid? + track_note_edit_usage_for_issues(note) if note.for_issue? track_note_edit_usage_for_merge_requests(note) if note.for_merge_request? @@ -23,11 +25,7 @@ module Notes note.note = content end - if note.note_changed? - note.assign_attributes(last_edited_at: Time.current, updated_by: current_user) - note.check_for_spam(action: :update, user: current_user) unless only_commands - end - + update_note(note, only_commands) note.save unless only_commands || note.for_personal_snippet? @@ -56,6 +54,13 @@ module Notes private + def update_note(note, only_commands) + return unless note.note_changed? + + note.assign_attributes(last_edited_at: Time.current, updated_by: current_user) + note.check_for_spam(action: :update, user: current_user) unless only_commands + end + def delete_note(note, message) # We must add the error after we call #save because errors are reset # when #save is called |