diff options
Diffstat (limited to 'app/services/notes/update_service.rb')
-rw-r--r-- | app/services/notes/update_service.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/app/services/notes/update_service.rb b/app/services/notes/update_service.rb index 444656348ed..047848fd1a3 100644 --- a/app/services/notes/update_service.rb +++ b/app/services/notes/update_service.rb @@ -10,6 +10,7 @@ module Notes note.assign_attributes(params.merge(updated_by: current_user)) note.with_transaction_returning_status do + update_confidentiality(note) note.save end @@ -79,6 +80,15 @@ module Notes TodoService.new.update_note(note, current_user, old_mentioned_users) end + + # This method updates confidentiality of all discussion notes at once + def update_confidentiality(note) + return unless params.key?(:confidential) + return unless note.is_a?(DiscussionNote) # we don't need to do bulk update for single notes + return unless note.start_of_discussion? # don't update all notes if a response is being updated + + Note.id_in(note.discussion.notes.map(&:id)).update_all(confidential: params[:confidential]) + end end end |