//! Pictures: E-9 upload, E-10 remove, E-11 download (AC-4.4). //! //! Registered and annotated by M2a; M3 owns this file and implements the handlers (until then 501 //! `not_implemented`). use crate::api::{IdPath, not_implemented}; use crate::auth::AuthDevice; use crate::error::AppError; use crate::openapi::responses::{ BadRequest, NotFound, PayloadTooLarge, Unprocessable, UnsupportedMediaType, }; use crate::wire::{IntSchema, JpegBytes, PictureSizeSchema, PngBytes, User, UuidSchema, WebpBytes}; #[utoipa::path( put, path = "/me/picture", operation_id = "putMePicture", summary = "E-9 Upload own picture", description = "JPEG, PNG or WebP up to 5 MiB and 8000 × 8000 px; processed per AC-4.4.", request_body(content((JpegBytes = "image/jpeg"), (PngBytes = "image/png"), (WebpBytes = "image/webp"))), responses( (status = 200, description = "The user with the new `picture_version`.", body = User, content_type = "application/json; charset=utf-8"), (status = 413, response = PayloadTooLarge), (status = 415, response = UnsupportedMediaType), (status = 422, response = Unprocessable), ) )] pub async fn put_me_picture(_device: AuthDevice) -> AppError { not_implemented() } #[utoipa::path( delete, path = "/me/picture", operation_id = "deleteMePicture", summary = "E-10 Remove own picture", description = "Idempotent.", responses( (status = 200, description = "The user with `picture_version` null.", body = User, content_type = "application/json; charset=utf-8"), ) )] pub async fn delete_me_picture(_device: AuthDevice) -> AppError { not_implemented() } #[utoipa::path( get, path = "/users/{user_id}/picture", operation_id = "getUserPicture", summary = "E-11 Download a user's picture", params( ("user_id" = UuidSchema, Path, description = "Not a UUID is 404 `not_found`."), ("size" = Option, Query, description = "Other values are `invalid_request`."), ("v" = Option, Query, description = "The `picture_version`; a cache key only, ignored by the server."), ), responses( (status = 200, description = "The square JPEG.", body = JpegBytes, content_type = "image/jpeg", headers(("ETag" = String, description = "`\"\"`"), ("Cache-Control" = String, description = "`private, max-age=31536000, immutable`"))), (status = 400, response = BadRequest), (status = 404, response = NotFound), ) )] pub async fn get_user_picture(_device: AuthDevice, IdPath(_user_id): IdPath) -> AppError { not_implemented() }