mirror of
https://github.com/AppFlowy-IO/AppFlowy-Cloud.git
synced 2025-04-19 03:24:42 -04:00
feat: add favorite reorder API
This commit is contained in:
parent
dfd44f8fb7
commit
9c435d9016
35 changed files with 225 additions and 164 deletions
14
Cargo.lock
generated
14
Cargo.lock
generated
|
@ -1896,7 +1896,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "collab"
|
||||
version = "0.2.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=45239d2ae871cc355ea2cc1d5d578e21c8263242#45239d2ae871cc355ea2cc1d5d578e21c8263242"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=80d1c6147d1139289c2eaadab40557cc86c0f4b6#80d1c6147d1139289c2eaadab40557cc86c0f4b6"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"arc-swap",
|
||||
|
@ -1921,7 +1921,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "collab-database"
|
||||
version = "0.2.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=45239d2ae871cc355ea2cc1d5d578e21c8263242#45239d2ae871cc355ea2cc1d5d578e21c8263242"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=80d1c6147d1139289c2eaadab40557cc86c0f4b6#80d1c6147d1139289c2eaadab40557cc86c0f4b6"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
|
@ -1961,7 +1961,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "collab-document"
|
||||
version = "0.2.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=45239d2ae871cc355ea2cc1d5d578e21c8263242#45239d2ae871cc355ea2cc1d5d578e21c8263242"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=80d1c6147d1139289c2eaadab40557cc86c0f4b6#80d1c6147d1139289c2eaadab40557cc86c0f4b6"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"arc-swap",
|
||||
|
@ -1982,7 +1982,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "collab-entity"
|
||||
version = "0.2.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=45239d2ae871cc355ea2cc1d5d578e21c8263242#45239d2ae871cc355ea2cc1d5d578e21c8263242"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=80d1c6147d1139289c2eaadab40557cc86c0f4b6#80d1c6147d1139289c2eaadab40557cc86c0f4b6"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bytes",
|
||||
|
@ -2002,7 +2002,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "collab-folder"
|
||||
version = "0.2.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=45239d2ae871cc355ea2cc1d5d578e21c8263242#45239d2ae871cc355ea2cc1d5d578e21c8263242"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=80d1c6147d1139289c2eaadab40557cc86c0f4b6#80d1c6147d1139289c2eaadab40557cc86c0f4b6"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"arc-swap",
|
||||
|
@ -2024,7 +2024,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "collab-importer"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=45239d2ae871cc355ea2cc1d5d578e21c8263242#45239d2ae871cc355ea2cc1d5d578e21c8263242"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=80d1c6147d1139289c2eaadab40557cc86c0f4b6#80d1c6147d1139289c2eaadab40557cc86c0f4b6"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-recursion",
|
||||
|
@ -2131,7 +2131,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "collab-user"
|
||||
version = "0.2.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=45239d2ae871cc355ea2cc1d5d578e21c8263242#45239d2ae871cc355ea2cc1d5d578e21c8263242"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=80d1c6147d1139289c2eaadab40557cc86c0f4b6#80d1c6147d1139289c2eaadab40557cc86c0f4b6"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"collab",
|
||||
|
|
14
Cargo.toml
14
Cargo.toml
|
@ -303,13 +303,13 @@ lto = false
|
|||
[patch.crates-io]
|
||||
# It's diffcult to resovle different version with the same crate used in AppFlowy Frontend and the Client-API crate.
|
||||
# So using patch to workaround this issue.
|
||||
collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "45239d2ae871cc355ea2cc1d5d578e21c8263242" }
|
||||
collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "45239d2ae871cc355ea2cc1d5d578e21c8263242" }
|
||||
collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "45239d2ae871cc355ea2cc1d5d578e21c8263242" }
|
||||
collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "45239d2ae871cc355ea2cc1d5d578e21c8263242" }
|
||||
collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "45239d2ae871cc355ea2cc1d5d578e21c8263242" }
|
||||
collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "45239d2ae871cc355ea2cc1d5d578e21c8263242" }
|
||||
collab-importer = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "45239d2ae871cc355ea2cc1d5d578e21c8263242" }
|
||||
collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "80d1c6147d1139289c2eaadab40557cc86c0f4b6" }
|
||||
collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "80d1c6147d1139289c2eaadab40557cc86c0f4b6" }
|
||||
collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "80d1c6147d1139289c2eaadab40557cc86c0f4b6" }
|
||||
collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "80d1c6147d1139289c2eaadab40557cc86c0f4b6" }
|
||||
collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "80d1c6147d1139289c2eaadab40557cc86c0f4b6" }
|
||||
collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "80d1c6147d1139289c2eaadab40557cc86c0f4b6" }
|
||||
collab-importer = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "80d1c6147d1139289c2eaadab40557cc86c0f4b6" }
|
||||
|
||||
[features]
|
||||
history = []
|
||||
|
|
|
@ -62,7 +62,7 @@ impl DatabaseCollabService for TestDatabaseCollabService {
|
|||
) -> Result<EncodeCollabByOid, DatabaseError> {
|
||||
let params = object_ids
|
||||
.into_iter()
|
||||
.map(|object_id| QueryCollab::new(object_id, collab_type.clone()))
|
||||
.map(|object_id| QueryCollab::new(object_id, collab_type))
|
||||
.collect();
|
||||
let results = self
|
||||
.api_client
|
||||
|
|
|
@ -874,7 +874,7 @@ impl TestClient {
|
|||
.create_collab(CreateCollabParams {
|
||||
object_id: object_id.to_string(),
|
||||
encoded_collab_v1,
|
||||
collab_type: collab_type.clone(),
|
||||
collab_type,
|
||||
workspace_id: workspace_id.to_string(),
|
||||
})
|
||||
.await
|
||||
|
@ -1018,7 +1018,7 @@ impl TestClient {
|
|||
.create_collab(CreateCollabParams {
|
||||
object_id: object_id.to_string(),
|
||||
encoded_collab_v1,
|
||||
collab_type: collab_type.clone(),
|
||||
collab_type,
|
||||
workspace_id: workspace_id.to_string(),
|
||||
})
|
||||
.await
|
||||
|
@ -1159,12 +1159,11 @@ pub async fn assert_server_collab(
|
|||
workspace_id: &str,
|
||||
client: &mut client_api::Client,
|
||||
object_id: &str,
|
||||
collab_type: &CollabType,
|
||||
collab_type: CollabType,
|
||||
timeout_secs: u64,
|
||||
expected: Value,
|
||||
) -> Result<(), Error> {
|
||||
let duration = Duration::from_secs(timeout_secs);
|
||||
let collab_type = collab_type.clone();
|
||||
let object_id = object_id.to_string();
|
||||
let final_json = Arc::new(Mutex::from(json!({})));
|
||||
|
||||
|
@ -1175,7 +1174,7 @@ pub async fn assert_server_collab(
|
|||
let result = client
|
||||
.get_collab(QueryCollabParams::new(
|
||||
&object_id,
|
||||
collab_type.clone(),
|
||||
collab_type,
|
||||
workspace_id,
|
||||
))
|
||||
.await;
|
||||
|
|
|
@ -210,7 +210,7 @@ where
|
|||
let init_sync = InitSync::new(
|
||||
origin,
|
||||
sync_object.object_id.clone(),
|
||||
sync_object.collab_type.clone(),
|
||||
sync_object.collab_type,
|
||||
sync_object.workspace_id.clone(),
|
||||
msg_id,
|
||||
payload,
|
||||
|
@ -251,7 +251,7 @@ where
|
|||
let init_sync = InitSync::new(
|
||||
origin,
|
||||
sync_object.object_id.clone(),
|
||||
sync_object.collab_type.clone(),
|
||||
sync_object.collab_type,
|
||||
sync_object.workspace_id.clone(),
|
||||
msg_id,
|
||||
payload,
|
||||
|
|
|
@ -626,7 +626,7 @@ impl Action for GetCollabAction {
|
|||
fn run(&mut self) -> Self::Future {
|
||||
let client = self.client.clone();
|
||||
let params = self.params.clone();
|
||||
let collab_type = self.params.collab_type.clone();
|
||||
let collab_type = self.params.collab_type;
|
||||
|
||||
Box::pin(async move {
|
||||
let url = format!(
|
||||
|
|
|
@ -617,7 +617,7 @@ where
|
|||
{
|
||||
let collab_types: Vec<CollabType> = embedded_collab
|
||||
.iter()
|
||||
.map(|query| query.collab_type.clone())
|
||||
.map(|query| query.collab_type)
|
||||
.collect();
|
||||
let object_ids: Vec<String> = embedded_collab
|
||||
.into_iter()
|
||||
|
|
|
@ -56,11 +56,11 @@ impl IndexerProvider {
|
|||
/// Returns indexer for a specific type of [Collab] object.
|
||||
/// If collab of given type is not supported or workspace it belongs to has indexing disabled,
|
||||
/// returns `None`.
|
||||
pub fn indexer_for(&self, collab_type: &CollabType) -> Option<Arc<dyn Indexer>> {
|
||||
self.indexer_cache.get(collab_type).cloned()
|
||||
pub fn indexer_for(&self, collab_type: CollabType) -> Option<Arc<dyn Indexer>> {
|
||||
self.indexer_cache.get(&collab_type).cloned()
|
||||
}
|
||||
|
||||
pub fn is_indexing_enabled(&self, collab_type: &CollabType) -> bool {
|
||||
self.indexer_cache.contains_key(collab_type)
|
||||
pub fn is_indexing_enabled(&self, collab_type: CollabType) -> bool {
|
||||
self.indexer_cache.contains_key(&collab_type)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -137,7 +137,7 @@ impl IndexerScheduler {
|
|||
true
|
||||
}
|
||||
|
||||
pub fn is_indexing_enabled(&self, collab_type: &CollabType) -> bool {
|
||||
pub fn is_indexing_enabled(&self, collab_type: CollabType) -> bool {
|
||||
self.indexer_provider.is_indexing_enabled(collab_type)
|
||||
}
|
||||
|
||||
|
@ -206,7 +206,7 @@ impl IndexerScheduler {
|
|||
|
||||
let indexer = self
|
||||
.indexer_provider
|
||||
.indexer_for(&pending_collab.collab_type);
|
||||
.indexer_for(pending_collab.collab_type);
|
||||
if indexer.is_none() {
|
||||
return Ok(());
|
||||
}
|
||||
|
@ -228,7 +228,7 @@ impl IndexerScheduler {
|
|||
return Ok(());
|
||||
}
|
||||
|
||||
pending_collabs.retain(|collab| self.is_indexing_enabled(&collab.collab_type));
|
||||
pending_collabs.retain(|collab| self.is_indexing_enabled(collab.collab_type));
|
||||
if pending_collabs.is_empty() {
|
||||
return Ok(());
|
||||
}
|
||||
|
@ -244,7 +244,7 @@ impl IndexerScheduler {
|
|||
workspace_id: &str,
|
||||
object_id: &str,
|
||||
collab: &Collab,
|
||||
collab_type: &CollabType,
|
||||
collab_type: CollabType,
|
||||
) -> Result<(), AppError> {
|
||||
if !self.index_enabled() {
|
||||
return Ok(());
|
||||
|
@ -265,7 +265,7 @@ impl IndexerScheduler {
|
|||
let pending = UnindexedCollabTask::new(
|
||||
Uuid::parse_str(workspace_id)?,
|
||||
object_id.to_string(),
|
||||
collab_type.clone(),
|
||||
collab_type,
|
||||
UnindexedData::Text(text),
|
||||
);
|
||||
self.embed_immediately(pending)?;
|
||||
|
@ -342,7 +342,7 @@ async fn spawn_rayon_generate_embeddings(
|
|||
Ok(embedder) => {
|
||||
records.into_par_iter().for_each(|record| {
|
||||
let result = threads.install(|| {
|
||||
let indexer = indexer_provider.indexer_for(&record.collab_type);
|
||||
let indexer = indexer_provider.indexer_for(record.collab_type);
|
||||
match process_collab(&embedder, indexer, &record.object_id, record.data, &metrics) {
|
||||
Ok(Some((tokens_used, contents))) => {
|
||||
if let Err(err) = write_embedding_tx.send(EmbeddingRecord {
|
||||
|
|
|
@ -170,7 +170,7 @@ async fn create_embeddings(
|
|||
unindexed_records
|
||||
.into_par_iter()
|
||||
.flat_map(|unindexed| {
|
||||
let indexer = indexer_provider.indexer_for(&unindexed.collab_type)?;
|
||||
let indexer = indexer_provider.indexer_for(unindexed.collab_type)?;
|
||||
let collab = Collab::new_with_source(
|
||||
CollabOrigin::Empty,
|
||||
&unindexed.object_id,
|
||||
|
|
|
@ -212,6 +212,11 @@ pub struct MovePageParams {
|
|||
pub prev_view_id: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct ReorderFavoritePageParams {
|
||||
pub prev_view_id: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct DuplicatePageParams {
|
||||
pub suffix: Option<String>,
|
||||
|
|
|
@ -171,7 +171,7 @@ impl CollabCache {
|
|||
params: CollabParams,
|
||||
transaction: &mut Transaction<'_, sqlx::Postgres>,
|
||||
) -> Result<(), AppError> {
|
||||
let collab_type = params.collab_type.clone();
|
||||
let collab_type = params.collab_type;
|
||||
let object_id = params.object_id.clone();
|
||||
let encode_collab_data = params.encoded_collab_v1.clone();
|
||||
let s3 = self.disk_cache.s3_client();
|
||||
|
|
|
@ -403,12 +403,7 @@ where
|
|||
match collab_message {
|
||||
ClientCollabMessage::ClientInitSync { data, .. } => {
|
||||
self
|
||||
.create_group(
|
||||
user,
|
||||
&data.workspace_id,
|
||||
object_id,
|
||||
data.collab_type.clone(),
|
||||
)
|
||||
.create_group(user, &data.workspace_id, object_id, data.collab_type)
|
||||
.await?;
|
||||
Ok(())
|
||||
},
|
||||
|
|
|
@ -96,7 +96,7 @@ impl CollabGroup {
|
|||
uid,
|
||||
workspace_id.clone(),
|
||||
object_id.clone(),
|
||||
collab_type.clone(),
|
||||
collab_type,
|
||||
storage,
|
||||
collab_redis_stream,
|
||||
indexer_scheduler,
|
||||
|
@ -363,7 +363,7 @@ impl CollabGroup {
|
|||
.map_err(|e| AppError::Internal(e.into()))?;
|
||||
let workspace_id = &self.state.workspace_id;
|
||||
let object_id = &self.state.object_id;
|
||||
let collab_type = &self.state.collab_type;
|
||||
let collab_type = self.state.collab_type;
|
||||
self
|
||||
.state
|
||||
.persister
|
||||
|
@ -1149,7 +1149,7 @@ impl CollabPersister {
|
|||
.metrics
|
||||
.collab_size
|
||||
.observe(encoded_collab.len() as f64);
|
||||
let params = CollabParams::new(&self.object_id, self.collab_type.clone(), encoded_collab);
|
||||
let params = CollabParams::new(&self.object_id, self.collab_type, encoded_collab);
|
||||
self
|
||||
.storage
|
||||
.queue_insert_or_update_collab(&self.workspace_id, &self.uid, params, true)
|
||||
|
@ -1163,7 +1163,7 @@ impl CollabPersister {
|
|||
let indexed_collab = UnindexedCollabTask::new(
|
||||
workspace_id,
|
||||
self.object_id.clone(),
|
||||
self.collab_type.clone(),
|
||||
self.collab_type,
|
||||
UnindexedData::Text(text),
|
||||
);
|
||||
if let Err(err) = self
|
||||
|
@ -1182,7 +1182,7 @@ impl CollabPersister {
|
|||
// we didn't find a snapshot, or we want a lightweight collab version
|
||||
let params = QueryCollabParams::new(
|
||||
self.object_id.clone(),
|
||||
self.collab_type.clone(),
|
||||
self.collab_type,
|
||||
self.workspace_id.clone(),
|
||||
);
|
||||
let result = self
|
||||
|
|
|
@ -118,7 +118,7 @@ where
|
|||
object_id: &str,
|
||||
collab_type: CollabType,
|
||||
) -> Result<(), RealtimeError> {
|
||||
let params = QueryCollabParams::new(object_id, collab_type.clone(), workspace_id);
|
||||
let params = QueryCollabParams::new(object_id, collab_type, workspace_id);
|
||||
let res = self
|
||||
.storage
|
||||
.get_encode_collab(GetCollabOrigin::Server, params, false)
|
||||
|
|
|
@ -96,7 +96,7 @@ where
|
|||
self.did_create_snapshot.store(true, Ordering::SeqCst);
|
||||
let storage = self.storage.clone();
|
||||
let weak_collab = self.weak_collab.clone();
|
||||
let collab_type = self.collab_type.clone();
|
||||
let collab_type = self.collab_type;
|
||||
let object_id = self.object_id.clone();
|
||||
let workspace_id = self.workspace_id.clone();
|
||||
|
||||
|
|
|
@ -135,7 +135,7 @@ async fn process_upcoming_tasks(
|
|||
|
||||
let collab_ids: Vec<(String, CollabType)> = tasks
|
||||
.iter()
|
||||
.map(|task| (task.object_id.clone(), task.collab_type.clone()))
|
||||
.map(|task| (task.object_id.clone(), task.collab_type))
|
||||
.collect();
|
||||
|
||||
let indexed_collabs = get_collabs_indexed_at(&pg_pool, collab_ids)
|
||||
|
@ -160,7 +160,7 @@ async fn process_upcoming_tasks(
|
|||
let num_tasks = tasks.len();
|
||||
tasks.into_par_iter().for_each(|task| {
|
||||
let result = threads.install(|| {
|
||||
if let Some(indexer) = indexer_provider.indexer_for(&task.collab_type) {
|
||||
if let Some(indexer) = indexer_provider.indexer_for(task.collab_type) {
|
||||
let embedder = create_embedder(&config);
|
||||
let result = handle_task(embedder, indexer, task);
|
||||
match result {
|
||||
|
|
|
@ -16,8 +16,8 @@ use crate::biz::workspace::ops::{
|
|||
use crate::biz::workspace::page_view::{
|
||||
append_block_at_the_end_of_page, create_database_view, create_page, create_space,
|
||||
delete_all_pages_from_trash, delete_trash, favorite_page, get_page_view_collab, move_page,
|
||||
move_page_to_trash, publish_page, restore_all_pages_from_trash, restore_page_from_trash,
|
||||
unpublish_page, update_page, update_page_collab_data, update_space,
|
||||
move_page_to_trash, publish_page, reorder_favorite_page, restore_all_pages_from_trash,
|
||||
restore_page_from_trash, unpublish_page, update_page, update_page_collab_data, update_space,
|
||||
};
|
||||
use crate::biz::workspace::publish::get_workspace_default_publish_view_info_meta;
|
||||
use crate::biz::workspace::quick_note::{
|
||||
|
@ -189,6 +189,10 @@ pub fn workspace_scope() -> Scope {
|
|||
web::resource("/{workspace_id}/page-view/{view_id}/move")
|
||||
.route(web::post().to(move_page_handler)),
|
||||
)
|
||||
.service(
|
||||
web::resource("/{workspace_id}/page-view/{view_id}/reorder-favorite")
|
||||
.route(web::post().to(reorder_favorite_page_handler)),
|
||||
)
|
||||
.service(
|
||||
web::resource("/{workspace_id}/page-view/{view_id}/duplicate")
|
||||
.route(web::post().to(duplicate_page_handler)),
|
||||
|
@ -815,7 +819,7 @@ async fn create_collab_handler(
|
|||
let pending = UnindexedCollabTask::new(
|
||||
workspace_id_uuid,
|
||||
params.object_id.clone(),
|
||||
params.collab_type.clone(),
|
||||
params.collab_type,
|
||||
UnindexedData::Text(text),
|
||||
);
|
||||
state
|
||||
|
@ -962,11 +966,7 @@ async fn batch_create_collab_handler(
|
|||
{
|
||||
pending_undexed_collabs = collab_params_list
|
||||
.iter_mut()
|
||||
.filter(|p| {
|
||||
state
|
||||
.indexer_scheduler
|
||||
.is_indexing_enabled(&p.1.collab_type)
|
||||
})
|
||||
.filter(|p| state.indexer_scheduler.is_indexing_enabled(p.1.collab_type))
|
||||
.flat_map(|value| match std::mem::take(&mut value.0) {
|
||||
None => None,
|
||||
Some(text) => text
|
||||
|
@ -974,7 +974,7 @@ async fn batch_create_collab_handler(
|
|||
UnindexedCollabTask::new(
|
||||
workspace_id_uuid,
|
||||
value.1.object_id.clone(),
|
||||
value.1.collab_type.clone(),
|
||||
value.1.collab_type,
|
||||
UnindexedData::Text(text),
|
||||
)
|
||||
})
|
||||
|
@ -1138,7 +1138,7 @@ async fn post_web_update_handler(
|
|||
trace!("create onetime web realtime user: {}", user);
|
||||
|
||||
let payload = payload.into_inner();
|
||||
let collab_type = payload.collab_type.clone();
|
||||
let collab_type = payload.collab_type;
|
||||
|
||||
update_page_collab_data(
|
||||
&state.metrics.appflowy_web_metrics,
|
||||
|
@ -1293,6 +1293,30 @@ async fn move_page_handler(
|
|||
Ok(Json(AppResponse::Ok()))
|
||||
}
|
||||
|
||||
async fn reorder_favorite_page_handler(
|
||||
user_uuid: UserUuid,
|
||||
path: web::Path<(Uuid, String)>,
|
||||
payload: Json<ReorderFavoritePageParams>,
|
||||
state: Data<AppState>,
|
||||
server: Data<RealtimeServerAddr>,
|
||||
req: HttpRequest,
|
||||
) -> Result<Json<AppResponse<()>>> {
|
||||
let uid = state.user_cache.get_user_uid(&user_uuid).await?;
|
||||
let (workspace_uuid, view_id) = path.into_inner();
|
||||
let user = realtime_user_for_web_request(req.headers(), uid)?;
|
||||
reorder_favorite_page(
|
||||
&state.metrics.appflowy_web_metrics,
|
||||
server,
|
||||
user,
|
||||
&state.collab_access_control_storage,
|
||||
workspace_uuid,
|
||||
&view_id,
|
||||
payload.prev_view_id.as_deref(),
|
||||
)
|
||||
.await?;
|
||||
Ok(Json(AppResponse::Ok()))
|
||||
}
|
||||
|
||||
async fn duplicate_page_handler(
|
||||
user_uuid: UserUuid,
|
||||
path: web::Path<(Uuid, Uuid)>,
|
||||
|
@ -1649,7 +1673,7 @@ async fn create_collab_snapshot_handler(
|
|||
.collab_access_control_storage
|
||||
.get_encode_collab(
|
||||
GetCollabOrigin::User { uid },
|
||||
QueryCollabParams::new(&object_id, collab_type.clone(), &workspace_id),
|
||||
QueryCollabParams::new(&object_id, collab_type, &workspace_id),
|
||||
true,
|
||||
)
|
||||
.await?
|
||||
|
@ -1748,7 +1772,7 @@ async fn update_collab_handler(
|
|||
let pending = UnindexedCollabTask::new(
|
||||
workspace_id_uuid,
|
||||
params.object_id.clone(),
|
||||
params.collab_type.clone(),
|
||||
params.collab_type,
|
||||
UnindexedData::Text(text),
|
||||
);
|
||||
state
|
||||
|
|
|
@ -284,7 +284,7 @@ pub async fn batch_get_latest_collab_encoded(
|
|||
.iter()
|
||||
.map(|row_id| QueryCollab {
|
||||
object_id: row_id.to_string(),
|
||||
collab_type: collab_type.clone(),
|
||||
collab_type,
|
||||
})
|
||||
.collect();
|
||||
let query_collab_results = collab_storage
|
||||
|
|
|
@ -49,7 +49,7 @@ where
|
|||
database_id,
|
||||
} => (object_id.clone(), database_id.clone()),
|
||||
};
|
||||
let object_type = template.collab_type.clone();
|
||||
let object_type = template.collab_type;
|
||||
let encoded_collab_v1 = template
|
||||
.encoded_collab
|
||||
.encode_to_bytes()
|
||||
|
@ -57,7 +57,7 @@ where
|
|||
collab_params.push(CollabParams {
|
||||
object_id: object_id.clone(),
|
||||
encoded_collab_v1: encoded_collab_v1.into(),
|
||||
collab_type: object_type.clone(),
|
||||
collab_type: object_type,
|
||||
});
|
||||
|
||||
// push the database record
|
||||
|
|
|
@ -701,6 +701,26 @@ async fn update_favorite_view(
|
|||
Ok(encoded_update)
|
||||
}
|
||||
|
||||
async fn reorder_favorite_section(
|
||||
view_id: &str,
|
||||
prev_view_id: Option<&str>,
|
||||
folder: &mut Folder,
|
||||
) -> Result<Vec<u8>, AppError> {
|
||||
let encoded_update = {
|
||||
let mut txn = folder.collab.transact_mut();
|
||||
if let Some(op) = folder
|
||||
.body
|
||||
.section
|
||||
.section_op(&txn, collab_folder::Section::Favorite)
|
||||
{
|
||||
op.move_section_item_with_txn(&mut txn, view_id, prev_view_id);
|
||||
};
|
||||
txn.encode_update_v1()
|
||||
};
|
||||
|
||||
Ok(encoded_update)
|
||||
}
|
||||
|
||||
async fn update_view_properties(
|
||||
view_id: &str,
|
||||
folder: &mut Folder,
|
||||
|
@ -1169,6 +1189,31 @@ pub async fn move_page(
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub async fn reorder_favorite_page(
|
||||
appflowy_web_metrics: &AppFlowyWebMetrics,
|
||||
server: Data<RealtimeServerAddr>,
|
||||
user: RealtimeUser,
|
||||
collab_storage: &CollabAccessControlStorage,
|
||||
workspace_id: Uuid,
|
||||
view_id: &str,
|
||||
prev_view_id: Option<&str>,
|
||||
) -> Result<(), AppError> {
|
||||
let collab_origin = GetCollabOrigin::User { uid: user.uid };
|
||||
let mut folder =
|
||||
get_latest_collab_folder(collab_storage, collab_origin, &workspace_id.to_string()).await?;
|
||||
let folder_update = reorder_favorite_section(view_id, prev_view_id, &mut folder).await?;
|
||||
update_workspace_folder_data(
|
||||
appflowy_web_metrics,
|
||||
server,
|
||||
user,
|
||||
workspace_id,
|
||||
folder_update,
|
||||
)
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn move_page_to_trash(
|
||||
appflowy_web_metrics: &AppFlowyWebMetrics,
|
||||
server: Data<RealtimeServerAddr>,
|
||||
|
|
|
@ -19,7 +19,7 @@ async fn viewing_document_editing_users_test() {
|
|||
.unwrap();
|
||||
|
||||
let object_id = owner
|
||||
.create_and_edit_collab(&workspace_id, collab_type.clone())
|
||||
.create_and_edit_collab(&workspace_id, collab_type)
|
||||
.await;
|
||||
|
||||
let owner_uid = owner.uid().await;
|
||||
|
|
|
@ -184,7 +184,7 @@ async fn batch_insert_document_collab_test() {
|
|||
.iter()
|
||||
.map(|params| QueryCollab {
|
||||
object_id: params.object_id.clone(),
|
||||
collab_type: params.collab_type.clone(),
|
||||
collab_type: params.collab_type,
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ async fn make_clients() -> (TestClient, TestClient, String, Value) {
|
|||
// Create a collaborative document with client_1 and invite client_2 to collaborate.
|
||||
let workspace_id = client_1.workspace_id().await;
|
||||
let object_id = client_1
|
||||
.create_and_edit_collab(&workspace_id, collab_type.clone())
|
||||
.create_and_edit_collab(&workspace_id, collab_type)
|
||||
.await;
|
||||
client_1
|
||||
.invite_and_accepted_workspace_member(&workspace_id, &client_2, AFRole::Member)
|
||||
|
@ -61,7 +61,7 @@ async fn make_clients() -> (TestClient, TestClient, String, Value) {
|
|||
|
||||
// after client 2 finish init sync and then disable receive message
|
||||
client_2
|
||||
.open_collab(&workspace_id, &object_id, collab_type.clone())
|
||||
.open_collab(&workspace_id, &object_id, collab_type)
|
||||
.await;
|
||||
client_2
|
||||
.wait_object_sync_complete(&object_id)
|
||||
|
|
|
@ -18,7 +18,7 @@ async fn sync_collab_content_after_reconnect_test() {
|
|||
let mut test_client = TestClient::new_user().await;
|
||||
let workspace_id = test_client.workspace_id().await;
|
||||
test_client
|
||||
.open_collab(&workspace_id, &object_id, collab_type.clone())
|
||||
.open_collab(&workspace_id, &object_id, collab_type)
|
||||
.await;
|
||||
|
||||
// Disconnect the client and edit the collab. The updates will not be sent to the server.
|
||||
|
@ -34,7 +34,7 @@ async fn sync_collab_content_after_reconnect_test() {
|
|||
.api_client
|
||||
.get_collab(QueryCollabParams::new(
|
||||
&object_id,
|
||||
collab_type.clone(),
|
||||
collab_type,
|
||||
&workspace_id,
|
||||
))
|
||||
.await
|
||||
|
@ -53,7 +53,7 @@ async fn sync_collab_content_after_reconnect_test() {
|
|||
&workspace_id,
|
||||
&mut test_client.api_client,
|
||||
&object_id,
|
||||
&collab_type,
|
||||
collab_type,
|
||||
10,
|
||||
json!( {
|
||||
"0": "0",
|
||||
|
@ -77,7 +77,7 @@ async fn same_client_with_diff_devices_edit_same_collab_test() {
|
|||
|
||||
let workspace_id = client_1.workspace_id().await;
|
||||
let object_id = client_1
|
||||
.create_and_edit_collab(&workspace_id, collab_type.clone())
|
||||
.create_and_edit_collab(&workspace_id, collab_type)
|
||||
.await;
|
||||
|
||||
// client 1 edit the collab
|
||||
|
@ -91,7 +91,7 @@ async fn same_client_with_diff_devices_edit_same_collab_test() {
|
|||
&workspace_id,
|
||||
&mut client_1.api_client,
|
||||
&object_id,
|
||||
&collab_type,
|
||||
collab_type,
|
||||
30,
|
||||
json!({
|
||||
"name": "workspace1"
|
||||
|
@ -101,7 +101,7 @@ async fn same_client_with_diff_devices_edit_same_collab_test() {
|
|||
.unwrap();
|
||||
|
||||
client_2
|
||||
.open_collab(&workspace_id, &object_id, collab_type.clone())
|
||||
.open_collab(&workspace_id, &object_id, collab_type)
|
||||
.await;
|
||||
client_2
|
||||
.wait_object_sync_complete(&object_id)
|
||||
|
@ -139,10 +139,10 @@ async fn same_client_with_diff_devices_edit_diff_collab_test() {
|
|||
|
||||
// different devices create different collabs. the collab will be synced between devices
|
||||
let object_id_1 = device_1
|
||||
.create_and_edit_collab(&workspace_id, collab_type.clone())
|
||||
.create_and_edit_collab(&workspace_id, collab_type)
|
||||
.await;
|
||||
let object_id_2 = device_2
|
||||
.create_and_edit_collab(&workspace_id, collab_type.clone())
|
||||
.create_and_edit_collab(&workspace_id, collab_type)
|
||||
.await;
|
||||
|
||||
// client 1 edit the collab with object_id_1
|
||||
|
@ -161,7 +161,7 @@ async fn same_client_with_diff_devices_edit_diff_collab_test() {
|
|||
|
||||
// client1 open the collab with object_id_2
|
||||
device_1
|
||||
.open_collab(&workspace_id, &object_id_2, collab_type.clone())
|
||||
.open_collab(&workspace_id, &object_id_2, collab_type)
|
||||
.await;
|
||||
assert_client_collab_within_secs(
|
||||
&mut device_1,
|
||||
|
@ -176,7 +176,7 @@ async fn same_client_with_diff_devices_edit_diff_collab_test() {
|
|||
|
||||
// client2 open the collab with object_id_1
|
||||
device_2
|
||||
.open_collab(&workspace_id, &object_id_1, collab_type.clone())
|
||||
.open_collab(&workspace_id, &object_id_1, collab_type)
|
||||
.await;
|
||||
assert_client_collab_within_secs(
|
||||
&mut device_2,
|
||||
|
@ -198,7 +198,7 @@ async fn edit_document_with_both_clients_offline_then_online_sync_test() {
|
|||
|
||||
let workspace_id = client_1.workspace_id().await;
|
||||
let object_id = client_1
|
||||
.create_and_edit_collab(&workspace_id, collab_type.clone())
|
||||
.create_and_edit_collab(&workspace_id, collab_type)
|
||||
.await;
|
||||
|
||||
// add client 2 as a member of the workspace
|
||||
|
@ -209,7 +209,7 @@ async fn edit_document_with_both_clients_offline_then_online_sync_test() {
|
|||
client_1.disconnect().await;
|
||||
|
||||
client_2
|
||||
.open_collab(&workspace_id, &object_id, collab_type.clone())
|
||||
.open_collab(&workspace_id, &object_id, collab_type)
|
||||
.await;
|
||||
client_2.disconnect().await;
|
||||
|
||||
|
|
|
@ -24,11 +24,11 @@ async fn recv_updates_without_permission_test() {
|
|||
|
||||
let workspace_id = client_1.workspace_id().await;
|
||||
let object_id = client_1
|
||||
.create_and_edit_collab(&workspace_id, collab_type.clone())
|
||||
.create_and_edit_collab(&workspace_id, collab_type)
|
||||
.await;
|
||||
|
||||
client_2
|
||||
.open_collab(&workspace_id, &object_id, collab_type.clone())
|
||||
.open_collab(&workspace_id, &object_id, collab_type)
|
||||
.await;
|
||||
|
||||
// Edit the collab from client 1 and then the server will broadcast to client 2. But the client 2
|
||||
|
@ -49,7 +49,7 @@ async fn recv_updates_without_permission_test() {
|
|||
//
|
||||
// let workspace_id = client_1.workspace_id().await;
|
||||
// let object_id = client_1
|
||||
// .create_and_edit_collab(&workspace_id, collab_type.clone())
|
||||
// .create_and_edit_collab(&workspace_id, collab_type)
|
||||
// .await;
|
||||
//
|
||||
// // Add client 2 as the member of the collab then the client 2 will receive the update.
|
||||
|
@ -63,7 +63,7 @@ async fn recv_updates_without_permission_test() {
|
|||
// .await;
|
||||
//
|
||||
// client_2
|
||||
// .open_collab(&workspace_id, &object_id, collab_type.clone())
|
||||
// .open_collab(&workspace_id, &object_id, collab_type)
|
||||
// .await;
|
||||
//
|
||||
// // Edit the collab from client 1 and then the server will broadcast to client 2
|
||||
|
@ -103,7 +103,7 @@ async fn recv_updates_without_permission_test() {
|
|||
//
|
||||
// let workspace_id = client_1.workspace_id().await;
|
||||
// let object_id = client_1
|
||||
// .create_and_edit_collab(&workspace_id, collab_type.clone())
|
||||
// .create_and_edit_collab(&workspace_id, collab_type)
|
||||
// .await;
|
||||
// client_1
|
||||
// .collabs
|
||||
|
@ -144,7 +144,7 @@ async fn recv_updates_without_permission_test() {
|
|||
// )
|
||||
// .await;
|
||||
// client_2
|
||||
// .open_collab(&workspace_id, &object_id, collab_type.clone())
|
||||
// .open_collab(&workspace_id, &object_id, collab_type)
|
||||
// .await;
|
||||
// assert_client_collab_include_value(&mut client_2, &object_id, expected)
|
||||
// .await
|
||||
|
@ -159,7 +159,7 @@ async fn edit_collab_with_readonly_permission_test() {
|
|||
|
||||
let workspace_id = client_1.workspace_id().await;
|
||||
let object_id = client_1
|
||||
.create_and_edit_collab(&workspace_id, collab_type.clone())
|
||||
.create_and_edit_collab(&workspace_id, collab_type)
|
||||
.await;
|
||||
|
||||
// Add client 2 as the member of the collab then the client 2 will receive the update.
|
||||
|
@ -169,7 +169,7 @@ async fn edit_collab_with_readonly_permission_test() {
|
|||
.unwrap();
|
||||
|
||||
client_2
|
||||
.open_collab(&workspace_id, &object_id, collab_type.clone())
|
||||
.open_collab(&workspace_id, &object_id, collab_type)
|
||||
.await;
|
||||
|
||||
// client 2 edit the collab and then the server will reject the update which mean the
|
||||
|
@ -189,7 +189,7 @@ async fn edit_collab_with_readonly_permission_test() {
|
|||
&workspace_id,
|
||||
&mut client_1.api_client,
|
||||
&object_id,
|
||||
&collab_type,
|
||||
collab_type,
|
||||
5,
|
||||
json!({}),
|
||||
)
|
||||
|
@ -205,7 +205,7 @@ async fn edit_collab_with_read_and_write_permission_test() {
|
|||
|
||||
let workspace_id = client_1.workspace_id().await;
|
||||
let object_id = client_1
|
||||
.create_and_edit_collab(&workspace_id, collab_type.clone())
|
||||
.create_and_edit_collab(&workspace_id, collab_type)
|
||||
.await;
|
||||
|
||||
// Add client 2 as the member of the collab then the client 2 will receive the update.
|
||||
|
@ -215,7 +215,7 @@ async fn edit_collab_with_read_and_write_permission_test() {
|
|||
.unwrap();
|
||||
|
||||
client_2
|
||||
.open_collab(&workspace_id, &object_id, collab_type.clone())
|
||||
.open_collab(&workspace_id, &object_id, collab_type)
|
||||
.await;
|
||||
|
||||
// client 2 edit the collab and then the server will broadcast the update
|
||||
|
@ -236,7 +236,7 @@ async fn edit_collab_with_read_and_write_permission_test() {
|
|||
&workspace_id,
|
||||
&mut client_1.api_client,
|
||||
&object_id,
|
||||
&collab_type,
|
||||
collab_type,
|
||||
5,
|
||||
expected,
|
||||
)
|
||||
|
@ -252,7 +252,7 @@ async fn edit_collab_with_full_access_permission_test() {
|
|||
|
||||
let workspace_id = client_1.workspace_id().await;
|
||||
let object_id = client_1
|
||||
.create_and_edit_collab(&workspace_id, collab_type.clone())
|
||||
.create_and_edit_collab(&workspace_id, collab_type)
|
||||
.await;
|
||||
|
||||
// Add client 2 as the member of the collab then the client 2 will receive the update.
|
||||
|
@ -262,7 +262,7 @@ async fn edit_collab_with_full_access_permission_test() {
|
|||
.unwrap();
|
||||
|
||||
client_2
|
||||
.open_collab(&workspace_id, &object_id, collab_type.clone())
|
||||
.open_collab(&workspace_id, &object_id, collab_type)
|
||||
.await;
|
||||
|
||||
// client 2 edit the collab and then the server will broadcast the update
|
||||
|
@ -281,7 +281,7 @@ async fn edit_collab_with_full_access_permission_test() {
|
|||
&workspace_id,
|
||||
&mut client_1.api_client,
|
||||
&object_id,
|
||||
&collab_type,
|
||||
collab_type,
|
||||
5,
|
||||
expected,
|
||||
)
|
||||
|
@ -297,7 +297,7 @@ async fn edit_collab_with_full_access_then_readonly_permission() {
|
|||
|
||||
let workspace_id = client_1.workspace_id().await;
|
||||
let object_id = client_1
|
||||
.create_and_edit_collab(&workspace_id, collab_type.clone())
|
||||
.create_and_edit_collab(&workspace_id, collab_type)
|
||||
.await;
|
||||
|
||||
// Add client 2 as the member of the collab then the client 2 will receive the update.
|
||||
|
@ -309,7 +309,7 @@ async fn edit_collab_with_full_access_then_readonly_permission() {
|
|||
// client 2 edit the collab and then the server will broadcast the update
|
||||
{
|
||||
client_2
|
||||
.open_collab(&workspace_id, &object_id, collab_type.clone())
|
||||
.open_collab(&workspace_id, &object_id, collab_type)
|
||||
.await;
|
||||
client_2
|
||||
.insert_into(&object_id, "title", "hello world")
|
||||
|
@ -346,7 +346,7 @@ async fn edit_collab_with_full_access_then_readonly_permission() {
|
|||
&workspace_id,
|
||||
&mut client_1.api_client,
|
||||
&object_id,
|
||||
&collab_type,
|
||||
collab_type,
|
||||
5,
|
||||
json!({
|
||||
"title": "hello world"
|
||||
|
@ -364,7 +364,7 @@ async fn multiple_user_with_read_and_write_permission_edit_same_collab_test() {
|
|||
let collab_type = CollabType::Unknown;
|
||||
let workspace_id = owner.workspace_id().await;
|
||||
owner
|
||||
.create_and_edit_collab_with_data(&object_id, &workspace_id, collab_type.clone(), None)
|
||||
.create_and_edit_collab_with_data(&object_id, &workspace_id, collab_type, None)
|
||||
.await;
|
||||
|
||||
let arc_owner = Arc::new(owner);
|
||||
|
@ -373,7 +373,6 @@ async fn multiple_user_with_read_and_write_permission_edit_same_collab_test() {
|
|||
for i in 0..3 {
|
||||
let owner = arc_owner.clone();
|
||||
let object_id = object_id.clone();
|
||||
let collab_type = collab_type.clone();
|
||||
let workspace_id = workspace_id.clone();
|
||||
let task = tokio::spawn(async move {
|
||||
let mut new_member = TestClient::new_user().await;
|
||||
|
@ -386,7 +385,7 @@ async fn multiple_user_with_read_and_write_permission_edit_same_collab_test() {
|
|||
.unwrap();
|
||||
|
||||
new_member
|
||||
.open_collab(&workspace_id, &object_id, collab_type.clone())
|
||||
.open_collab(&workspace_id, &object_id, collab_type)
|
||||
.await;
|
||||
|
||||
// generate random string and insert it to the collab
|
||||
|
@ -444,7 +443,7 @@ async fn multiple_user_with_read_only_permission_edit_same_collab_test() {
|
|||
let collab_type = CollabType::Unknown;
|
||||
let workspace_id = owner.workspace_id().await;
|
||||
let object_id = owner
|
||||
.create_and_edit_collab(&workspace_id, collab_type.clone())
|
||||
.create_and_edit_collab(&workspace_id, collab_type)
|
||||
.await;
|
||||
|
||||
let arc_owner = Arc::new(owner);
|
||||
|
@ -452,7 +451,6 @@ async fn multiple_user_with_read_only_permission_edit_same_collab_test() {
|
|||
for i in 0..5 {
|
||||
let owner = arc_owner.clone();
|
||||
let object_id = object_id.clone();
|
||||
let collab_type = collab_type.clone();
|
||||
let workspace_id = workspace_id.clone();
|
||||
let task = tokio::spawn(async move {
|
||||
let mut new_user = TestClient::new_user().await;
|
||||
|
@ -464,7 +462,7 @@ async fn multiple_user_with_read_only_permission_edit_same_collab_test() {
|
|||
.unwrap();
|
||||
|
||||
new_user
|
||||
.open_collab(&workspace_id, &object_id, collab_type.clone())
|
||||
.open_collab(&workspace_id, &object_id, collab_type)
|
||||
.await;
|
||||
|
||||
let random_str = generate_random_string(200);
|
||||
|
|
|
@ -21,10 +21,10 @@ async fn realtime_write_single_collab_test() {
|
|||
let mut test_client = TestClient::new_user().await;
|
||||
let workspace_id = test_client.workspace_id().await;
|
||||
let object_id = test_client
|
||||
.create_and_edit_collab(&workspace_id, collab_type.clone())
|
||||
.create_and_edit_collab(&workspace_id, collab_type)
|
||||
.await;
|
||||
test_client
|
||||
.open_collab(&workspace_id, &object_id, collab_type.clone())
|
||||
.open_collab(&workspace_id, &object_id, collab_type)
|
||||
.await;
|
||||
|
||||
// Edit the collab
|
||||
|
@ -49,7 +49,7 @@ async fn realtime_write_single_collab_test() {
|
|||
&workspace_id,
|
||||
&mut test_client.api_client,
|
||||
&object_id,
|
||||
&collab_type,
|
||||
collab_type,
|
||||
10,
|
||||
expected_json,
|
||||
)
|
||||
|
@ -67,7 +67,7 @@ async fn collab_write_small_chunk_of_data_test() {
|
|||
// The [CollabStoragePlugin] plugin try to get the collab object from the database, but it doesn't exist.
|
||||
// So the plugin will create the collab object.
|
||||
test_client
|
||||
.open_collab(&workspace_id, &object_id, collab_type.clone())
|
||||
.open_collab(&workspace_id, &object_id, collab_type)
|
||||
.await;
|
||||
let mut expected_json = HashMap::new();
|
||||
|
||||
|
@ -90,7 +90,7 @@ async fn collab_write_small_chunk_of_data_test() {
|
|||
&workspace_id,
|
||||
&mut test_client.api_client,
|
||||
&object_id,
|
||||
&collab_type,
|
||||
collab_type,
|
||||
10,
|
||||
json!(expected_json),
|
||||
)
|
||||
|
@ -106,7 +106,7 @@ async fn collab_write_big_chunk_of_data_test() {
|
|||
let object_id = Uuid::new_v4().to_string();
|
||||
|
||||
test_client
|
||||
.open_collab(&workspace_id, &object_id, collab_type.clone())
|
||||
.open_collab(&workspace_id, &object_id, collab_type)
|
||||
.await;
|
||||
let s = generate_random_string(10000);
|
||||
test_client
|
||||
|
@ -121,7 +121,7 @@ async fn collab_write_big_chunk_of_data_test() {
|
|||
&workspace_id,
|
||||
&mut test_client.api_client,
|
||||
&object_id,
|
||||
&collab_type,
|
||||
collab_type,
|
||||
10,
|
||||
json!({
|
||||
"big_text": s
|
||||
|
@ -143,7 +143,7 @@ async fn write_big_chunk_data_init_sync_test() {
|
|||
// the big doc_state will force the init_sync using the http request.
|
||||
// It will trigger the POST_REALTIME_MESSAGE_STREAM_HANDLER to handle the request.
|
||||
test_client
|
||||
.open_collab_with_doc_state(&workspace_id, &object_id, collab_type.clone(), doc_state)
|
||||
.open_collab_with_doc_state(&workspace_id, &object_id, collab_type, doc_state)
|
||||
.await;
|
||||
test_client
|
||||
.wait_object_sync_complete(&object_id)
|
||||
|
@ -154,7 +154,7 @@ async fn write_big_chunk_data_init_sync_test() {
|
|||
&workspace_id,
|
||||
&mut test_client.api_client,
|
||||
&object_id,
|
||||
&collab_type,
|
||||
collab_type,
|
||||
10,
|
||||
json!({
|
||||
"big_text": big_text
|
||||
|
@ -173,11 +173,11 @@ async fn realtime_write_multiple_collab_test() {
|
|||
let collab_type = CollabType::Unknown;
|
||||
|
||||
let object_id = test_client
|
||||
.create_and_edit_collab(&workspace_id, collab_type.clone())
|
||||
.create_and_edit_collab(&workspace_id, collab_type)
|
||||
.await;
|
||||
|
||||
test_client
|
||||
.open_collab(&workspace_id, &object_id, collab_type.clone())
|
||||
.open_collab(&workspace_id, &object_id, collab_type)
|
||||
.await;
|
||||
for i in 0..=5 {
|
||||
test_client
|
||||
|
@ -198,7 +198,7 @@ async fn realtime_write_multiple_collab_test() {
|
|||
&workspace_id,
|
||||
&mut test_client.api_client,
|
||||
&object_id,
|
||||
&CollabType::Document,
|
||||
CollabType::Document,
|
||||
10,
|
||||
json!( {
|
||||
"0": "0",
|
||||
|
@ -223,7 +223,7 @@ async fn second_connect_override_first_connect_test() {
|
|||
let workspace_id = client.workspace_id().await;
|
||||
|
||||
let object_id = client
|
||||
.create_and_edit_collab(&workspace_id, collab_type.clone())
|
||||
.create_and_edit_collab(&workspace_id, collab_type)
|
||||
.await;
|
||||
|
||||
client.insert_into(&object_id, "1", "a").await;
|
||||
|
@ -238,7 +238,7 @@ async fn second_connect_override_first_connect_test() {
|
|||
let mut new_client =
|
||||
TestClient::new_with_device_id(&client.device_id, client.user.clone(), true).await;
|
||||
new_client
|
||||
.open_collab(&workspace_id, &object_id, collab_type.clone())
|
||||
.open_collab(&workspace_id, &object_id, collab_type)
|
||||
.await;
|
||||
new_client.insert_into(&object_id, "2", "b").await;
|
||||
new_client
|
||||
|
@ -261,7 +261,7 @@ async fn second_connect_override_first_connect_test() {
|
|||
&workspace_id,
|
||||
&mut new_client.api_client,
|
||||
&object_id,
|
||||
&collab_type,
|
||||
collab_type,
|
||||
60,
|
||||
json!({
|
||||
"1": "a",
|
||||
|
@ -279,7 +279,7 @@ async fn same_device_multiple_connect_in_order_test() {
|
|||
let workspace_id = old_client.workspace_id().await;
|
||||
|
||||
let object_id = old_client
|
||||
.create_and_edit_collab(&workspace_id, collab_type.clone())
|
||||
.create_and_edit_collab(&workspace_id, collab_type)
|
||||
.await;
|
||||
// simulate client try to connect the websocket server by three times
|
||||
// each connect alter the document
|
||||
|
@ -287,7 +287,7 @@ async fn same_device_multiple_connect_in_order_test() {
|
|||
let mut new_client =
|
||||
TestClient::new_with_device_id(&old_client.device_id, old_client.user.clone(), true).await;
|
||||
new_client
|
||||
.open_collab(&workspace_id, &object_id, collab_type.clone())
|
||||
.open_collab(&workspace_id, &object_id, collab_type)
|
||||
.await;
|
||||
new_client.insert_into(&object_id, &i.to_string(), i).await;
|
||||
sleep(Duration::from_millis(500)).await;
|
||||
|
@ -301,7 +301,7 @@ async fn same_device_multiple_connect_in_order_test() {
|
|||
&workspace_id,
|
||||
&mut old_client.api_client,
|
||||
&object_id,
|
||||
&collab_type,
|
||||
collab_type,
|
||||
10,
|
||||
json!({"0":0,"1":1,"2":2}),
|
||||
)
|
||||
|
@ -316,7 +316,7 @@ async fn two_direction_peer_sync_test() {
|
|||
let mut client_1 = TestClient::new_user().await;
|
||||
let workspace_id = client_1.workspace_id().await;
|
||||
let object_id = client_1
|
||||
.create_and_edit_collab(&workspace_id, collab_type.clone())
|
||||
.create_and_edit_collab(&workspace_id, collab_type)
|
||||
.await;
|
||||
|
||||
let mut client_2 = TestClient::new_user().await;
|
||||
|
@ -328,7 +328,7 @@ async fn two_direction_peer_sync_test() {
|
|||
.unwrap();
|
||||
|
||||
client_2
|
||||
.open_collab(&workspace_id, &object_id, collab_type.clone())
|
||||
.open_collab(&workspace_id, &object_id, collab_type)
|
||||
.await;
|
||||
|
||||
client_1.insert_into(&object_id, "name", "AppFlowy").await;
|
||||
|
@ -367,19 +367,19 @@ async fn multiple_collab_edit_test() {
|
|||
let mut client_1 = TestClient::new_user().await;
|
||||
let workspace_id_1 = client_1.workspace_id().await;
|
||||
let object_id_1 = client_1
|
||||
.create_and_edit_collab(&workspace_id_1, collab_type.clone())
|
||||
.create_and_edit_collab(&workspace_id_1, collab_type)
|
||||
.await;
|
||||
client_1
|
||||
.open_collab(&workspace_id_1, &object_id_1, collab_type.clone())
|
||||
.open_collab(&workspace_id_1, &object_id_1, collab_type)
|
||||
.await;
|
||||
|
||||
let mut client_2 = TestClient::new_user().await;
|
||||
let workspace_id_2 = client_2.workspace_id().await;
|
||||
let object_id_2 = client_2
|
||||
.create_and_edit_collab(&workspace_id_2, collab_type.clone())
|
||||
.create_and_edit_collab(&workspace_id_2, collab_type)
|
||||
.await;
|
||||
client_2
|
||||
.open_collab(&workspace_id_2, &object_id_2, collab_type.clone())
|
||||
.open_collab(&workspace_id_2, &object_id_2, collab_type)
|
||||
.await;
|
||||
|
||||
client_1
|
||||
|
@ -402,7 +402,7 @@ async fn multiple_collab_edit_test() {
|
|||
&workspace_id_1,
|
||||
&mut client_1.api_client,
|
||||
&object_id_1,
|
||||
&collab_type,
|
||||
collab_type,
|
||||
10,
|
||||
json!( {
|
||||
"title": "I am client 1"
|
||||
|
@ -415,7 +415,7 @@ async fn multiple_collab_edit_test() {
|
|||
&workspace_id_2,
|
||||
&mut client_2.api_client,
|
||||
&object_id_2,
|
||||
&collab_type,
|
||||
collab_type,
|
||||
10,
|
||||
json!( {
|
||||
"title": "I am client 2"
|
||||
|
@ -436,7 +436,7 @@ async fn simulate_multiple_user_edit_collab_test() {
|
|||
let object_id = Uuid::new_v4().to_string();
|
||||
|
||||
new_user
|
||||
.open_collab(&workspace_id, &object_id, collab_type.clone())
|
||||
.open_collab(&workspace_id, &object_id, collab_type)
|
||||
.await;
|
||||
|
||||
let random_str = generate_random_string(200);
|
||||
|
@ -510,7 +510,7 @@ async fn post_realtime_message_test() {
|
|||
&workspace_id,
|
||||
&mut client.api_client,
|
||||
&object_id,
|
||||
&CollabType::Document,
|
||||
CollabType::Document,
|
||||
10,
|
||||
json!({
|
||||
"text": big_text
|
||||
|
@ -630,7 +630,7 @@ async fn offline_and_then_sync_through_http_request() {
|
|||
&workspace_id,
|
||||
&mut test_client.api_client,
|
||||
&object_id,
|
||||
&CollabType::Unknown,
|
||||
CollabType::Unknown,
|
||||
10,
|
||||
json!({"1":""}),
|
||||
)
|
||||
|
@ -667,7 +667,7 @@ async fn offline_and_then_sync_through_http_request() {
|
|||
&workspace_id,
|
||||
&mut test_client.api_client,
|
||||
&object_id,
|
||||
&CollabType::Unknown,
|
||||
CollabType::Unknown,
|
||||
10,
|
||||
json!({"1": small_text.clone()}),
|
||||
)
|
||||
|
@ -704,7 +704,7 @@ async fn offline_and_then_sync_through_http_request() {
|
|||
&workspace_id,
|
||||
&mut test_client.api_client,
|
||||
&object_id,
|
||||
&CollabType::Unknown,
|
||||
CollabType::Unknown,
|
||||
10,
|
||||
json!({"1": small_text, "2": medium_text}),
|
||||
)
|
||||
|
@ -762,7 +762,7 @@ async fn insert_text_through_http_post_request() {
|
|||
&workspace_id,
|
||||
&mut test_client.api_client,
|
||||
&object_id,
|
||||
&CollabType::Unknown,
|
||||
CollabType::Unknown,
|
||||
10,
|
||||
json!(final_text),
|
||||
)
|
||||
|
|
|
@ -20,7 +20,7 @@ async fn read_write_snapshot() {
|
|||
&wid,
|
||||
&mut c.api_client,
|
||||
&oid,
|
||||
&CollabType::Unknown,
|
||||
CollabType::Unknown,
|
||||
10,
|
||||
json!({"title": "t1"}),
|
||||
)
|
||||
|
@ -38,7 +38,7 @@ async fn read_write_snapshot() {
|
|||
&wid,
|
||||
&mut c.api_client,
|
||||
&oid,
|
||||
&CollabType::Unknown,
|
||||
CollabType::Unknown,
|
||||
10,
|
||||
json!({"title": "t2"}),
|
||||
)
|
||||
|
|
|
@ -71,7 +71,7 @@ async fn success_batch_get_collab_test() {
|
|||
let encode_collab = test_encode_collab_v1(&object_id, "title", "hello world")
|
||||
.encode_to_bytes()
|
||||
.unwrap();
|
||||
let collab_type = query.collab_type.clone();
|
||||
let collab_type = query.collab_type;
|
||||
|
||||
expected_results.insert(
|
||||
object_id.clone(),
|
||||
|
@ -83,7 +83,7 @@ async fn success_batch_get_collab_test() {
|
|||
c.create_collab(CreateCollabParams {
|
||||
object_id: object_id.clone(),
|
||||
encoded_collab_v1: encode_collab.clone(),
|
||||
collab_type: collab_type.clone(),
|
||||
collab_type,
|
||||
workspace_id: workspace_id.clone(),
|
||||
})
|
||||
.await
|
||||
|
@ -118,7 +118,7 @@ async fn success_part_batch_get_collab_test() {
|
|||
let mut expected_results = HashMap::new();
|
||||
for (index, query) in queries.iter().enumerate() {
|
||||
let object_id = query.object_id.clone();
|
||||
let collab_type = query.collab_type.clone();
|
||||
let collab_type = query.collab_type;
|
||||
let encode_collab = test_encode_collab_v1(&object_id, "title", "hello world")
|
||||
.encode_to_bytes()
|
||||
.unwrap();
|
||||
|
@ -140,7 +140,7 @@ async fn success_part_batch_get_collab_test() {
|
|||
c.create_collab(CreateCollabParams {
|
||||
object_id: object_id.clone(),
|
||||
encoded_collab_v1: encode_collab.clone(),
|
||||
collab_type: collab_type.clone(),
|
||||
collab_type,
|
||||
workspace_id: workspace_id.clone(),
|
||||
})
|
||||
.await
|
||||
|
@ -381,7 +381,7 @@ async fn insert_invalid_data_test() {
|
|||
workspace_id: workspace_id.clone(),
|
||||
object_id: object_id.clone(),
|
||||
encoded_collab_v1: encoded_collab_v1.clone(),
|
||||
collab_type: collab_type.clone(),
|
||||
collab_type,
|
||||
};
|
||||
let error = test_client
|
||||
.api_client
|
||||
|
|
|
@ -69,7 +69,7 @@ async fn stress_test_run_multiple_text_edits() {
|
|||
&workspace_id,
|
||||
&mut reader.api_client,
|
||||
&object_id,
|
||||
&CollabType::Unknown,
|
||||
CollabType::Unknown,
|
||||
10,
|
||||
json!({
|
||||
"text-id": &expected,
|
||||
|
|
|
@ -14,7 +14,7 @@ async fn web_and_native_app_edit_same_collab_test() {
|
|||
let mut app_client = TestClient::user_with_new_device(registered_user.clone()).await;
|
||||
let workspace_id = app_client.workspace_id().await;
|
||||
let object_id = app_client
|
||||
.create_and_edit_collab(&workspace_id, collab_type.clone())
|
||||
.create_and_edit_collab(&workspace_id, collab_type)
|
||||
.await;
|
||||
|
||||
// client 1 edit the collab
|
||||
|
@ -29,7 +29,7 @@ async fn web_and_native_app_edit_same_collab_test() {
|
|||
&workspace_id,
|
||||
&mut app_client.api_client,
|
||||
&object_id,
|
||||
&collab_type,
|
||||
collab_type,
|
||||
30,
|
||||
json!({
|
||||
"name": "workspace1"
|
||||
|
@ -46,7 +46,7 @@ async fn web_and_native_app_edit_same_collab_test() {
|
|||
workspace_id: workspace_id.clone(),
|
||||
inner: QueryCollab {
|
||||
object_id: object_id.clone(),
|
||||
collab_type: collab_type.clone(),
|
||||
collab_type,
|
||||
},
|
||||
})
|
||||
.await
|
||||
|
@ -70,7 +70,7 @@ async fn web_and_native_app_edit_same_collab_test() {
|
|||
doc_state: web_doc
|
||||
.transact()
|
||||
.encode_state_as_update_v1(&StateVector::default()),
|
||||
collab_type: collab_type.clone(),
|
||||
collab_type,
|
||||
},
|
||||
)
|
||||
.await
|
||||
|
@ -84,7 +84,7 @@ async fn web_and_native_app_edit_same_collab_test() {
|
|||
&workspace_id,
|
||||
&mut app_client.api_client,
|
||||
&object_id,
|
||||
&collab_type,
|
||||
collab_type,
|
||||
30,
|
||||
expected_json.clone(),
|
||||
)
|
||||
|
|
|
@ -18,16 +18,16 @@ async fn collab_history_and_snapshot_test() {
|
|||
// Using [CollabType::Unknown] for testing purposes.
|
||||
let collab_type = CollabType::Unknown;
|
||||
test_client
|
||||
.create_and_edit_collab_with_data(&object_id, &workspace_id, collab_type.clone(), None)
|
||||
.create_and_edit_collab_with_data(&object_id, &workspace_id, collab_type, None)
|
||||
.await;
|
||||
test_client
|
||||
.open_collab(&workspace_id, &object_id, collab_type.clone())
|
||||
.open_collab(&workspace_id, &object_id, collab_type)
|
||||
.await;
|
||||
|
||||
// from the beginning, there should be no snapshots
|
||||
let snapshots = test_client
|
||||
.api_client
|
||||
.get_snapshots(&workspace_id, &object_id, collab_type.clone())
|
||||
.get_snapshots(&workspace_id, &object_id, collab_type)
|
||||
.await
|
||||
.unwrap()
|
||||
.items;
|
||||
|
@ -50,7 +50,7 @@ async fn collab_history_and_snapshot_test() {
|
|||
sleep(std::time::Duration::from_secs(10)).await;
|
||||
let snapshots = test_client
|
||||
.api_client
|
||||
.get_snapshots(&workspace_id, &object_id, collab_type.clone())
|
||||
.get_snapshots(&workspace_id, &object_id, collab_type)
|
||||
.await
|
||||
.unwrap()
|
||||
.items;
|
||||
|
|
|
@ -183,15 +183,10 @@ async fn test_document_indexing_and_search() {
|
|||
document.encode_collab().unwrap()
|
||||
};
|
||||
test_client
|
||||
.create_and_edit_collab_with_data(
|
||||
&object_id,
|
||||
&workspace_id,
|
||||
collab_type.clone(),
|
||||
Some(encoded_collab),
|
||||
)
|
||||
.create_and_edit_collab_with_data(&object_id, &workspace_id, collab_type, Some(encoded_collab))
|
||||
.await;
|
||||
test_client
|
||||
.open_collab(&workspace_id, &object_id, collab_type.clone())
|
||||
.open_collab(&workspace_id, &object_id, collab_type)
|
||||
.await;
|
||||
|
||||
sleep(Duration::from_millis(2000)).await;
|
||||
|
|
|
@ -48,7 +48,7 @@ async fn insert_snapshot_test(pool: PgPool) {
|
|||
doc_state,
|
||||
doc_state_version,
|
||||
deps_snapshot_id,
|
||||
collab_type.clone(),
|
||||
collab_type,
|
||||
timestamp + 200,
|
||||
snapshots,
|
||||
pool.clone(),
|
||||
|
|
|
@ -110,7 +110,7 @@ async fn edit_workspace_with_guest_permission() {
|
|||
&workspace_id,
|
||||
&mut owner.api_client,
|
||||
&workspace_id,
|
||||
&CollabType::Folder,
|
||||
CollabType::Folder,
|
||||
30,
|
||||
json!({
|
||||
"name": "zack"
|
||||
|
|
Loading…
Add table
Reference in a new issue