Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notes throw errors if there are no visible comments #3450

Open
gravitystorm opened this issue Feb 9, 2022 · 6 comments
Open

Notes throw errors if there are no visible comments #3450

gravitystorm opened this issue Feb 9, 2022 · 6 comments
Labels
bug Something is broken or not working as expected notes Related to the notes feature refactor Refactoring, or things that work but could be done better

Comments

@gravitystorm
Copy link
Collaborator

It's not possible to view a note if there are no visible comments. This can come about either:

In both cases, you get errors, albeit different ones in each case. But the point remains that there's a lot of (untested) logic that assumes there's at least one note comment visible.

Related:

@gravitystorm gravitystorm added bug Something is broken or not working as expected refactor Refactoring, or things that work but could be done better labels Feb 9, 2022
@mmd-osm
Copy link
Contributor

mmd-osm commented Feb 10, 2022

I thought I tested a scenario where all notes were hidden, and I don't remember seeing an error message for non-moderators. Hmm.

@gravitystorm
Copy link
Collaborator Author

gravitystorm commented Feb 10, 2022

I think with the UI that you made in #3441 you don't surface the option to hide the first comment, but there's no similar restriction in the API implementation in #3438. I haven't checked that conclusively though. So if you use the UI that you wrote then you won't hit the problem.

@mmd-osm
Copy link
Contributor

mmd-osm commented Feb 10, 2022

Good point. What would be your suggestion here? Should the new API endpoint block any attempts to delete the first comment?
Besides, "Resolved by..." and "Reactivated by..." can be hidden / un-hidden in the new UI. I don't see this as a bug, as a moderator might want to hide excessive closing/reactivating of notes to get rid of some clutter.

      # Find the note comment
      comment = NoteComment.find(id)

      # Opening comment cannot be hidden
      raise OSM::APIBadUserInput, "Cannot hide id" if comment.event == "opened"

      # Hide the comment
      comment.update(:visible => false)

@gravitystorm
Copy link
Collaborator Author

Good point. What would be your suggestion here?

I don't know. I think relying on the fact that the first comment has the "opened" event, and that there's no other "opened" events, seems fragile - but I'm not entirely sure why I feel that. But maybe that's a workaround until we sort things out properly?

@mmd-osm
Copy link
Contributor

mmd-osm commented Feb 17, 2022

Hmm. An "opened" event is used exclusively when creating a new note. https://github.com/openstreetmap/openstreetmap-website/blob/master/app/controllers/api/notes_controller.rb#L76

I think what needs to be clarified first is whether we want the opening event to be hidden at all. Depending on this decision other parts of the code need to be adjusted to handle this case properly.

@gravitystorm
Copy link
Collaborator Author

I've moved the discussion of the "opened" comment to the PR in #3438 , since this issue is to deal with the wider problems of the current implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is broken or not working as expected notes Related to the notes feature refactor Refactoring, or things that work but could be done better
Projects
None yet
Development

No branches or pull requests

2 participants