- ##
- # Read a note
- def show
- # Check the arguments are sane
- raise OSM::APIBadUserInput, "No id was given" unless params[:id]
-
- # Find the note and check it is valid
- @note = Note.find(params[:id])
- raise OSM::APINotFoundError unless @note
- raise OSM::APIAlreadyDeletedError.new("note", @note.id) unless @note.visible? || current_user&.moderator?
-
- # Render the result
- respond_to do |format|
- format.xml
- format.rss
- format.json
- format.gpx
- end
- end
-
- ##
- # Delete (hide) a note
- def destroy
- # Check the arguments are sane
- raise OSM::APIBadUserInput, "No id was given" unless params[:id]
-
- # Extract the arguments
- id = params[:id].to_i
- comment = params[:text]
-
- # Find the note and check it is valid
- @note = Note.find(id)
- raise OSM::APINotFoundError unless @note
- raise OSM::APIAlreadyDeletedError.new("note", @note.id) unless @note.visible?
-
- # Mark the note as hidden
- Note.transaction do
- @note.status = "hidden"
- @note.save
-
- add_comment(@note, comment, "hidden", :notify => false)
- end
-
- # Return a copy of the updated note
- respond_to do |format|
- format.xml { render :action => :show }
- format.json { render :action => :show }
- end
- end
-