a06673b
use axum::Json;
use axum::extract::{Path, Query, State};
use jwt::extractor::AuthUser;
use uuid::Uuid;
use crate::error::RepoResult;
use crate::features::RepoService;
use crate::features::commit_status::types::{
CombinedStatusView, CommitStatusPage, ListStatusQuery,
};
#[utoipa::path(
get,
path = "/repo/{channel_id}/{repo_id}/commits/{ref}/statuses",
tag = "repo",
params(ListStatusQuery),
responses((status = 200, description = "List commit statuses by ref", body = CommitStatusPage)),
security(("bearer_auth" = []))
)]
pub(crate) async fn list_by_ref_handler(
State(svc): State<RepoService>,
AuthUser { claims }: AuthUser,
Path((_, repo_id, git_ref)): Path<(Uuid, Uuid, String)>,
Query(q): Query<ListStatusQuery>,
) -> RepoResult<Json<CommitStatusPage>> {
let out = svc
.list_commit_statuses_by_ref(claims.sub, repo_id, &git_ref, q)
.await?;
Ok(Json(out))
}
#[utoipa::path(
get,
path = "/repo/{channel_id}/{repo_id}/commits/{ref}/status",
tag = "repo",
responses((status = 200, description = "Get combined commit status by ref", body = CombinedStatusView)),
security(("bearer_auth" = []))
)]
pub(crate) async fn combined_handler(
State(svc): State<RepoService>,
AuthUser { claims }: AuthUser,
Path((_, repo_id, git_ref)): Path<(Uuid, Uuid, String)>,
) -> RepoResult<Json<CombinedStatusView>> {
let out = svc
.combined_status_by_ref(claims.sub, repo_id, &git_ref)
.await?;
Ok(Json(out))
}