Skip to content

Conversation

@AntonKhorev
Copy link
Collaborator

Going through the DWG Wishlist, there was a blocks api.

Currently scripted blocks in osmtools are done by emulating the browser, loading webpages and filling out forms. That requires passing the password around. It would be better to be able to access block functionality with a proper api and an oauth token.

But before doing block creation, there need to be block read api endpoints. Here the xml block show method is added at /api/0.6/user_blocks/:id with an output like:

<osm version="0.6" ...>
<user_block id="6" created_at="2023-08-01T15:55:58Z" updated_at="2023-08-05T00:46:36Z" ends_at="2023-08-05T00:46:36Z" needs_view="false">
  <user uid="1" user="fakeuser1"/>
  <creator uid="2" user="fakemod1"/>
  <revoker uid="2" user="fakemod1"/>
  <reason>longer block test</reason>
</user_block>
</osm>

All of this is already accessible through the web ui at /user_blocks/:id.

@mmd-osm
Copy link
Contributor

mmd-osm commented Sep 8, 2023

#1618 seems to be related to this one

Copy link
Member

@tomhughes tomhughes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we be adding JSON output as well?

@AntonKhorev
Copy link
Collaborator Author

#1618 seems to be related to this one

This PR alone won't be enough for what was originally asked there. The next required thing is a search endpoint with the ability to search by usernames/ids.

Should we be adding JSON output as well?

Yes, if the xml output format is ok. The biggest decision here was to make separate user/creator/revoker subelements.

@tomhughes
Copy link
Member

I assume there's nothing being exposed here that isn't already visible through the web interface? I think pretty much everything is visible there already?

@mmd-osm
Copy link
Contributor

mmd-osm commented Sep 10, 2023

As a normal user, I don't see any of the "uid" values in the web interface, neither for the user which has been blocked, nor for the creator and potential block revoker.

By the way, does this also work for deleted users, like this one: https://www.openstreetmap.org/user_blocks/14719

before_action :set_request_formats

def show
raise OSM::APIBadUserInput, "No id was given" unless params[:id]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe make it a bit clearer, which "id" we expect here, like "No user block id was given".

@tomhughes
Copy link
Member

As a normal user, I don't see any of the "uid" values in the web interface, neither for the user which has been blocked,
nor for the creator and potential block revoker.

Right, but in general the mapping between username and ids is not hidden - the user details call will get it for example.

@AntonKhorev
Copy link
Collaborator Author

The web interface prefers to work with usernames while the api prefers user ids. For example you need a user id for user details. When you know a username and want to get the corresponding id through the api, you typically do a changeset search by the username and get the id from the search results. It's only difficult to do if the user has no contributions, but then, if it's a genuine user and not a pre-blocked vandal account, there has to be a problem with their contributions and changesets (or notes) searchable by the username exist.

@tomhughes tomhughes merged commit 85b17a1 into openstreetmap:master Sep 14, 2023
@AntonKhorev AntonKhorev deleted the blocks-api branch September 15, 2023 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants