use ::session::AuthedUser; use api::http::{Path, Query, State}; use api::rest::AppResponseData; use crate::errors::ApiError; use crate::services::inbox::{InboxPage, InboxQuery}; use crate::services::service::PullService; #[derive(Debug, serde::Deserialize, utoipa::IntoParams)] pub struct InboxPath { /// created | review-requested | reviewed pub scope: String, } #[utoipa::path( get, path = "/pulls/@me/{scope}", tag = "pulls", description = "跨仓库的个人合并请求收件箱:我创建的、待我评审的、我评审过的。", params(InboxPath, InboxQuery), responses( (status = 200, description = "inbox", body = AppResponseData>) ) )] pub async fn list_my_pulls( State(service): State, AuthedUser(uid): AuthedUser, Path(path): Path, Query(query): Query, ) -> Result, ApiError> { let caller = uid; let scope = match path.scope.as_str() { "created" => crate::services::inbox::InboxScope::Created, "review-requested" => crate::services::inbox::InboxScope::ReviewRequested, "reviewed" => crate::services::inbox::InboxScope::Reviewed, other => { return Err(ApiError::from(crate::errors::PullError::BadRequest( format!("unknown inbox scope `{other}`"), ))); } }; let page = service.list_inbox(caller, scope, query).await?; Ok(AppResponseData::ok(page)) }