[openstreetmap/openstreetmap-website] Add user block api call (PR #4301)
Anton Khorev
notifications at github.com
Sat Oct 21 16:10:53 UTC 2023
@AntonKhorev commented on this pull request.
> + def create
+ raise OSM::APIBadUserInput, "No user was given" unless params[:user]
+
+ user = User.visible.find_by(:id => params[:user])
+ raise OSM::APINotFoundError unless user
+ raise OSM::APIBadUserInput, "No reason was given" unless params[:reason]
+ raise OSM::APIBadUserInput, "No period was given" unless params[:period]
+
+ period = Integer(params[:period], :exception => false)
+ raise OSM::APIBadUserInput, "Period one is in a wrong format" unless period
+
+ max_period = UserBlock::PERIODS.max
+ raise OSM::APIBadUserInput, "Period must be between 0 and #{max_period}" if period.negative? || period > max_period
+ raise OSM::APIBadUserInput, "Needs_view must be true if provided" unless params[:needs_view].nil? || params[:needs_view] == "true"
+
+ @user_block = UserBlock.create(
> What should happen if the user to be blocked is already currently blocked? Or if we're trying to POST the same user block twice, and introduce duplicates.
You can create multiple blocks from the web interface.
Currently we have two qualitatively different block types: one that requires reading the message and one that doesn't. In the future there might be more types. It might be useful to have multiple active blocks with different periods at the same time.
--
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/4301#discussion_r1367753443
You are receiving this because you are subscribed to this thread.
Message ID: <openstreetmap/openstreetmap-website/pull/4301/review/1691283964 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20231021/b330798d/attachment.htm>
More information about the rails-dev
mailing list