* Documents the new /profile-images/:username API endpoint * Introduces the /api/profile_images/:username endpoint This endpoint receives either an user or organization username as input via the URL path and returns the profile image information for that user/orgnization. * Updates the /api/profile_images/:username response Adapts the response according to the review comments: 1. Removes the cache directives 1. Tweaks how the user query is being done 1. Adds a `image_of` property to the response * Bump API version Co-authored-by: rhymes <rhymes@hey.com> Co-authored-by: Molly Struve <mollylbs@gmail.com>
27 lines
583 B
Ruby
27 lines
583 B
Ruby
module Api
|
|
module V0
|
|
class ProfileImagesController < ApiController
|
|
def show
|
|
not_found unless profile_image_owner
|
|
|
|
@profile_image_owner = profile_image_owner
|
|
end
|
|
|
|
private
|
|
|
|
def profile_image_owner
|
|
user || organization
|
|
end
|
|
|
|
def user
|
|
@user ||= User.registered.select(:id, :profile_image)
|
|
.find_by(username: params[:username])
|
|
end
|
|
|
|
def organization
|
|
@organization ||= Organization.select(:id, :profile_image)
|
|
.find_by(username: params[:username])
|
|
end
|
|
end
|
|
end
|
|
end
|