2023-07-14 13:37:13 +08:00
|
|
|
use std::sync::Arc;
|
|
|
|
|
|
2023-11-28 15:49:47 -08:00
|
|
|
use anyhow::{anyhow, Error};
|
2024-10-23 19:41:46 +08:00
|
|
|
use client_api::entity::workspace_dto::PublishInfoView;
|
|
|
|
|
use client_api::entity::PublishInfo;
|
2023-12-29 13:02:27 +08:00
|
|
|
use collab_entity::CollabType;
|
2023-08-17 23:46:39 +08:00
|
|
|
|
2024-08-18 05:16:42 +02:00
|
|
|
use crate::local_server::LocalServerDB;
|
2024-01-11 14:42:03 +08:00
|
|
|
use flowy_folder_pub::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
|
|
|
};
|
2024-10-23 19:41:46 +08:00
|
|
|
use flowy_folder_pub::entities::PublishPayload;
|
2024-08-18 05:16:42 +02:00
|
|
|
use lib_infra::async_trait::async_trait;
|
2023-07-14 13:37:13 +08:00
|
|
|
|
|
|
|
|
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
|
|
|
|
2024-08-18 05:16:42 +02:00
|
|
|
#[async_trait]
|
2023-05-23 23:55:21 +08:00
|
|
|
impl FolderCloudService for LocalServerFolderCloudServiceImpl {
|
2024-08-18 05:16:42 +02:00
|
|
|
async fn create_workspace(&self, uid: i64, name: &str) -> Result<Workspace, Error> {
|
2023-05-23 23:55:21 +08:00
|
|
|
let name = name.to_string();
|
2024-08-18 05:16:42 +02: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
|
|
|
|
2024-08-18 05:16:42 +02:00
|
|
|
async fn open_workspace(&self, _workspace_id: &str) -> Result<(), Error> {
|
|
|
|
|
Ok(())
|
2023-11-05 14:00:24 +08:00
|
|
|
}
|
|
|
|
|
|
2024-08-18 05:16:42 +02:00
|
|
|
async fn get_all_workspace(&self) -> Result<Vec<WorkspaceRecord>, Error> {
|
|
|
|
|
Ok(vec![])
|
2023-11-05 14:00:24 +08:00
|
|
|
}
|
|
|
|
|
|
2024-08-18 05:16:42 +02:00
|
|
|
async fn get_folder_data(
|
2023-11-01 11:45:35 +08:00
|
|
|
&self,
|
|
|
|
|
_workspace_id: &str,
|
|
|
|
|
_uid: &i64,
|
2024-08-18 05:16:42 +02:00
|
|
|
) -> Result<Option<FolderData>, Error> {
|
|
|
|
|
Ok(None)
|
2023-07-14 13:37:13 +08:00
|
|
|
}
|
|
|
|
|
|
2024-08-18 05:16:42 +02:00
|
|
|
async 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,
|
2024-08-18 05:16:42 +02:00
|
|
|
) -> Result<Vec<FolderSnapshot>, Error> {
|
|
|
|
|
Ok(vec![])
|
2023-07-05 20:57:09 +08:00
|
|
|
}
|
|
|
|
|
|
2024-08-18 05:16:42 +02:00
|
|
|
async fn get_folder_doc_state(
|
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,
|
2024-08-18 05:16:42 +02:00
|
|
|
) -> Result<Vec<u8>, Error> {
|
|
|
|
|
Err(anyhow!(
|
|
|
|
|
"Local server doesn't support get collab doc state from remote"
|
|
|
|
|
))
|
2023-07-14 13:37:13 +08:00
|
|
|
}
|
|
|
|
|
|
2024-08-18 05:16:42 +02:00
|
|
|
async fn batch_create_folder_collab_objects(
|
2023-12-29 13:02:27 +08:00
|
|
|
&self,
|
|
|
|
|
_workspace_id: &str,
|
|
|
|
|
_objects: Vec<FolderCollabParams>,
|
2024-08-18 05:16:42 +02:00
|
|
|
) -> Result<(), Error> {
|
2024-09-08 22:21:34 +08:00
|
|
|
Ok(())
|
2023-12-29 13:02:27 +08:00
|
|
|
}
|
|
|
|
|
|
2023-07-14 13:37:13 +08:00
|
|
|
fn service_name(&self) -> String {
|
|
|
|
|
"Local".to_string()
|
2023-07-05 20:57:09 +08:00
|
|
|
}
|
2024-07-08 13:45:57 +08:00
|
|
|
|
2024-08-18 05:16:42 +02:00
|
|
|
async fn publish_view(
|
2024-07-08 13:45:57 +08:00
|
|
|
&self,
|
|
|
|
|
_workspace_id: &str,
|
2024-07-22 13:35:42 +08:00
|
|
|
_payload: Vec<PublishPayload>,
|
2024-08-18 05:16:42 +02:00
|
|
|
) -> Result<(), Error> {
|
|
|
|
|
Err(anyhow!("Local server doesn't support publish view"))
|
2024-07-08 13:45:57 +08:00
|
|
|
}
|
|
|
|
|
|
2024-08-18 05:16:42 +02:00
|
|
|
async fn unpublish_views(
|
2024-07-08 13:45:57 +08:00
|
|
|
&self,
|
|
|
|
|
_workspace_id: &str,
|
|
|
|
|
_view_ids: Vec<String>,
|
2024-08-18 05:16:42 +02:00
|
|
|
) -> Result<(), Error> {
|
|
|
|
|
Err(anyhow!("Local server doesn't support unpublish views"))
|
2024-07-08 13:45:57 +08:00
|
|
|
}
|
|
|
|
|
|
2024-10-23 19:41:46 +08:00
|
|
|
async fn get_publish_info(&self, _view_id: &str) -> Result<PublishInfo, Error> {
|
2024-08-18 05:16:42 +02:00
|
|
|
Err(anyhow!(
|
|
|
|
|
"Local server doesn't support get publish info from remote"
|
|
|
|
|
))
|
2024-07-08 13:45:57 +08:00
|
|
|
}
|
|
|
|
|
|
2024-08-18 05:16:42 +02:00
|
|
|
async fn set_publish_namespace(
|
2024-07-08 13:45:57 +08:00
|
|
|
&self,
|
|
|
|
|
_workspace_id: &str,
|
|
|
|
|
_new_namespace: &str,
|
2024-08-18 05:16:42 +02:00
|
|
|
) -> Result<(), Error> {
|
|
|
|
|
Err(anyhow!(
|
|
|
|
|
"Local server doesn't support set publish namespace"
|
|
|
|
|
))
|
2024-07-08 13:45:57 +08:00
|
|
|
}
|
|
|
|
|
|
2024-08-18 05:16:42 +02:00
|
|
|
async fn get_publish_namespace(&self, _workspace_id: &str) -> Result<String, Error> {
|
|
|
|
|
Err(anyhow!(
|
|
|
|
|
"Local server doesn't support get publish namespace"
|
|
|
|
|
))
|
2024-07-08 13:45:57 +08:00
|
|
|
}
|
2024-10-14 20:38:04 +08:00
|
|
|
|
2024-10-23 19:41:46 +08:00
|
|
|
async fn list_published_views(&self, _workspace_id: &str) -> Result<Vec<PublishInfoView>, Error> {
|
|
|
|
|
Err(anyhow!("Local server doesn't support list published views"))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async fn get_default_published_view_info(
|
|
|
|
|
&self,
|
|
|
|
|
_workspace_id: &str,
|
|
|
|
|
) -> Result<PublishInfo, Error> {
|
|
|
|
|
Err(anyhow!("Local server doesn't support list published views"))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async fn set_default_published_view(
|
|
|
|
|
&self,
|
|
|
|
|
_workspace_id: &str,
|
|
|
|
|
_view_id: uuid::Uuid,
|
|
|
|
|
) -> Result<(), Error> {
|
|
|
|
|
Err(anyhow!("Local server doesn't support list published views"))
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-14 20:38:04 +08:00
|
|
|
async fn import_zip(&self, _file_path: &str) -> Result<(), Error> {
|
|
|
|
|
Err(anyhow!(
|
|
|
|
|
"Local server doesn't support get publish namespace"
|
|
|
|
|
))
|
|
|
|
|
}
|
2023-05-23 23:55:21 +08:00
|
|
|
}
|