| 
									
										
										
										
											2023-07-14 13:37:13 +08:00
										 |  |  | use std::sync::Arc;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-28 15:49:47 -08:00
										 |  |  | use anyhow::{anyhow, Error};
 | 
					
						
							| 
									
										
										
										
											2023-12-29 13:02:27 +08:00
										 |  |  | use collab::core::collab::CollabDocState;
 | 
					
						
							|  |  |  | use collab_entity::CollabType;
 | 
					
						
							| 
									
										
										
										
											2023-08-17 23:46:39 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-29 09:46:24 +08:00
										 |  |  | use flowy_folder_deps::cloud::{
 | 
					
						
							| 
									
										
										
										
											2023-12-29 13:02:27 +08:00
										 |  |  |   gen_workspace_id, FolderCloudService, FolderCollabParams, FolderData, FolderSnapshot, Workspace,
 | 
					
						
							|  |  |  |   WorkspaceRecord,
 | 
					
						
							| 
									
										
										
										
											2023-07-29 09:46:24 +08:00
										 |  |  | };
 | 
					
						
							| 
									
										
										
										
											2023-05-23 23:55:21 +08:00
										 |  |  | use lib_infra::future::FutureResult;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-14 13:37:13 +08:00
										 |  |  | use crate::local_server::LocalServerDB;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | pub(crate) struct LocalServerFolderCloudServiceImpl {
 | 
					
						
							| 
									
										
										
										
											2023-11-05 14:00:24 +08:00
										 |  |  |   #[allow(dead_code)]
 | 
					
						
							| 
									
										
										
										
											2023-07-14 13:37:13 +08:00
										 |  |  |   pub db: Arc<dyn LocalServerDB>,
 | 
					
						
							|  |  |  | }
 | 
					
						
							| 
									
										
										
										
											2023-05-23 23:55:21 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | impl FolderCloudService for LocalServerFolderCloudServiceImpl {
 | 
					
						
							| 
									
										
										
										
											2023-11-08 21:48:17 +08:00
										 |  |  |   fn create_workspace(&self, uid: i64, name: &str) -> FutureResult<Workspace, Error> {
 | 
					
						
							| 
									
										
										
										
											2023-05-23 23:55:21 +08:00
										 |  |  |     let name = name.to_string();
 | 
					
						
							|  |  |  |     FutureResult::new(async move {
 | 
					
						
							| 
									
										
										
										
											2023-11-08 21:48:17 +08:00
										 |  |  |       Ok(Workspace::new(
 | 
					
						
							|  |  |  |         gen_workspace_id().to_string(),
 | 
					
						
							|  |  |  |         name.to_string(),
 | 
					
						
							|  |  |  |         uid,
 | 
					
						
							|  |  |  |       ))
 | 
					
						
							| 
									
										
										
										
											2023-05-23 23:55:21 +08:00
										 |  |  |     })
 | 
					
						
							|  |  |  |   }
 | 
					
						
							| 
									
										
										
										
											2023-07-05 20:57:09 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-05 14:00:24 +08:00
										 |  |  |   fn open_workspace(&self, _workspace_id: &str) -> FutureResult<(), Error> {
 | 
					
						
							|  |  |  |     FutureResult::new(async { Ok(()) })
 | 
					
						
							|  |  |  |   }
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   fn get_all_workspace(&self) -> FutureResult<Vec<WorkspaceRecord>, Error> {
 | 
					
						
							|  |  |  |     FutureResult::new(async { Ok(vec![]) })
 | 
					
						
							|  |  |  |   }
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-01 11:45:35 +08:00
										 |  |  |   fn get_folder_data(
 | 
					
						
							|  |  |  |     &self,
 | 
					
						
							|  |  |  |     _workspace_id: &str,
 | 
					
						
							|  |  |  |     _uid: &i64,
 | 
					
						
							|  |  |  |   ) -> FutureResult<Option<FolderData>, Error> {
 | 
					
						
							| 
									
										
										
										
											2023-07-14 13:37:13 +08:00
										 |  |  |     FutureResult::new(async move { Ok(None) })
 | 
					
						
							|  |  |  |   }
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-17 23:46:39 +08:00
										 |  |  |   fn get_folder_snapshots(
 | 
					
						
							| 
									
										
										
										
											2023-07-05 20:57:09 +08:00
										 |  |  |     &self,
 | 
					
						
							|  |  |  |     _workspace_id: &str,
 | 
					
						
							| 
									
										
										
										
											2023-08-17 23:46:39 +08:00
										 |  |  |     _limit: usize,
 | 
					
						
							|  |  |  |   ) -> FutureResult<Vec<FolderSnapshot>, Error> {
 | 
					
						
							|  |  |  |     FutureResult::new(async move { Ok(vec![]) })
 | 
					
						
							| 
									
										
										
										
											2023-07-05 20:57:09 +08:00
										 |  |  |   }
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-29 13:02:27 +08:00
										 |  |  |   fn get_collab_doc_state_f(
 | 
					
						
							| 
									
										
										
										
											2023-11-05 14:00:24 +08:00
										 |  |  |     &self,
 | 
					
						
							|  |  |  |     _workspace_id: &str,
 | 
					
						
							|  |  |  |     _uid: i64,
 | 
					
						
							| 
									
										
										
										
											2023-12-29 13:02:27 +08:00
										 |  |  |     _collab_type: CollabType,
 | 
					
						
							|  |  |  |     _object_id: &str,
 | 
					
						
							|  |  |  |   ) -> FutureResult<CollabDocState, Error> {
 | 
					
						
							| 
									
										
										
										
											2023-11-28 15:49:47 -08:00
										 |  |  |     FutureResult::new(async {
 | 
					
						
							|  |  |  |       Err(anyhow!(
 | 
					
						
							| 
									
										
										
										
											2023-12-29 13:02:27 +08:00
										 |  |  |         "Local server doesn't support get collab doc state from remote"
 | 
					
						
							| 
									
										
										
										
											2023-11-28 15:49:47 -08:00
										 |  |  |       ))
 | 
					
						
							|  |  |  |     })
 | 
					
						
							| 
									
										
										
										
											2023-07-14 13:37:13 +08:00
										 |  |  |   }
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-29 13:02:27 +08:00
										 |  |  |   fn batch_create_collab_object(
 | 
					
						
							|  |  |  |     &self,
 | 
					
						
							|  |  |  |     _workspace_id: &str,
 | 
					
						
							|  |  |  |     _objects: Vec<FolderCollabParams>,
 | 
					
						
							|  |  |  |   ) -> FutureResult<(), Error> {
 | 
					
						
							|  |  |  |     FutureResult::new(async { Err(anyhow!("Local server doesn't support create collab")) })
 | 
					
						
							|  |  |  |   }
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-14 13:37:13 +08:00
										 |  |  |   fn service_name(&self) -> String {
 | 
					
						
							|  |  |  |     "Local".to_string()
 | 
					
						
							| 
									
										
										
										
											2023-07-05 20:57:09 +08:00
										 |  |  |   }
 | 
					
						
							| 
									
										
										
										
											2023-05-23 23:55:21 +08:00
										 |  |  | }
 |