a06673b
use axum::Json;
use axum::extract::{Path, State};
use axum::http::StatusCode;
use jwt::extractor::AuthUser;
use uuid::Uuid;
use crate::error::RepoResult;
use crate::features::RepoService;
use crate::features::extras::UpdateAvatarOption;
#[utoipa::path(
post,
path = "/repo/{channel_id}/{repo_id}/avatar",
tag = "repo",
request_body = UpdateAvatarOption,
responses((status = 204, description = "Update repo avatar")),
security(("bearer_auth" = []))
)]
pub(crate) async fn post_handler(
State(svc): State<RepoService>,
AuthUser { claims }: AuthUser,
Path((_, repo_id)): Path<(Uuid, Uuid)>,
Json(input): Json<UpdateAvatarOption>,
) -> RepoResult<StatusCode> {
svc.update_repo_avatar(claims.sub, repo_id, input).await?;
Ok(StatusCode::NO_CONTENT)
}
#[utoipa::path(
delete,
path = "/repo/{channel_id}/{repo_id}/avatar",
tag = "repo",
responses((status = 204, description = "Delete repo avatar")),
security(("bearer_auth" = []))
)]
pub(crate) async fn delete_handler(
State(svc): State<RepoService>,
AuthUser { claims }: AuthUser,
Path((_, repo_id)): Path<(Uuid, Uuid)>,
) -> RepoResult<StatusCode> {
svc.delete_repo_avatar(claims.sub, repo_id).await?;
Ok(StatusCode::NO_CONTENT)
}