media assets: add image redirect routes.
Add URLs that redirect from a media asset to the image: * https://danbooru.donmai.us/media_assets/6961761/original -> https://cdn.donmai.us/original/2c/4f/2c4ff193b0fc7106e59b2f6696a68a02.jpg * https://danbooru.donmai.us/media_assets/6961761/sample -> https://cdn.donmai.us/sample/2c/4f/sample-2c4ff193b0fc7106e59b2f6696a68a02.jpg * https://danbooru.donmai.us/media_assets/6961761/720x720 -> https://cdn.donmai.us/180x180/2c/4f/2c4ff193b0fc7106e59b2f6696a68a02.webp * https://danbooru.donmai.us/media_assets/6961761/360x360 -> https://cdn.donmai.us/180x180/2c/4f/2c4ff193b0fc7106e59b2f6696a68a02.jpg * https://danbooru.donmai.us/media_assets/6961761/180x180 -> https://cdn.donmai.us/180x180/2c/4f/2c4ff193b0fc7106e59b2f6696a68a02.jpg This is useful if you have a media asset ID and want to get to the image without looking up the image URL in the API. This endpoint is rate-limited to 5 requests per second. It's not meant to be used for things like thumbnail galleries or bulk scraping images.
This commit is contained in:
@@ -5,6 +5,10 @@ class MediaAssetPolicy < ApplicationPolicy
|
||||
true
|
||||
end
|
||||
|
||||
def image?
|
||||
can_see_image?
|
||||
end
|
||||
|
||||
def can_see_image?
|
||||
record.post.blank? || record.post.visible?(user)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user