feat: support disabling comments and disallow duplicate as template for published page (#1167)
This commit is contained in:
parent
14c05479b0
commit
0f7a1f41d0
|
|
@ -1,20 +0,0 @@
|
||||||
{
|
|
||||||
"db_name": "PostgreSQL",
|
|
||||||
"query": "\n INSERT INTO af_published_collab (workspace_id, view_id, publish_name, published_by, metadata, blob)\n SELECT * FROM UNNEST(\n (SELECT array_agg((SELECT $1::uuid)) FROM generate_series(1, $7))::uuid[],\n $2::uuid[],\n $3::text[],\n (SELECT array_agg((SELECT uid FROM af_user WHERE uuid = $4)) FROM generate_series(1, $7))::bigint[],\n $5::jsonb[],\n $6::bytea[]\n )\n ON CONFLICT (workspace_id, view_id) DO UPDATE\n SET metadata = EXCLUDED.metadata,\n blob = EXCLUDED.blob,\n published_by = EXCLUDED.published_by,\n publish_name = EXCLUDED.publish_name\n ",
|
|
||||||
"describe": {
|
|
||||||
"columns": [],
|
|
||||||
"parameters": {
|
|
||||||
"Left": [
|
|
||||||
"Uuid",
|
|
||||||
"UuidArray",
|
|
||||||
"TextArray",
|
|
||||||
"Uuid",
|
|
||||||
"JsonbArray",
|
|
||||||
"ByteaArray",
|
|
||||||
"Int4"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"nullable": []
|
|
||||||
},
|
|
||||||
"hash": "0857da7f3d100186aab8a6f881dfec948a99c96d6f02bcf11eae7aeeea62e5a0"
|
|
||||||
}
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"db_name": "PostgreSQL",
|
"db_name": "PostgreSQL",
|
||||||
"query": "\n SELECT\n apc.view_id,\n apc.publish_name,\n au.email AS publisher_email,\n apc.created_at AS publish_timestamp\n FROM af_published_collab apc\n JOIN af_user au ON apc.published_by = au.uid\n WHERE workspace_id = $1\n AND unpublished_at IS NULL\n ",
|
"query": "\n SELECT\n apc.view_id,\n apc.publish_name,\n au.email AS publisher_email,\n apc.created_at AS publish_timestamp,\n apc.comments_enabled,\n apc.duplicate_enabled\n FROM af_published_collab apc\n JOIN af_user au ON apc.published_by = au.uid\n WHERE workspace_id = $1\n AND unpublished_at IS NULL\n ",
|
||||||
"describe": {
|
"describe": {
|
||||||
"columns": [
|
"columns": [
|
||||||
{
|
{
|
||||||
|
|
@ -22,6 +22,16 @@
|
||||||
"ordinal": 3,
|
"ordinal": 3,
|
||||||
"name": "publish_timestamp",
|
"name": "publish_timestamp",
|
||||||
"type_info": "Timestamptz"
|
"type_info": "Timestamptz"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ordinal": 4,
|
||||||
|
"name": "comments_enabled",
|
||||||
|
"type_info": "Bool"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ordinal": 5,
|
||||||
|
"name": "duplicate_enabled",
|
||||||
|
"type_info": "Bool"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"parameters": {
|
"parameters": {
|
||||||
|
|
@ -30,11 +40,13 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"nullable": [
|
"nullable": [
|
||||||
|
false,
|
||||||
|
false,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
false
|
false
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"hash": "4787139d2189fc33ac25ac07bb9f585f578bde4cd3f75a7da95aa849a25bca9d"
|
"hash": "223e530f8605f6d00789344565666f57705151e3c2318519e877b22f8ffc871b"
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
{
|
||||||
|
"db_name": "PostgreSQL",
|
||||||
|
"query": "\n INSERT INTO af_published_collab (workspace_id, view_id, publish_name, published_by, metadata, blob, comments_enabled, duplicate_enabled)\n SELECT * FROM UNNEST(\n (SELECT array_agg((SELECT $1::uuid)) FROM generate_series(1, $9))::uuid[],\n $2::uuid[],\n $3::text[],\n (SELECT array_agg((SELECT uid FROM af_user WHERE uuid = $4)) FROM generate_series(1, $9))::bigint[],\n $5::jsonb[],\n $6::bytea[],\n $7::boolean[],\n $8::boolean[]\n )\n ON CONFLICT (workspace_id, view_id) DO UPDATE\n SET metadata = EXCLUDED.metadata,\n blob = EXCLUDED.blob,\n published_by = EXCLUDED.published_by,\n publish_name = EXCLUDED.publish_name\n ",
|
||||||
|
"describe": {
|
||||||
|
"columns": [],
|
||||||
|
"parameters": {
|
||||||
|
"Left": [
|
||||||
|
"Uuid",
|
||||||
|
"UuidArray",
|
||||||
|
"TextArray",
|
||||||
|
"Uuid",
|
||||||
|
"JsonbArray",
|
||||||
|
"ByteaArray",
|
||||||
|
"BoolArray",
|
||||||
|
"BoolArray",
|
||||||
|
"Int4"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"nullable": []
|
||||||
|
},
|
||||||
|
"hash": "94555a25b986992bd3cfb67bd36ff015d39bdd78ac20d56570306616bf10faf3"
|
||||||
|
}
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
{
|
|
||||||
"db_name": "PostgreSQL",
|
|
||||||
"query": "\n UPDATE af_published_collab\n SET publish_name = $1\n WHERE workspace_id = $2\n AND view_id = $3\n ",
|
|
||||||
"describe": {
|
|
||||||
"columns": [],
|
|
||||||
"parameters": {
|
|
||||||
"Left": [
|
|
||||||
"Text",
|
|
||||||
"Uuid",
|
|
||||||
"Uuid"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"nullable": []
|
|
||||||
},
|
|
||||||
"hash": "a98cb855107a0641979d3a7fecaf01df960e3fe5abd841752c05782c7203ff12"
|
|
||||||
}
|
|
||||||
|
|
@ -1047,7 +1047,13 @@ impl TestClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// data: [(view_id, meta_json, blob_hex)]
|
/// data: [(view_id, meta_json, blob_hex)]
|
||||||
pub async fn publish_collabs(&self, workspace_id: &str, data: Vec<(Uuid, &str, &str)>) {
|
pub async fn publish_collabs(
|
||||||
|
&self,
|
||||||
|
workspace_id: &str,
|
||||||
|
data: Vec<(Uuid, &str, &str)>,
|
||||||
|
comments_enabled: bool,
|
||||||
|
duplicate_enabled: bool,
|
||||||
|
) {
|
||||||
let pub_items = data
|
let pub_items = data
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|(view_id, meta_json, blob_hex)| {
|
.map(|(view_id, meta_json, blob_hex)| {
|
||||||
|
|
@ -1060,6 +1066,8 @@ impl TestClient {
|
||||||
metadata: meta,
|
metadata: meta,
|
||||||
},
|
},
|
||||||
data: blob,
|
data: blob,
|
||||||
|
comments_enabled,
|
||||||
|
duplicate_enabled,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
|
||||||
|
|
@ -801,12 +801,16 @@ pub struct PublishCollabKey {
|
||||||
pub struct PublishCollabItem<Meta, Data> {
|
pub struct PublishCollabItem<Meta, Data> {
|
||||||
pub meta: PublishCollabMetadata<Meta>,
|
pub meta: PublishCollabMetadata<Meta>,
|
||||||
pub data: Data,
|
pub data: Data,
|
||||||
|
pub comments_enabled: bool,
|
||||||
|
pub duplicate_enabled: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
pub struct PatchPublishedCollab {
|
pub struct PatchPublishedCollab {
|
||||||
pub view_id: Uuid,
|
pub view_id: Uuid,
|
||||||
pub publish_name: Option<String>,
|
pub publish_name: Option<String>,
|
||||||
|
pub comments_enabled: Option<bool>,
|
||||||
|
pub duplicate_enabled: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
|
|
||||||
|
|
@ -692,4 +692,6 @@ pub struct AFPublishViewWithPublishInfo {
|
||||||
pub publish_name: String,
|
pub publish_name: String,
|
||||||
pub publisher_email: String,
|
pub publisher_email: String,
|
||||||
pub publish_timestamp: DateTime<Utc>,
|
pub publish_timestamp: DateTime<Utc>,
|
||||||
|
pub comments_enabled: bool,
|
||||||
|
pub duplicate_enabled: bool,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ use app_error::AppError;
|
||||||
use database_entity::dto::{
|
use database_entity::dto::{
|
||||||
PatchPublishedCollab, PublishCollabItem, PublishCollabKey, PublishInfo, WorkspaceNamespace,
|
PatchPublishedCollab, PublishCollabItem, PublishCollabKey, PublishInfo, WorkspaceNamespace,
|
||||||
};
|
};
|
||||||
use sqlx::{Executor, PgPool, Postgres};
|
use sqlx::{Executor, PgPool, Postgres, QueryBuilder};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::pg_row::AFPublishViewWithPublishInfo;
|
use crate::pg_row::AFPublishViewWithPublishInfo;
|
||||||
|
|
@ -253,11 +253,15 @@ pub async fn insert_or_replace_publish_collabs(
|
||||||
let mut publish_names: Vec<String> = Vec::with_capacity(item_count);
|
let mut publish_names: Vec<String> = Vec::with_capacity(item_count);
|
||||||
let mut metadatas: Vec<serde_json::Value> = Vec::with_capacity(item_count);
|
let mut metadatas: Vec<serde_json::Value> = Vec::with_capacity(item_count);
|
||||||
let mut blobs: Vec<Vec<u8>> = Vec::with_capacity(item_count);
|
let mut blobs: Vec<Vec<u8>> = Vec::with_capacity(item_count);
|
||||||
|
let mut comments_enabled_list: Vec<bool> = Vec::with_capacity(item_count);
|
||||||
|
let mut duplicate_enabled_list: Vec<bool> = Vec::with_capacity(item_count);
|
||||||
publish_items.into_iter().for_each(|item| {
|
publish_items.into_iter().for_each(|item| {
|
||||||
view_ids.push(item.meta.view_id);
|
view_ids.push(item.meta.view_id);
|
||||||
publish_names.push(item.meta.publish_name);
|
publish_names.push(item.meta.publish_name);
|
||||||
metadatas.push(item.meta.metadata);
|
metadatas.push(item.meta.metadata);
|
||||||
blobs.push(item.data);
|
blobs.push(item.data);
|
||||||
|
comments_enabled_list.push(item.comments_enabled);
|
||||||
|
duplicate_enabled_list.push(item.duplicate_enabled);
|
||||||
});
|
});
|
||||||
|
|
||||||
let mut txn = pg_pool.begin().await?;
|
let mut txn = pg_pool.begin().await?;
|
||||||
|
|
@ -265,14 +269,16 @@ pub async fn insert_or_replace_publish_collabs(
|
||||||
|
|
||||||
let res = sqlx::query!(
|
let res = sqlx::query!(
|
||||||
r#"
|
r#"
|
||||||
INSERT INTO af_published_collab (workspace_id, view_id, publish_name, published_by, metadata, blob)
|
INSERT INTO af_published_collab (workspace_id, view_id, publish_name, published_by, metadata, blob, comments_enabled, duplicate_enabled)
|
||||||
SELECT * FROM UNNEST(
|
SELECT * FROM UNNEST(
|
||||||
(SELECT array_agg((SELECT $1::uuid)) FROM generate_series(1, $7))::uuid[],
|
(SELECT array_agg((SELECT $1::uuid)) FROM generate_series(1, $9))::uuid[],
|
||||||
$2::uuid[],
|
$2::uuid[],
|
||||||
$3::text[],
|
$3::text[],
|
||||||
(SELECT array_agg((SELECT uid FROM af_user WHERE uuid = $4)) FROM generate_series(1, $7))::bigint[],
|
(SELECT array_agg((SELECT uid FROM af_user WHERE uuid = $4)) FROM generate_series(1, $9))::bigint[],
|
||||||
$5::jsonb[],
|
$5::jsonb[],
|
||||||
$6::bytea[]
|
$6::bytea[],
|
||||||
|
$7::boolean[],
|
||||||
|
$8::boolean[]
|
||||||
)
|
)
|
||||||
ON CONFLICT (workspace_id, view_id) DO UPDATE
|
ON CONFLICT (workspace_id, view_id) DO UPDATE
|
||||||
SET metadata = EXCLUDED.metadata,
|
SET metadata = EXCLUDED.metadata,
|
||||||
|
|
@ -286,6 +292,8 @@ pub async fn insert_or_replace_publish_collabs(
|
||||||
publisher_uuid,
|
publisher_uuid,
|
||||||
&metadatas,
|
&metadatas,
|
||||||
&blobs,
|
&blobs,
|
||||||
|
&comments_enabled_list,
|
||||||
|
&duplicate_enabled_list,
|
||||||
item_count as i32,
|
item_count as i32,
|
||||||
)
|
)
|
||||||
.execute(txn.as_mut())
|
.execute(txn.as_mut())
|
||||||
|
|
@ -372,33 +380,45 @@ pub async fn update_published_collabs(
|
||||||
.collect();
|
.collect();
|
||||||
delete_published_collabs(txn, workspace_id, &publish_names).await?;
|
delete_published_collabs(txn, workspace_id, &publish_names).await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
for patch in patches {
|
for patch in patches {
|
||||||
let new_publish_name = match &patch.publish_name {
|
let mut query_builder: QueryBuilder<Postgres> = QueryBuilder::new(
|
||||||
Some(new_publish_name) => new_publish_name,
|
|
||||||
None => continue,
|
|
||||||
};
|
|
||||||
|
|
||||||
let res = sqlx::query!(
|
|
||||||
r#"
|
r#"
|
||||||
UPDATE af_published_collab
|
UPDATE af_published_collab SET
|
||||||
SET publish_name = $1
|
|
||||||
WHERE workspace_id = $2
|
|
||||||
AND view_id = $3
|
|
||||||
"#,
|
"#,
|
||||||
patch.publish_name,
|
);
|
||||||
workspace_id,
|
let mut first_set = true;
|
||||||
patch.view_id,
|
if let Some(comments_enabled) = patch.comments_enabled {
|
||||||
)
|
first_set = false;
|
||||||
.execute(txn.as_mut())
|
query_builder.push(" comments_enabled = ");
|
||||||
.await?;
|
query_builder.push_bind(comments_enabled);
|
||||||
|
}
|
||||||
|
if let Some(duplicate_enabled) = patch.duplicate_enabled {
|
||||||
|
if !first_set {
|
||||||
|
query_builder.push(",");
|
||||||
|
}
|
||||||
|
first_set = false;
|
||||||
|
query_builder.push(" duplicate_enabled = ");
|
||||||
|
query_builder.push_bind(duplicate_enabled);
|
||||||
|
}
|
||||||
|
if let Some(publish_name) = &patch.publish_name {
|
||||||
|
if !first_set {
|
||||||
|
query_builder.push(",");
|
||||||
|
}
|
||||||
|
query_builder.push(" publish_name = ");
|
||||||
|
query_builder.push_bind(publish_name);
|
||||||
|
}
|
||||||
|
query_builder.push(" WHERE workspace_id = ");
|
||||||
|
query_builder.push_bind(workspace_id);
|
||||||
|
query_builder.push(" AND view_id = ");
|
||||||
|
query_builder.push_bind(patch.view_id);
|
||||||
|
let query = query_builder.build();
|
||||||
|
let res = query.execute(txn.as_mut()).await?;
|
||||||
|
|
||||||
if res.rows_affected() != 1 {
|
if res.rows_affected() != 1 {
|
||||||
tracing::error!(
|
tracing::error!(
|
||||||
"Failed to update published collab publish name, workspace_id: {}, view_id: {}, new_publish_name: {}, rows_affected: {}",
|
"Failed to update published collab publish name, workspace_id: {}, view_id: {}, rows_affected: {}",
|
||||||
workspace_id,
|
workspace_id,
|
||||||
patch.view_id,
|
patch.view_id,
|
||||||
new_publish_name,
|
|
||||||
res.rows_affected()
|
res.rows_affected()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -695,7 +715,9 @@ pub async fn select_published_view_ids_with_publish_info_for_workspace<
|
||||||
apc.view_id,
|
apc.view_id,
|
||||||
apc.publish_name,
|
apc.publish_name,
|
||||||
au.email AS publisher_email,
|
au.email AS publisher_email,
|
||||||
apc.created_at AS publish_timestamp
|
apc.created_at AS publish_timestamp,
|
||||||
|
apc.comments_enabled,
|
||||||
|
apc.duplicate_enabled
|
||||||
FROM af_published_collab apc
|
FROM af_published_collab apc
|
||||||
JOIN af_user au ON apc.published_by = au.uid
|
JOIN af_user au ON apc.published_by = au.uid
|
||||||
WHERE workspace_id = $1
|
WHERE workspace_id = $1
|
||||||
|
|
|
||||||
|
|
@ -285,6 +285,8 @@ pub struct PublishInfoView {
|
||||||
pub struct PublishPageParams {
|
pub struct PublishPageParams {
|
||||||
pub publish_name: Option<String>,
|
pub publish_name: Option<String>,
|
||||||
pub visible_database_view_ids: Option<Vec<String>>,
|
pub visible_database_view_ids: Option<Vec<String>>,
|
||||||
|
pub comments_enabled: Option<bool>,
|
||||||
|
pub duplicate_enabled: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Eq, PartialEq, Debug, Hash, Clone, Serialize_repr, Deserialize_repr)]
|
#[derive(Eq, PartialEq, Debug, Hash, Clone, Serialize_repr, Deserialize_repr)]
|
||||||
|
|
@ -401,6 +403,8 @@ pub struct PublishedViewInfo {
|
||||||
pub publisher_email: String,
|
pub publisher_email: String,
|
||||||
pub publish_name: String,
|
pub publish_name: String,
|
||||||
pub publish_timestamp: DateTime<Utc>,
|
pub publish_timestamp: DateTime<Utc>,
|
||||||
|
pub comments_enabled: bool,
|
||||||
|
pub duplicate_enabled: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
|
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
ALTER TABLE af_published_collab
|
||||||
|
ADD COLUMN comments_enabled BOOLEAN NOT NULL DEFAULT TRUE,
|
||||||
|
ADD COLUMN duplicate_enabled BOOLEAN NOT NULL DEFAULT TRUE;
|
||||||
|
|
@ -105,6 +105,18 @@ http {
|
||||||
proxy_pass $appflowy_cloud_backend;
|
proxy_pass $appflowy_cloud_backend;
|
||||||
proxy_request_buffering off;
|
proxy_request_buffering off;
|
||||||
client_max_body_size 256M;
|
client_max_body_size 256M;
|
||||||
|
if ($request_method = 'OPTIONS') {
|
||||||
|
add_header 'Access-Control-Allow-Origin' $cors_origin always;
|
||||||
|
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, PATCH, OPTIONS' always;
|
||||||
|
add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization, Accept, Client-Version' always;
|
||||||
|
add_header 'Access-Control-Max-Age' 3600 always;
|
||||||
|
return 204;
|
||||||
|
}
|
||||||
|
|
||||||
|
add_header 'Access-Control-Allow-Origin' $cors_origin always;
|
||||||
|
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, PATCH, OPTIONS' always;
|
||||||
|
add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization, Accept, Client-Version' always;
|
||||||
|
add_header 'Access-Control-Max-Age' 3600 always;
|
||||||
}
|
}
|
||||||
|
|
||||||
# AppFlowy-Cloud
|
# AppFlowy-Cloud
|
||||||
|
|
|
||||||
|
|
@ -1300,6 +1300,8 @@ async fn publish_page_handler(
|
||||||
let PublishPageParams {
|
let PublishPageParams {
|
||||||
publish_name,
|
publish_name,
|
||||||
visible_database_view_ids,
|
visible_database_view_ids,
|
||||||
|
comments_enabled,
|
||||||
|
duplicate_enabled,
|
||||||
} = payload.into_inner();
|
} = payload.into_inner();
|
||||||
publish_page(
|
publish_page(
|
||||||
&state.pg_pool,
|
&state.pg_pool,
|
||||||
|
|
@ -1311,6 +1313,8 @@ async fn publish_page_handler(
|
||||||
&view_id,
|
&view_id,
|
||||||
visible_database_view_ids,
|
visible_database_view_ids,
|
||||||
publish_name,
|
publish_name,
|
||||||
|
comments_enabled.unwrap_or(true),
|
||||||
|
duplicate_enabled.unwrap_or(true),
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
Ok(Json(AppResponse::Ok()))
|
Ok(Json(AppResponse::Ok()))
|
||||||
|
|
@ -1936,6 +1940,9 @@ async fn delete_published_collab_reaction_handler(
|
||||||
Ok(Json(AppResponse::Ok()))
|
Ok(Json(AppResponse::Ok()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: This endpoint currently has a different behaviour from the publish page endpoint,
|
||||||
|
// as it doesn't accept parameters. We will need to deprecate this endpoint and use a new
|
||||||
|
// one that accepts parameters.
|
||||||
async fn post_publish_collabs_handler(
|
async fn post_publish_collabs_handler(
|
||||||
workspace_id: web::Path<Uuid>,
|
workspace_id: web::Path<Uuid>,
|
||||||
user_uuid: UserUuid,
|
user_uuid: UserUuid,
|
||||||
|
|
@ -1974,7 +1981,14 @@ async fn post_publish_collabs_handler(
|
||||||
data_buffer
|
data_buffer
|
||||||
};
|
};
|
||||||
|
|
||||||
accumulator.push(PublishCollabItem { meta, data });
|
// Set comments_enabled and duplicate_enabled to true by default, as this is the default
|
||||||
|
// behaviour for the older web version.
|
||||||
|
accumulator.push(PublishCollabItem {
|
||||||
|
meta,
|
||||||
|
data,
|
||||||
|
comments_enabled: true,
|
||||||
|
duplicate_enabled: true,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if accumulator.is_empty() {
|
if accumulator.is_empty() {
|
||||||
|
|
|
||||||
|
|
@ -471,6 +471,8 @@ pub async fn get_published_view(
|
||||||
publisher_email: pv.publisher_email.clone(),
|
publisher_email: pv.publisher_email.clone(),
|
||||||
publish_name: pv.publish_name.clone(),
|
publish_name: pv.publish_name.clone(),
|
||||||
publish_timestamp: pv.publish_timestamp,
|
publish_timestamp: pv.publish_timestamp,
|
||||||
|
comments_enabled: pv.comments_enabled,
|
||||||
|
duplicate_enabled: pv.duplicate_enabled,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ use collab_folder::{Folder, View};
|
||||||
use database::collab::GetCollabOrigin;
|
use database::collab::GetCollabOrigin;
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use tracing::info;
|
|
||||||
|
|
||||||
use database::index::{search_documents, SearchDocumentParams};
|
use database::index::{search_documents, SearchDocumentParams};
|
||||||
use shared_entity::dto::search_dto::{
|
use shared_entity::dto::search_dto::{
|
||||||
|
|
@ -126,7 +125,6 @@ pub async fn search_document(
|
||||||
0,
|
0,
|
||||||
MAX_SEARCH_DEPTH,
|
MAX_SEARCH_DEPTH,
|
||||||
);
|
);
|
||||||
info!("{:?}", searchable_view_ids);
|
|
||||||
let results = search_documents(
|
let results = search_documents(
|
||||||
pg_pool,
|
pg_pool,
|
||||||
SearchDocumentParams {
|
SearchDocumentParams {
|
||||||
|
|
|
||||||
|
|
@ -1076,6 +1076,8 @@ pub async fn publish_page(
|
||||||
view_id: &str,
|
view_id: &str,
|
||||||
visible_database_view_ids: Option<Vec<String>>,
|
visible_database_view_ids: Option<Vec<String>>,
|
||||||
publish_name: Option<impl ToString>,
|
publish_name: Option<impl ToString>,
|
||||||
|
comments_enabled: bool,
|
||||||
|
duplicate_enabled: bool,
|
||||||
) -> Result<(), AppError> {
|
) -> Result<(), AppError> {
|
||||||
let folder = get_latest_collab_folder(
|
let folder = get_latest_collab_folder(
|
||||||
collab_access_control_storage,
|
collab_access_control_storage,
|
||||||
|
|
@ -1145,6 +1147,8 @@ pub async fn publish_page(
|
||||||
metadata: serde_json::value::to_value(metadata).unwrap(),
|
metadata: serde_json::value::to_value(metadata).unwrap(),
|
||||||
},
|
},
|
||||||
data: publish_data,
|
data: publish_data,
|
||||||
|
comments_enabled,
|
||||||
|
duplicate_enabled,
|
||||||
}],
|
}],
|
||||||
&workspace_id,
|
&workspace_id,
|
||||||
&user_uuid,
|
&user_uuid,
|
||||||
|
|
|
||||||
|
|
@ -768,6 +768,8 @@ async fn publish_page() {
|
||||||
&PublishPageParams {
|
&PublishPageParams {
|
||||||
publish_name: None,
|
publish_name: None,
|
||||||
visible_database_view_ids: None,
|
visible_database_view_ids: None,
|
||||||
|
comments_enabled: None,
|
||||||
|
duplicate_enabled: None,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
|
|
|
||||||
|
|
@ -121,12 +121,14 @@ async fn test_publish_doc() {
|
||||||
vec![PublishCollabItem {
|
vec![PublishCollabItem {
|
||||||
meta: PublishCollabMetadata {
|
meta: PublishCollabMetadata {
|
||||||
view_id: uuid::Uuid::new_v4(),
|
view_id: uuid::Uuid::new_v4(),
|
||||||
publish_name: "(*&^%$#!".to_string(), // invalid chars
|
publish_name: "(*&^%$#!".to_string(),
|
||||||
metadata: MyCustomMetadata {
|
metadata: MyCustomMetadata {
|
||||||
title: "my_title_1".to_string(),
|
title: "my_title_1".to_string(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
data: "yrs_encoded_data_1".as_bytes(),
|
data: "yrs_encoded_data_1".as_bytes(),
|
||||||
|
comments_enabled: true,
|
||||||
|
duplicate_enabled: true,
|
||||||
}],
|
}],
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
|
|
@ -144,12 +146,14 @@ async fn test_publish_doc() {
|
||||||
vec![PublishCollabItem {
|
vec![PublishCollabItem {
|
||||||
meta: PublishCollabMetadata {
|
meta: PublishCollabMetadata {
|
||||||
view_id: uuid::Uuid::new_v4(),
|
view_id: uuid::Uuid::new_v4(),
|
||||||
publish_name: "a".repeat(1001), // too long
|
publish_name: "a".repeat(1001),
|
||||||
metadata: MyCustomMetadata {
|
metadata: MyCustomMetadata {
|
||||||
title: "my_title_1".to_string(),
|
title: "my_title_1".to_string(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
data: "yrs_encoded_data_1".as_bytes(),
|
data: "yrs_encoded_data_1".as_bytes(),
|
||||||
|
comments_enabled: true,
|
||||||
|
duplicate_enabled: true,
|
||||||
}],
|
}],
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
|
|
@ -175,6 +179,8 @@ async fn test_publish_doc() {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
data: "yrs_encoded_data_1".as_bytes(),
|
data: "yrs_encoded_data_1".as_bytes(),
|
||||||
|
comments_enabled: true,
|
||||||
|
duplicate_enabled: true,
|
||||||
},
|
},
|
||||||
PublishCollabItem {
|
PublishCollabItem {
|
||||||
meta: PublishCollabMetadata {
|
meta: PublishCollabMetadata {
|
||||||
|
|
@ -185,6 +191,8 @@ async fn test_publish_doc() {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
data: "yrs_encoded_data_2".as_bytes(),
|
data: "yrs_encoded_data_2".as_bytes(),
|
||||||
|
comments_enabled: true,
|
||||||
|
duplicate_enabled: true,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
@ -204,6 +212,8 @@ async fn test_publish_doc() {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
data: "some_other_yrs_data".as_bytes(),
|
data: "some_other_yrs_data".as_bytes(),
|
||||||
|
comments_enabled: true,
|
||||||
|
duplicate_enabled: true,
|
||||||
}],
|
}],
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
|
|
@ -278,6 +288,8 @@ async fn test_publish_doc() {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
data: "yrs_encoded_data_3".as_bytes(),
|
data: "yrs_encoded_data_3".as_bytes(),
|
||||||
|
comments_enabled: true,
|
||||||
|
duplicate_enabled: true,
|
||||||
},
|
},
|
||||||
PublishCollabItem {
|
PublishCollabItem {
|
||||||
meta: PublishCollabMetadata {
|
meta: PublishCollabMetadata {
|
||||||
|
|
@ -288,6 +300,8 @@ async fn test_publish_doc() {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
data: "yrs_encoded_data_4".as_bytes(),
|
data: "yrs_encoded_data_4".as_bytes(),
|
||||||
|
comments_enabled: true,
|
||||||
|
duplicate_enabled: true,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
@ -357,8 +371,9 @@ async fn test_publish_doc() {
|
||||||
&workspace_id,
|
&workspace_id,
|
||||||
&[PatchPublishedCollab {
|
&[PatchPublishedCollab {
|
||||||
view_id: view_id_1,
|
view_id: view_id_1,
|
||||||
// publish_name_2 already exists
|
|
||||||
publish_name: Some(publish_name_2.to_string()),
|
publish_name: Some(publish_name_2.to_string()),
|
||||||
|
comments_enabled: None,
|
||||||
|
duplicate_enabled: None,
|
||||||
}],
|
}],
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
|
|
@ -373,6 +388,8 @@ async fn test_publish_doc() {
|
||||||
&[PatchPublishedCollab {
|
&[PatchPublishedCollab {
|
||||||
view_id: view_id_1,
|
view_id: view_id_1,
|
||||||
publish_name: Some(new_publish_name_1.to_string()),
|
publish_name: Some(new_publish_name_1.to_string()),
|
||||||
|
comments_enabled: None,
|
||||||
|
duplicate_enabled: None,
|
||||||
}],
|
}],
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
|
|
@ -400,6 +417,8 @@ async fn test_publish_doc() {
|
||||||
&[PatchPublishedCollab {
|
&[PatchPublishedCollab {
|
||||||
view_id: view_id_1,
|
view_id: view_id_1,
|
||||||
publish_name: Some(publish_name_1.to_string()),
|
publish_name: Some(publish_name_1.to_string()),
|
||||||
|
comments_enabled: None,
|
||||||
|
duplicate_enabled: None,
|
||||||
}],
|
}],
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
|
|
@ -474,6 +493,8 @@ async fn test_publish_comments() {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
data: "yrs_encoded_data_1".as_bytes(),
|
data: "yrs_encoded_data_1".as_bytes(),
|
||||||
|
comments_enabled: true,
|
||||||
|
duplicate_enabled: true,
|
||||||
}],
|
}],
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
|
|
@ -696,6 +717,8 @@ async fn test_excessive_comment_length() {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
data: "yrs_encoded_data_1".as_bytes(),
|
data: "yrs_encoded_data_1".as_bytes(),
|
||||||
|
comments_enabled: true,
|
||||||
|
duplicate_enabled: true,
|
||||||
}],
|
}],
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
|
|
@ -732,6 +755,8 @@ async fn test_publish_reactions() {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
data: "yrs_encoded_data_1".as_bytes(),
|
data: "yrs_encoded_data_1".as_bytes(),
|
||||||
|
comments_enabled: true,
|
||||||
|
duplicate_enabled: true,
|
||||||
}],
|
}],
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
|
|
@ -861,7 +886,9 @@ async fn test_publish_load_test() {
|
||||||
title: format!("title_{}", i),
|
title: format!("title_{}", i),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
data: vec![0; 100_000], // 100 KB
|
data: vec![0; 100_000],
|
||||||
|
comments_enabled: true,
|
||||||
|
duplicate_enabled: true,
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
|
|
@ -903,6 +930,8 @@ async fn workspace_member_publish_unpublish() {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
data: "yrs_encoded_data_1".as_bytes(),
|
data: "yrs_encoded_data_1".as_bytes(),
|
||||||
|
comments_enabled: true,
|
||||||
|
duplicate_enabled: true,
|
||||||
}],
|
}],
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
|
|
@ -951,6 +980,8 @@ async fn duplicate_to_workspace_references() {
|
||||||
published_data::GRID_1_DB_DATA,
|
published_data::GRID_1_DB_DATA,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
true,
|
||||||
|
true,
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
|
@ -1036,6 +1067,8 @@ async fn duplicate_to_workspace_doc_inline_database() {
|
||||||
published_data::VIEW_OF_GRID_1_DB_DATA,
|
published_data::VIEW_OF_GRID_1_DB_DATA,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
true,
|
||||||
|
true,
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
|
@ -1209,6 +1242,8 @@ async fn duplicate_to_workspace_db_embedded_in_doc() {
|
||||||
published_data::EMBEDDED_DB_HEX,
|
published_data::EMBEDDED_DB_HEX,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
true,
|
||||||
|
true,
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
|
@ -1301,6 +1336,8 @@ async fn duplicate_to_workspace_db_with_relation() {
|
||||||
published_data::RELATED_DB_HEX,
|
published_data::RELATED_DB_HEX,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
true,
|
||||||
|
true,
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
|
@ -1313,6 +1350,8 @@ async fn duplicate_to_workspace_db_with_relation() {
|
||||||
published_data::DB_ROW_WITH_DOC_META,
|
published_data::DB_ROW_WITH_DOC_META,
|
||||||
published_data::DB_ROW_WITH_DOC_HEX,
|
published_data::DB_ROW_WITH_DOC_HEX,
|
||||||
)],
|
)],
|
||||||
|
true,
|
||||||
|
true,
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
|
@ -1406,6 +1445,8 @@ async fn duplicate_to_workspace_db_row_with_doc() {
|
||||||
published_data::DB_ROW_WITH_DOC_META,
|
published_data::DB_ROW_WITH_DOC_META,
|
||||||
published_data::DB_ROW_WITH_DOC_HEX,
|
published_data::DB_ROW_WITH_DOC_HEX,
|
||||||
)],
|
)],
|
||||||
|
true,
|
||||||
|
true,
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
|
@ -1496,6 +1537,8 @@ async fn duplicate_to_workspace_db_rel_self() {
|
||||||
published_data::DB_REL_SELF_META,
|
published_data::DB_REL_SELF_META,
|
||||||
published_data::DB_REL_SELF_HEX,
|
published_data::DB_REL_SELF_HEX,
|
||||||
)],
|
)],
|
||||||
|
true,
|
||||||
|
true,
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
|
@ -1592,6 +1635,8 @@ async fn duplicate_to_workspace_inline_db_doc_with_relation() {
|
||||||
published_data::GRID_2_HEX,
|
published_data::GRID_2_HEX,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
true,
|
||||||
|
true,
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
|
@ -1668,6 +1713,8 @@ async fn test_republish_doc() {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
data: "yrs_encoded_data_1".as_bytes(),
|
data: "yrs_encoded_data_1".as_bytes(),
|
||||||
|
comments_enabled: true,
|
||||||
|
duplicate_enabled: true,
|
||||||
}],
|
}],
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
|
|
@ -1717,6 +1764,8 @@ async fn test_republish_doc() {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
data: "yrs_encoded_data_2".as_bytes(),
|
data: "yrs_encoded_data_2".as_bytes(),
|
||||||
|
comments_enabled: true,
|
||||||
|
duplicate_enabled: true,
|
||||||
}],
|
}],
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
|
|
@ -1762,6 +1811,8 @@ async fn test_republish_patch() {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
data: "yrs_encoded_data_1".as_bytes(),
|
data: "yrs_encoded_data_1".as_bytes(),
|
||||||
|
comments_enabled: true,
|
||||||
|
duplicate_enabled: true,
|
||||||
}],
|
}],
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
|
|
@ -1786,6 +1837,8 @@ async fn test_republish_patch() {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
data: "yrs_encoded_data_1".as_bytes(),
|
data: "yrs_encoded_data_1".as_bytes(),
|
||||||
|
comments_enabled: true,
|
||||||
|
duplicate_enabled: true,
|
||||||
}],
|
}],
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
|
|
@ -1798,6 +1851,8 @@ async fn test_republish_patch() {
|
||||||
&[PatchPublishedCollab {
|
&[PatchPublishedCollab {
|
||||||
view_id: view_id_2,
|
view_id: view_id_2,
|
||||||
publish_name: Some(publish_name.to_string()),
|
publish_name: Some(publish_name.to_string()),
|
||||||
|
comments_enabled: None,
|
||||||
|
duplicate_enabled: None,
|
||||||
}],
|
}],
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
|
|
|
||||||
|
|
@ -228,6 +228,8 @@ async fn test_template_crud() {
|
||||||
metadata: TemplateMetadata {},
|
metadata: TemplateMetadata {},
|
||||||
},
|
},
|
||||||
data: "yrs_encoded_data_1".as_bytes(),
|
data: "yrs_encoded_data_1".as_bytes(),
|
||||||
|
comments_enabled: true,
|
||||||
|
duplicate_enabled: true,
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue