X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/edd12c6995aa5f8ef5d6c8d898e42d1a5931430f..257f4673e1dd86a3704f6a965e5e077283a04a00:/app/controllers/api/note_subscriptions_controller.rb?ds=sidebyside diff --git a/app/controllers/api/note_subscriptions_controller.rb b/app/controllers/api/note_subscriptions_controller.rb index 348b428b6..c416dd803 100644 --- a/app/controllers/api/note_subscriptions_controller.rb +++ b/app/controllers/api/note_subscriptions_controller.rb @@ -14,5 +14,14 @@ module Api rescue ActiveRecord::RecordNotUnique report_error "You are already subscribed to note #{note_id}.", :conflict end + + def destroy + note_id = params[:note_id].to_i + note = Note.find(note_id) + count = note.subscriptions.where(:user => current_user).delete_all + report_error "You are not subscribed to note #{note_id}.", :not_found if count.zero? + rescue ActiveRecord::RecordNotFound + report_error "Note #{note_id} not found.", :not_found + end end end