- ##
- # Adds a subscriber to the changeset
- def subscribe
- # Check the arguments are sane
- raise OSM::APIBadUserInput, "No id was given" unless params[:id]
-
- # Extract the arguments
- id = params[:id].to_i
-
- # Find the changeset and check it is valid
- changeset = Changeset.find(id)
- raise OSM::APIChangesetAlreadySubscribedError, changeset if changeset.subscribers.include?(current_user)
-
- # Add the subscriber
- changeset.subscribers << current_user
-
- # Return a copy of the updated changeset
- @changeset = changeset
- render "show"
-
- respond_to do |format|
- format.xml
- format.json
- end
- end
-
- ##
- # Removes a subscriber from the changeset
- def unsubscribe
- # Check the arguments are sane
- raise OSM::APIBadUserInput, "No id was given" unless params[:id]
-
- # Extract the arguments
- id = params[:id].to_i
-
- # Find the changeset and check it is valid
- changeset = Changeset.find(id)
- raise OSM::APIChangesetNotSubscribedError, changeset unless changeset.subscribers.include?(current_user)
-
- # Remove the subscriber
- changeset.subscribers.delete(current_user)
-
- # Return a copy of the updated changeset
- @changeset = changeset
- render "show"
-
- respond_to do |format|
- format.xml
- format.json
- end
- end
-