fix: get workspace namespace
This commit is contained in:
parent
de0b03d6ec
commit
236a22ac97
|
|
@ -29,6 +29,25 @@ impl Client {
|
||||||
AppResponse::<()>::from_response(resp).await?.into_error()
|
AppResponse::<()>::from_response(resp).await?.into_error()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn get_workspace_publish_namespace(
|
||||||
|
&self,
|
||||||
|
workspace_id: &str,
|
||||||
|
) -> Result<String, AppResponseError> {
|
||||||
|
let url = format!(
|
||||||
|
"{}/api/workspace/{}/publish-namespace",
|
||||||
|
self.base_url, workspace_id
|
||||||
|
);
|
||||||
|
let resp = self
|
||||||
|
.http_client_with_auth(Method::GET, &url)
|
||||||
|
.await?
|
||||||
|
.get(&url)
|
||||||
|
.send()
|
||||||
|
.await?;
|
||||||
|
AppResponse::<String>::from_response(resp)
|
||||||
|
.await?
|
||||||
|
.into_data()
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn publish_collab<T>(
|
pub async fn publish_collab<T>(
|
||||||
&self,
|
&self,
|
||||||
workspace_id: &str,
|
workspace_id: &str,
|
||||||
|
|
@ -95,20 +114,6 @@ impl Client {
|
||||||
|
|
||||||
// Guest API (no login required)
|
// Guest API (no login required)
|
||||||
impl Client {
|
impl Client {
|
||||||
pub async fn get_workspace_publish_namespace(
|
|
||||||
&self,
|
|
||||||
workspace_id: &str,
|
|
||||||
) -> Result<String, AppResponseError> {
|
|
||||||
let url = format!(
|
|
||||||
"{}/api/workspace/{}/publish-namespace",
|
|
||||||
self.base_url, workspace_id
|
|
||||||
);
|
|
||||||
let resp = self.cloud_client.get(&url).send().await?;
|
|
||||||
AppResponse::<String>::from_response(resp)
|
|
||||||
.await?
|
|
||||||
.into_data()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn get_published_collab<T>(
|
pub async fn get_published_collab<T>(
|
||||||
&self,
|
&self,
|
||||||
publish_namespace: &str,
|
publish_namespace: &str,
|
||||||
|
|
|
||||||
|
|
@ -959,7 +959,7 @@ async fn get_publish_namespace_handler(
|
||||||
) -> Result<Json<AppResponse<String>>> {
|
) -> Result<Json<AppResponse<String>>> {
|
||||||
let workspace_id = workspace_id.into_inner();
|
let workspace_id = workspace_id.into_inner();
|
||||||
let namespace =
|
let namespace =
|
||||||
biz::workspace::ops::get_workspace_namespace(&state.pg_pool, &workspace_id).await?;
|
biz::workspace::ops::get_workspace_publish_namespace(&state.pg_pool, &workspace_id).await?;
|
||||||
Ok(Json(AppResponse::Ok().with_data(namespace)))
|
Ok(Json(AppResponse::Ok().with_data(namespace)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -135,7 +135,7 @@ pub async fn set_workspace_namespace(
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_workspace_namespace(
|
pub async fn get_workspace_publish_namespace(
|
||||||
pg_pool: &PgPool,
|
pg_pool: &PgPool,
|
||||||
workspace_id: &Uuid,
|
workspace_id: &Uuid,
|
||||||
) -> Result<String, AppError> {
|
) -> Result<String, AppError> {
|
||||||
|
|
|
||||||
|
|
@ -12,13 +12,7 @@ async fn test_set_publish_namespace_set() {
|
||||||
.await
|
.await
|
||||||
.err()
|
.err()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
assert_eq!(format!("{:?}", err.code), "PublishNamespaceNotSet");
|
||||||
if format!("{:?}", err.code) != "PublishNamespaceNotSet" {
|
|
||||||
panic!(
|
|
||||||
"Expected PublishNamespaceNotSet, got: code {:?}, message {:?}",
|
|
||||||
err.code, err.message
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let namespace = uuid::Uuid::new_v4().to_string();
|
let namespace = uuid::Uuid::new_v4().to_string();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue