X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/dbb462ca0ff432c94c00911340ab4c7619504844..605d7a5f694ca2e3310f65267c50f20d2a7ee5cd:/app/controllers/api/notes_controller.rb diff --git a/app/controllers/api/notes_controller.rb b/app/controllers/api/notes_controller.rb index c141bdf46..eca0728b6 100644 --- a/app/controllers/api/notes_controller.rb +++ b/app/controllers/api/notes_controller.rb @@ -384,11 +384,7 @@ module Api def add_comment(note, text, event, notify: true) attributes = { :visible => true, :event => event, :body => text } - if doorkeeper_token - author = current_user if scope_enabled?(:write_notes) - else - author = current_user - end + author = current_user if scope_enabled?(:write_notes) if author attributes[:author_id] = author.id @@ -398,8 +394,10 @@ module Api comment = note.comments.create!(attributes) - note.comments.map(&:author).uniq.each do |user| - UserMailer.note_comment_notification(comment, user).deliver_later if notify && user && user != current_user && user.visible? + if notify + note.subscribers.visible.each do |user| + UserMailer.note_comment_notification(comment, user).deliver_later if current_user != user + end end NoteSubscription.find_or_create_by(:note => note, :user => current_user) if current_user