Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

refactor: remove server type

Nathan2dc22004a1e2
diff --git a/frontend/rust-lib/flowy-core/src/deps_resolve/cloud_service_impl.rs b/frontend/rust-lib/flowy-core/src/deps_resolve/cloud_service_impl.rs
index 56bf4e965c..35300563d7 100644
--- a/frontend/rust-lib/flowy-core/src/deps_resolve/cloud_service_impl.rs
+++ b/frontend/rust-lib/flowy-core/src/deps_resolve/cloud_service_impl.rs
@@ -192,11 +192,11 @@ impl UserCloudServiceProvider for ServerProvider {
/// to create a new [AppFlowyServer] if it doesn't exist. Once the [AuthType] is set,
/// it will be used when user open the app again.
///
- fn set_auth_type(&self, auth_type: &AuthType) {
+ fn set_server_auth_type(&self, auth_type: &AuthType) {
self.set_auth_type(*auth_type);
}
- fn get_auth_type(&self) -> AuthType {
+ fn get_server_auth_type(&self) -> AuthType {
self.get_auth_type()
}
diff --git a/frontend/rust-lib/flowy-user-pub/src/cloud.rs b/frontend/rust-lib/flowy-user-pub/src/cloud.rs
index fd283360de..dd69e4aa37 100644
--- a/frontend/rust-lib/flowy-user-pub/src/cloud.rs
+++ b/frontend/rust-lib/flowy-user-pub/src/cloud.rs
@@ -84,9 +84,9 @@ pub trait UserCloudServiceProvider: Send + Sync {
/// * `enable_sync`: A boolean indicating whether synchronization should be enabled or disabled.
fn set_enable_sync(&self, uid: i64, enable_sync: bool);
- fn set_auth_type(&self, auth_type: &AuthType);
+ fn set_server_auth_type(&self, auth_type: &AuthType);
- fn get_auth_type(&self) -> AuthType;
+ fn get_server_auth_type(&self) -> AuthType;
/// Sets the network reachability
///
diff --git a/frontend/rust-lib/flowy-user/src/event_handler.rs b/frontend/rust-lib/flowy-user/src/event_handler.rs
index a20229b6d0..7a64c20e06 100644
--- a/frontend/rust-lib/flowy-user/src/event_handler.rs
+++ b/frontend/rust-lib/flowy-user/src/event_handler.rs
@@ -45,14 +45,16 @@ pub async fn sign_in_with_email_password_handler(
let manager = upgrade_manager(manager)?;
let params: SignInParams = data.into_inner().try_into()?;
- let old_authenticator = manager.cloud_services.get_auth_type();
+ let old_authenticator = manager.cloud_services.get_server_auth_type();
match manager
.sign_in_with_password(&params.email, &params.password)
.await
{
Ok(token) => data_result_ok(token.into()),
Err(err) => {
- manager.cloud_services.set_auth_type(&old_authenticator);
+ manager
+ .cloud_services
+ .set_server_auth_type(&old_authenticator);
return Err(err);
},
}
@@ -76,11 +78,11 @@ pub async fn sign_up(
let params: SignUpParams = data.into_inner().try_into()?;
let auth_type = params.auth_type;
- let prev_auth_type = manager.cloud_services.get_auth_type();
+ let prev_auth_type = manager.cloud_services.get_server_auth_type();
match manager.sign_up(auth_type, BoxAny::new(params)).await {
Ok(profile) => data_result_ok(UserProfilePB::from(profile)),
Err(err) => {
- manager.cloud_services.set_auth_type(&prev_auth_type);
+ manager.cloud_services.set_server_auth_type(&prev_auth_type);
Err(err)
},
}
diff --git a/frontend/rust-lib/flowy-user/src/user_manager/manager.rs b/frontend/rust-lib/flowy-user/src/user_manager/manager.rs
index 89a05539b6..8fb4009991 100644
--- a/frontend/rust-lib/flowy-user/src/user_manager/manager.rs
+++ b/frontend/rust-lib/flowy-user/src/user_manager/manager.rs
@@ -351,7 +351,7 @@ impl UserManager {
params: SignInParams,
authenticator: AuthType,
) -> Result<UserProfile, FlowyError> {
- self.cloud_services.set_auth_type(&authenticator);
+ self.cloud_services.set_server_auth_type(&authenticator);
let response: AuthResponse = self
.cloud_services
@@ -403,7 +403,7 @@ impl UserManager {
) -> Result<UserProfile, FlowyError> {
// sign out the current user if there is one
let migration_user = self.get_migration_user(&auth_type).await;
- self.cloud_services.set_auth_type(&auth_type);
+ self.cloud_services.set_server_auth_type(&auth_type);
let auth_service = self.cloud_services.get_user_service()?;
let response: AuthResponse = auth_service.sign_up(params).await?;
let new_user_profile = UserProfile::from((&response, &auth_type));
@@ -712,7 +712,7 @@ impl UserManager {
authenticator: &AuthType,
email: &str,
) -> Result<String, FlowyError> {
- self.cloud_services.set_auth_type(authenticator);
+ self.cloud_services.set_server_auth_type(authenticator);
let auth_service = self.cloud_services.get_user_service()?;
let url = auth_service.generate_sign_in_url_with_email(email).await?;
@@ -724,7 +724,9 @@ impl UserManager {
email: &str,
password: &str,
) -> Result<GotrueTokenResponse, FlowyError> {
- self.cloud_services.set_auth_type(&AuthType::AppFlowyCloud);
+ self
+ .cloud_services
+ .set_server_auth_type(&AuthType::AppFlowyCloud);
let auth_service = self.cloud_services.get_user_service()?;
let response = auth_service.sign_in_with_password(email, password).await?;
Ok(response)
@@ -735,7 +737,9 @@ impl UserManager {
email: &str,
redirect_to: &str,
) -> Result<(), FlowyError> {
- self.cloud_services.set_auth_type(&AuthType::AppFlowyCloud);
+ self
+ .cloud_services
+ .set_server_auth_type(&AuthType::AppFlowyCloud);
let auth_service = self.cloud_services.get_user_service()?;
auth_service
.sign_in_with_magic_link(email, redirect_to)
@@ -748,7 +752,9 @@ impl UserManager {
email: &str,
passcode: &str,
) -> Result<GotrueTokenResponse, FlowyError> {
- self.cloud_services.set_auth_type(&AuthType::AppFlowyCloud);
+ self
+ .cloud_services
+ .set_server_auth_type(&AuthType::AppFlowyCloud);
let auth_service = self.cloud_services.get_user_service()?;
let response = auth_service.sign_in_with_passcode(email, passcode).await?;
Ok(response)
@@ -758,7 +764,9 @@ impl UserManager {
&self,
oauth_provider: &str,
) -> Result<String, FlowyError> {
- self.cloud_services.set_auth_type(&AuthType::AppFlowyCloud);
+ self
+ .cloud_services
+ .set_server_auth_type(&AuthType::AppFlowyCloud);
let auth_service = self.cloud_services.get_user_service()?;
let url = auth_service
.generate_oauth_url_with_provider(oauth_provider)