[openstreetmap/openstreetmap-website] API changeset comment visibility resource (PR #5726)

Anton Khorev notifications at github.com
Sun Feb 23 23:05:14 UTC 2025


Previously there were `hide` and `unhide` actions on changeset comments and an attempt to change them into standard actions which didn't quite work. It went like this: hiding a comment is like deleting, let's map `hide` path to `destroy` action; unhiding is like... there's no standard undelete/undestroy, let's invent another nonstandard `restore` name for now. `create` couldn't be used as an opposite action because it creates a new comment.

However `destroy` and `create` could be used if another resource is introduced. That's what this PR does. Since these operations change `visible` attributes, I guess the resource name should be `visibility`. Then we'll have something similar to message `read_mark` from #5536 that can be created and deleted and also changes an attribute.

That requires a different path. Since the collection path was already introduced in #4359 as `/api/0.6/changeset_comments`, the visibility resource path should be`/api/0.6/changeset_comments/:id/visibility`. `DELETE`/`POST` at this path hide/unhide the comment. For backwards compatibility `POST /api/0.6/changeset/comment/:id/hide` is mapped to `destroy` and `POST /api/0.6/changeset/comment/:id/unhide` is mapped to `create` actions on visibility.

This removes all nonstandard actions from changeset comments controller.
You can view, comment on, or merge this pull request online at:

  https://github.com/openstreetmap/openstreetmap-website/pull/5726

-- Commit Summary --

  * Test response body of changeset comment hide/unhide
  * Create api changeset comment visibility resource
  * Refactor api changeset comment visibility xml tests
  * Refactor api changeset comment visibility json tests
  * Test api changeset comment hide/unhide at legacy routes
  * Remove unnecessary RuboCop exclusion

-- File Changes --

    M .rubocop.yml (1)
    M app/abilities/api_ability.rb (2)
    A app/controllers/api/changeset_comments/visibilities_controller.rb (60)
    M app/controllers/api/changeset_comments_controller.rb (50)
    M app/controllers/api/changesets_controller.rb (2)
    A app/views/api/changeset_comments/visibilities/create.json.jbuilder (5)
    A app/views/api/changeset_comments/visibilities/create.xml.builder (5)
    A app/views/api/changeset_comments/visibilities/destroy.json.jbuilder (5)
    A app/views/api/changeset_comments/visibilities/destroy.xml.builder (5)
    M app/views/changesets/show.html.erb (4)
    M config/routes.rb (8)
    M test/abilities/api_capability_test.rb (28)
    A test/controllers/api/changeset_comments/visibilities_controller_test.rb (253)
    M test/controllers/api/changeset_comments_controller_test.rb (130)

-- Patch Links --

https://github.com/openstreetmap/openstreetmap-website/pull/5726.patch
https://github.com/openstreetmap/openstreetmap-website/pull/5726.diff

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/5726
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/openstreetmap-website/pull/5726 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20250223/77203fc8/attachment.htm>


More information about the rails-dev mailing list