f0a1552
ZhenYi
feat(chat): add chat module with room management, message handling, and session revocation
f0a1552
use axum::Json;
use axum::extract::{Path, Query, State};
use export::rest::AppResponseData;
use session::Session;
use crate::errors::{ApiError, GitApiError};
use crate::handler::{RepoPath, require_writer};
use crate::service::GitService;
use crate::service::pipelines::{JobDto, TriggerResultDto};
#[derive(Debug, Clone, serde::Deserialize, utoipa::IntoParams)]
pub struct PipelineScheduleQuery {
pub commit: String,
}
#[derive(Debug, Clone, serde::Deserialize, utoipa::ToSchema)]
pub struct PipelineScheduleBody {
pub job: JobDto,
}
#[utoipa::path(
post,
path = "/repos/{space_name}/{repo_name}/pipelines/schedule",
tag = "pipelines",
description = "根据作业定义登记排队中的流水线运行记录。",
params(RepoPath, PipelineScheduleQuery),
request_body = PipelineScheduleBody,
responses(
(status = 200, description = "schedule pipeline job", body = AppResponseData<TriggerResultDto>)
)
)]
pub async fn schedule(
State(service): State<GitService>,
session: Session,
Path(path): Path<RepoPath>,
Query(query): Query<PipelineScheduleQuery>,
Json(body): Json<PipelineScheduleBody>,
) -> Result<AppResponseData<TriggerResultDto>, ApiError> {
let (_ctx, caller) = require_writer(
&service,
&session,
path.space_name.clone(),
path.repo_name.clone(),
)
.await?;
let out = service
.pipeline_schedule(caller, path.space_name, path.repo_name, query.commit, body.job)
.await
.map_err(GitApiError::from)?;
Ok(AppResponseData::ok(out))
}