chore: update logs

This commit is contained in:
Nathan 2025-04-20 19:29:56 +08:00
parent 92d5690bba
commit 2ee786f351
10 changed files with 55 additions and 78 deletions

View file

@ -31,7 +31,7 @@ impl FolderOperationHandler for ChatFolderOperation {
} }
async fn duplicate_view(&self, _view_id: &Uuid) -> Result<Bytes, FlowyError> { async fn duplicate_view(&self, _view_id: &Uuid) -> Result<Bytes, FlowyError> {
Err(FlowyError::not_support()) Err(FlowyError::not_support().with_context("Duplicate view"))
} }
async fn create_view_with_view_data( async fn create_view_with_view_data(
@ -39,7 +39,7 @@ impl FolderOperationHandler for ChatFolderOperation {
_user_id: i64, _user_id: i64,
_params: CreateViewParams, _params: CreateViewParams,
) -> Result<Option<EncodedCollab>, FlowyError> { ) -> Result<Option<EncodedCollab>, FlowyError> {
Err(FlowyError::not_support()) Err(FlowyError::not_support().with_context("Can't create view"))
} }
async fn create_default_view( async fn create_default_view(
@ -65,7 +65,7 @@ impl FolderOperationHandler for ChatFolderOperation {
_import_type: ImportType, _import_type: ImportType,
_bytes: Vec<u8>, _bytes: Vec<u8>,
) -> Result<Vec<ImportedData>, FlowyError> { ) -> Result<Vec<ImportedData>, FlowyError> {
Err(FlowyError::not_support()) Err(FlowyError::not_support().with_context("import from data"))
} }
async fn import_from_file_path( async fn import_from_file_path(
@ -74,6 +74,6 @@ impl FolderOperationHandler for ChatFolderOperation {
_name: &str, _name: &str,
_path: String, _path: String,
) -> Result<(), FlowyError> { ) -> Result<(), FlowyError> {
Err(FlowyError::not_support()) Err(FlowyError::not_support().with_context("import file from path"))
} }
} }

View file

@ -198,7 +198,9 @@ impl FolderOperationHandler for DatabaseFolderOperation {
ViewLayoutPB::Calendar => DatabaseLayoutPB::Calendar, ViewLayoutPB::Calendar => DatabaseLayoutPB::Calendar,
ViewLayoutPB::Grid => DatabaseLayoutPB::Grid, ViewLayoutPB::Grid => DatabaseLayoutPB::Grid,
ViewLayoutPB::Document | ViewLayoutPB::Chat => { ViewLayoutPB::Document | ViewLayoutPB::Chat => {
return Err(FlowyError::not_support()); return Err(
FlowyError::invalid_data().with_context("Can't handle document layout type"),
);
}, },
}; };
let name = params.name.to_string(); let name = params.name.to_string();

View file

@ -53,35 +53,17 @@ impl UserStatusCallbackImpl {
workspace_id: &Uuid, workspace_id: &Uuid,
auth_type: &AuthType, auth_type: &AuthType,
) -> FlowyResult<FolderInitDataSource> { ) -> FlowyResult<FolderInitDataSource> {
let is_exist = self.is_object_exist_on_disk(user_id, workspace_id, workspace_id)?; if self.is_object_exist_on_disk(user_id, workspace_id, workspace_id)? {
if is_exist { return Ok(FolderInitDataSource::LocalDisk {
Ok(FolderInitDataSource::LocalDisk {
create_if_not_exist: false, create_if_not_exist: false,
}) });
} else {
let data_source = match self
.folder_manager
.cloud_service
.get_folder_doc_state(workspace_id, user_id, CollabType::Folder, workspace_id)
.await
{
Ok(doc_state) => match auth_type {
AuthType::Local => FolderInitDataSource::LocalDisk {
create_if_not_exist: true,
},
AuthType::AppFlowyCloud => FolderInitDataSource::Cloud(doc_state),
},
Err(err) => match auth_type {
AuthType::Local => FolderInitDataSource::LocalDisk {
create_if_not_exist: true,
},
AuthType::AppFlowyCloud => {
return Err(err);
},
},
};
Ok(data_source)
} }
let doc_state_result = self
.folder_manager
.cloud_service
.get_folder_doc_state(workspace_id, user_id, CollabType::Folder, workspace_id)
.await;
resolve_data_source(auth_type, doc_state_result)
} }
fn is_object_exist_on_disk( fn is_object_exist_on_disk(
@ -296,3 +278,23 @@ impl UserStatusCallback for UserStatusCallbackImpl {
} }
} }
} }
fn resolve_data_source(
auth_type: &AuthType,
doc_state_result: Result<Vec<u8>, FlowyError>,
) -> FlowyResult<FolderInitDataSource> {
match doc_state_result {
Ok(doc_state) => Ok(match auth_type {
AuthType::Local => FolderInitDataSource::LocalDisk {
create_if_not_exist: true,
},
AuthType::AppFlowyCloud => FolderInitDataSource::Cloud(doc_state),
}),
Err(err) => match auth_type {
AuthType::Local => Ok(FolderInitDataSource::LocalDisk {
create_if_not_exist: true,
}),
AuthType::AppFlowyCloud => Err(err),
},
}
}

View file

@ -217,10 +217,10 @@ where
chat_id: &Uuid, chat_id: &Uuid,
metadata: Option<HashMap<String, Value>>, metadata: Option<HashMap<String, Value>>,
) -> Result<(), FlowyError> { ) -> Result<(), FlowyError> {
return Err( Err(
FlowyError::not_support() FlowyError::not_support()
.with_context("indexing file with appflowy cloud is not suppotred yet"), .with_context("indexing file with appflowy cloud is not suppotred yet"),
); )
} }
async fn get_chat_settings( async fn get_chat_settings(

View file

@ -13,8 +13,8 @@ use client_api::entity::workspace_dto::{
WorkspaceMemberInvitation, WorkspaceMemberInvitation,
}; };
use client_api::entity::{ use client_api::entity::{
AFRole, AFWorkspace, AFWorkspaceInvitation, AFWorkspaceSettings, AFWorkspaceSettingsChange, AFWorkspace, AFWorkspaceInvitation, AFWorkspaceSettings, AFWorkspaceSettingsChange, AuthProvider,
AuthProvider, CollabParams, CreateCollabParams, GotrueTokenResponse, QueryWorkspaceMember, CollabParams, CreateCollabParams, GotrueTokenResponse, QueryWorkspaceMember,
}; };
use client_api::entity::{QueryCollab, QueryCollabParams}; use client_api::entity::{QueryCollab, QueryCollabParams};
use client_api::{Client, ClientConfiguration}; use client_api::{Client, ClientConfiguration};
@ -341,18 +341,6 @@ where
Ok(members) Ok(members)
} }
async fn get_workspace_member(
&self,
workspace_id: Uuid,
uid: i64,
) -> Result<WorkspaceMember, FlowyError> {
let try_get_client = self.server.try_get_client();
let client = try_get_client?;
let query = QueryWorkspaceMember { workspace_id, uid };
let member = client.get_workspace_member(query).await?;
Ok(from_af_workspace_member(member))
}
#[instrument(level = "debug", skip_all)] #[instrument(level = "debug", skip_all)]
async fn get_user_awareness_doc_state( async fn get_user_awareness_doc_state(
&self, &self,
@ -452,7 +440,7 @@ where
Ok(payment_link) Ok(payment_link)
} }
async fn get_workspace_member_info( async fn get_workspace_member(
&self, &self,
workspace_id: &Uuid, workspace_id: &Uuid,
uid: i64, uid: i64,
@ -464,17 +452,8 @@ where
uid, uid,
}; };
let member = client.get_workspace_member(params).await?; let member = client.get_workspace_member(params).await?;
let role = match member.role {
AFRole::Owner => Role::Owner, Ok(from_af_workspace_member(member))
AFRole::Member => Role::Member,
AFRole::Guest => Role::Guest,
};
Ok(WorkspaceMember {
email: member.email,
role,
name: member.name,
avatar_url: member.avatar_url,
})
} }
async fn get_workspace_subscriptions( async fn get_workspace_subscriptions(

View file

@ -8,7 +8,7 @@ use flowy_ai_pub::cloud::chat_dto::{ChatAuthor, ChatAuthorType};
use flowy_ai_pub::cloud::{ use flowy_ai_pub::cloud::{
AIModel, AppErrorCode, AppResponseError, ChatCloudService, ChatMessage, ChatMessageType, AIModel, AppErrorCode, AppResponseError, ChatCloudService, ChatMessage, ChatMessageType,
ChatSettings, CompleteTextParams, MessageCursor, ModelList, RelatedQuestion, RepeatedChatMessage, ChatSettings, CompleteTextParams, MessageCursor, ModelList, RelatedQuestion, RepeatedChatMessage,
ResponseFormat, StreamAnswer, StreamComplete, UpdateChatParams, ResponseFormat, StreamAnswer, StreamComplete, UpdateChatParams, DEFAULT_AI_MODEL_NAME,
}; };
use flowy_ai_pub::persistence::{ use flowy_ai_pub::persistence::{
deserialize_chat_metadata, deserialize_rag_ids, read_chat, deserialize_chat_metadata, deserialize_rag_ids, read_chat,
@ -313,11 +313,11 @@ impl ChatCloudService for LocalChatServiceImpl {
} }
async fn get_available_models(&self, _workspace_id: &Uuid) -> Result<ModelList, FlowyError> { async fn get_available_models(&self, _workspace_id: &Uuid) -> Result<ModelList, FlowyError> {
Err(FlowyError::not_support().with_context("Chat is not supported in local server.")) Ok(ModelList { models: vec![] })
} }
async fn get_workspace_default_model(&self, _workspace_id: &Uuid) -> Result<String, FlowyError> { async fn get_workspace_default_model(&self, _workspace_id: &Uuid) -> Result<String, FlowyError> {
Err(FlowyError::not_support().with_context("Chat is not supported in local server.")) Ok(DEFAULT_AI_MODEL_NAME.to_string())
} }
} }

View file

@ -209,7 +209,7 @@ impl UserCloudService for LocalServerUserServiceImpl {
Ok(()) Ok(())
} }
async fn get_workspace_member_info( async fn get_workspace_member(
&self, &self,
workspace_id: &Uuid, workspace_id: &Uuid,
uid: i64, uid: i64,

View file

@ -32,9 +32,11 @@ pub async fn default_encode_collab_for_collab_type(
// Ok::<_, FlowyError>(()) // Ok::<_, FlowyError>(())
// })?; // })?;
// Ok(data) // Ok(data)
Err(FlowyError::not_support()) Err(FlowyError::not_support().with_context("Can not create default folder"))
},
CollabType::DatabaseRow => {
Err(FlowyError::not_support().with_context("Can not create default database row"))
}, },
CollabType::DatabaseRow => Err(FlowyError::not_support()),
CollabType::UserAwareness => Ok(default_user_awareness_data(object_id)), CollabType::UserAwareness => Ok(default_user_awareness_data(object_id)),
CollabType::Unknown => { CollabType::Unknown => {
let collab = Collab::new_with_origin(CollabOrigin::Empty, object_id, vec![], false); let collab = Collab::new_with_origin(CollabOrigin::Empty, object_id, vec![], false);

View file

@ -132,7 +132,7 @@ pub trait UserCloudService: Send + Sync + 'static {
/// Delete an account and all the data associated with the account /// Delete an account and all the data associated with the account
async fn delete_account(&self) -> Result<(), FlowyError> { async fn delete_account(&self) -> Result<(), FlowyError> {
Err(FlowyError::not_support()) Ok(())
} }
/// Generate a sign in url for the user with the given email /// Generate a sign in url for the user with the given email
@ -234,14 +234,6 @@ pub trait UserCloudService: Send + Sync + 'static {
Ok(vec![]) Ok(vec![])
} }
async fn get_workspace_member(
&self,
workspace_id: Uuid,
uid: i64,
) -> Result<WorkspaceMember, FlowyError> {
Err(FlowyError::not_support())
}
async fn get_user_awareness_doc_state( async fn get_user_awareness_doc_state(
&self, &self,
uid: i64, uid: i64,
@ -281,7 +273,7 @@ pub trait UserCloudService: Send + Sync + 'static {
Err(FlowyError::not_support()) Err(FlowyError::not_support())
} }
async fn get_workspace_member_info( async fn get_workspace_member(
&self, &self,
workspace_id: &Uuid, workspace_id: &Uuid,
uid: i64, uid: i64,

View file

@ -377,7 +377,7 @@ impl UserManager {
let member = self let member = self
.cloud_service .cloud_service
.get_user_service()? .get_user_service()?
.get_workspace_member(workspace_id, uid) .get_workspace_member(&workspace_id, uid)
.await?; .await?;
Ok(member) Ok(member)
} }
@ -655,7 +655,7 @@ impl UserManager {
let member = self let member = self
.cloud_service .cloud_service
.get_user_service()? .get_user_service()?
.get_workspace_member_info(workspace_id, uid) .get_workspace_member(workspace_id, uid)
.await?; .await?;
let record = WorkspaceMemberTable { let record = WorkspaceMemberTable {