Merge pull request #709 from AppFlowy-IO/fix/publish-nothing
fix: publish nothing should result in error
This commit is contained in:
commit
b5abaafb50
|
|
@ -1223,7 +1223,9 @@ async fn post_publish_collabs_handler(
|
||||||
}
|
}
|
||||||
|
|
||||||
if accumulator.is_empty() {
|
if accumulator.is_empty() {
|
||||||
return Ok(Json(AppResponse::Ok()));
|
return Err(
|
||||||
|
AppError::InvalidRequest(String::from("did not receive any data to publish")).into(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
biz::workspace::ops::publish_collabs(&state.pg_pool, &workspace_id, &user_uuid, &accumulator)
|
biz::workspace::ops::publish_collabs(&state.pg_pool, &workspace_id, &user_uuid, &accumulator)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,7 @@ async fn test_publish_doc() {
|
||||||
let view_id_1 = uuid::Uuid::new_v4();
|
let view_id_1 = uuid::Uuid::new_v4();
|
||||||
let publish_name_2 = "publish-name-2";
|
let publish_name_2 = "publish-name-2";
|
||||||
let view_id_2 = uuid::Uuid::new_v4();
|
let view_id_2 = uuid::Uuid::new_v4();
|
||||||
|
|
||||||
c.publish_collabs::<MyCustomMetadata, &[u8]>(
|
c.publish_collabs::<MyCustomMetadata, &[u8]>(
|
||||||
&workspace_id,
|
&workspace_id,
|
||||||
vec![
|
vec![
|
||||||
|
|
@ -547,15 +548,14 @@ async fn test_publish_load_test() {
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
// publish nothing
|
{
|
||||||
c.publish_collabs::<(), &[u8]>(&workspace_id, vec![])
|
// cannot publish nothing
|
||||||
.await
|
let err = c
|
||||||
.unwrap();
|
.publish_collabs::<(), &[u8]>(&workspace_id, vec![])
|
||||||
|
.await
|
||||||
// publish nothing with metadata
|
.unwrap_err();
|
||||||
c.publish_collabs::<MyCustomMetadata, &[u8]>(&workspace_id, vec![])
|
assert_eq!(err.code, ErrorCode::InvalidRequest);
|
||||||
.await
|
}
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
// publish 1000 collabs
|
// publish 1000 collabs
|
||||||
let collabs: Vec<PublishCollabItem<MyCustomMetadata, Vec<u8>>> = (0..1000)
|
let collabs: Vec<PublishCollabItem<MyCustomMetadata, Vec<u8>>> = (0..1000)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue