mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: supabase sync (#4243)
* chore: fix supabse sync * chore: bump collab * chore: fmt * chore: remove unused key
This commit is contained in:
parent
d2ccec79e4
commit
206ccb2c43
18
frontend/appflowy_tauri/src-tauri/Cargo.lock
generated
18
frontend/appflowy_tauri/src-tauri/Cargo.lock
generated
@ -883,7 +883,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "collab"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=bdc26b9a37399c9bc02e2309c54e31c664a9574d#bdc26b9a37399c9bc02e2309c54e31c664a9574d"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=e7d77a4b233886c4e9b7e03934c03d3e4489ec86#e7d77a4b233886c4e9b7e03934c03d3e4489ec86"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
@ -902,7 +902,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "collab-database"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=bdc26b9a37399c9bc02e2309c54e31c664a9574d#bdc26b9a37399c9bc02e2309c54e31c664a9574d"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=e7d77a4b233886c4e9b7e03934c03d3e4489ec86#e7d77a4b233886c4e9b7e03934c03d3e4489ec86"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
@ -932,7 +932,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "collab-derive"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=bdc26b9a37399c9bc02e2309c54e31c664a9574d#bdc26b9a37399c9bc02e2309c54e31c664a9574d"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=e7d77a4b233886c4e9b7e03934c03d3e4489ec86#e7d77a4b233886c4e9b7e03934c03d3e4489ec86"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@ -944,7 +944,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "collab-document"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=bdc26b9a37399c9bc02e2309c54e31c664a9574d#bdc26b9a37399c9bc02e2309c54e31c664a9574d"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=e7d77a4b233886c4e9b7e03934c03d3e4489ec86#e7d77a4b233886c4e9b7e03934c03d3e4489ec86"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"collab",
|
||||
@ -963,7 +963,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "collab-entity"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=bdc26b9a37399c9bc02e2309c54e31c664a9574d#bdc26b9a37399c9bc02e2309c54e31c664a9574d"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=e7d77a4b233886c4e9b7e03934c03d3e4489ec86#e7d77a4b233886c4e9b7e03934c03d3e4489ec86"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bytes",
|
||||
@ -977,7 +977,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "collab-folder"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=bdc26b9a37399c9bc02e2309c54e31c664a9574d#bdc26b9a37399c9bc02e2309c54e31c664a9574d"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=e7d77a4b233886c4e9b7e03934c03d3e4489ec86#e7d77a4b233886c4e9b7e03934c03d3e4489ec86"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"chrono",
|
||||
@ -1019,7 +1019,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "collab-persistence"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=bdc26b9a37399c9bc02e2309c54e31c664a9574d#bdc26b9a37399c9bc02e2309c54e31c664a9574d"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=e7d77a4b233886c4e9b7e03934c03d3e4489ec86#e7d77a4b233886c4e9b7e03934c03d3e4489ec86"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
@ -1040,7 +1040,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "collab-plugins"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=bdc26b9a37399c9bc02e2309c54e31c664a9574d#bdc26b9a37399c9bc02e2309c54e31c664a9574d"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=e7d77a4b233886c4e9b7e03934c03d3e4489ec86#e7d77a4b233886c4e9b7e03934c03d3e4489ec86"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
@ -1066,7 +1066,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "collab-user"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=bdc26b9a37399c9bc02e2309c54e31c664a9574d#bdc26b9a37399c9bc02e2309c54e31c664a9574d"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=e7d77a4b233886c4e9b7e03934c03d3e4489ec86#e7d77a4b233886c4e9b7e03934c03d3e4489ec86"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"collab",
|
||||
|
@ -67,14 +67,14 @@ client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "a45
|
||||
# To switch to the local path, run:
|
||||
# scripts/tool/update_collab_source.sh
|
||||
# ⚠️⚠️⚠️️
|
||||
collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "bdc26b9a37399c9bc02e2309c54e31c664a9574d" }
|
||||
collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "bdc26b9a37399c9bc02e2309c54e31c664a9574d" }
|
||||
collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "bdc26b9a37399c9bc02e2309c54e31c664a9574d" }
|
||||
collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "bdc26b9a37399c9bc02e2309c54e31c664a9574d" }
|
||||
collab-plugins = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "bdc26b9a37399c9bc02e2309c54e31c664a9574d" }
|
||||
collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "bdc26b9a37399c9bc02e2309c54e31c664a9574d" }
|
||||
collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "bdc26b9a37399c9bc02e2309c54e31c664a9574d" }
|
||||
collab-persistence = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "bdc26b9a37399c9bc02e2309c54e31c664a9574d" }
|
||||
collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "e7d77a4b233886c4e9b7e03934c03d3e4489ec86" }
|
||||
collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "e7d77a4b233886c4e9b7e03934c03d3e4489ec86" }
|
||||
collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "e7d77a4b233886c4e9b7e03934c03d3e4489ec86" }
|
||||
collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "e7d77a4b233886c4e9b7e03934c03d3e4489ec86" }
|
||||
collab-plugins = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "e7d77a4b233886c4e9b7e03934c03d3e4489ec86" }
|
||||
collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "e7d77a4b233886c4e9b7e03934c03d3e4489ec86" }
|
||||
collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "e7d77a4b233886c4e9b7e03934c03d3e4489ec86" }
|
||||
collab-persistence = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "e7d77a4b233886c4e9b7e03934c03d3e4489ec86" }
|
||||
|
||||
|
||||
|
||||
|
18
frontend/rust-lib/Cargo.lock
generated
18
frontend/rust-lib/Cargo.lock
generated
@ -733,7 +733,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "collab"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=bdc26b9a37399c9bc02e2309c54e31c664a9574d#bdc26b9a37399c9bc02e2309c54e31c664a9574d"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=e7d77a4b233886c4e9b7e03934c03d3e4489ec86#e7d77a4b233886c4e9b7e03934c03d3e4489ec86"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
@ -752,7 +752,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "collab-database"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=bdc26b9a37399c9bc02e2309c54e31c664a9574d#bdc26b9a37399c9bc02e2309c54e31c664a9574d"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=e7d77a4b233886c4e9b7e03934c03d3e4489ec86#e7d77a4b233886c4e9b7e03934c03d3e4489ec86"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
@ -782,7 +782,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "collab-derive"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=bdc26b9a37399c9bc02e2309c54e31c664a9574d#bdc26b9a37399c9bc02e2309c54e31c664a9574d"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=e7d77a4b233886c4e9b7e03934c03d3e4489ec86#e7d77a4b233886c4e9b7e03934c03d3e4489ec86"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@ -794,7 +794,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "collab-document"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=bdc26b9a37399c9bc02e2309c54e31c664a9574d#bdc26b9a37399c9bc02e2309c54e31c664a9574d"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=e7d77a4b233886c4e9b7e03934c03d3e4489ec86#e7d77a4b233886c4e9b7e03934c03d3e4489ec86"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"collab",
|
||||
@ -813,7 +813,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "collab-entity"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=bdc26b9a37399c9bc02e2309c54e31c664a9574d#bdc26b9a37399c9bc02e2309c54e31c664a9574d"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=e7d77a4b233886c4e9b7e03934c03d3e4489ec86#e7d77a4b233886c4e9b7e03934c03d3e4489ec86"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bytes",
|
||||
@ -827,7 +827,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "collab-folder"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=bdc26b9a37399c9bc02e2309c54e31c664a9574d#bdc26b9a37399c9bc02e2309c54e31c664a9574d"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=e7d77a4b233886c4e9b7e03934c03d3e4489ec86#e7d77a4b233886c4e9b7e03934c03d3e4489ec86"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"chrono",
|
||||
@ -869,7 +869,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "collab-persistence"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=bdc26b9a37399c9bc02e2309c54e31c664a9574d#bdc26b9a37399c9bc02e2309c54e31c664a9574d"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=e7d77a4b233886c4e9b7e03934c03d3e4489ec86#e7d77a4b233886c4e9b7e03934c03d3e4489ec86"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
@ -890,7 +890,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "collab-plugins"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=bdc26b9a37399c9bc02e2309c54e31c664a9574d#bdc26b9a37399c9bc02e2309c54e31c664a9574d"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=e7d77a4b233886c4e9b7e03934c03d3e4489ec86#e7d77a4b233886c4e9b7e03934c03d3e4489ec86"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
@ -916,7 +916,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "collab-user"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=bdc26b9a37399c9bc02e2309c54e31c664a9574d#bdc26b9a37399c9bc02e2309c54e31c664a9574d"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=e7d77a4b233886c4e9b7e03934c03d3e4489ec86#e7d77a4b233886c4e9b7e03934c03d3e4489ec86"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"collab",
|
||||
|
@ -109,11 +109,11 @@ client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "a45
|
||||
# To switch to the local path, run:
|
||||
# scripts/tool/update_collab_source.sh
|
||||
# ⚠️⚠️⚠️️
|
||||
collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "bdc26b9a37399c9bc02e2309c54e31c664a9574d" }
|
||||
collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "bdc26b9a37399c9bc02e2309c54e31c664a9574d" }
|
||||
collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "bdc26b9a37399c9bc02e2309c54e31c664a9574d" }
|
||||
collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "bdc26b9a37399c9bc02e2309c54e31c664a9574d" }
|
||||
collab-plugins = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "bdc26b9a37399c9bc02e2309c54e31c664a9574d" }
|
||||
collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "bdc26b9a37399c9bc02e2309c54e31c664a9574d" }
|
||||
collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "bdc26b9a37399c9bc02e2309c54e31c664a9574d" }
|
||||
collab-persistence = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "bdc26b9a37399c9bc02e2309c54e31c664a9574d" }
|
||||
collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "e7d77a4b233886c4e9b7e03934c03d3e4489ec86" }
|
||||
collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "e7d77a4b233886c4e9b7e03934c03d3e4489ec86" }
|
||||
collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "e7d77a4b233886c4e9b7e03934c03d3e4489ec86" }
|
||||
collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "e7d77a4b233886c4e9b7e03934c03d3e4489ec86" }
|
||||
collab-plugins = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "e7d77a4b233886c4e9b7e03934c03d3e4489ec86" }
|
||||
collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "e7d77a4b233886c4e9b7e03934c03d3e4489ec86" }
|
||||
collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "e7d77a4b233886c4e9b7e03934c03d3e4489ec86" }
|
||||
collab-persistence = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "e7d77a4b233886c4e9b7e03934c03d3e4489ec86" }
|
||||
|
@ -28,8 +28,15 @@ impl AppFlowyDartConfiguration {
|
||||
|
||||
pub fn write_env(&self) {
|
||||
self.authenticator_type.write_env();
|
||||
self.appflowy_cloud_config.write_env();
|
||||
self.supabase_config.write_env();
|
||||
match self.authenticator_type {
|
||||
AuthenticatorType::AppFlowyCloud => {
|
||||
self.appflowy_cloud_config.write_env();
|
||||
},
|
||||
AuthenticatorType::Supabase => {
|
||||
self.supabase_config.write_env();
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
|
||||
for (k, v) in self.envs.iter() {
|
||||
std::env::set_var(k, v);
|
||||
|
@ -190,16 +190,21 @@ impl EventIntegrationTest {
|
||||
Ok(user_profile)
|
||||
}
|
||||
|
||||
pub async fn import_appflowy_data(&self, path: String, name: &str) {
|
||||
pub async fn import_appflowy_data(&self, path: String, name: &str) -> Result<(), FlowyError> {
|
||||
let payload = ImportAppFlowyDataPB {
|
||||
path,
|
||||
import_container_name: name.to_string(),
|
||||
};
|
||||
EventBuilder::new(self.clone())
|
||||
match EventBuilder::new(self.clone())
|
||||
.event(FolderEvent::ImportAppFlowyDataFolder)
|
||||
.payload(payload)
|
||||
.async_send()
|
||||
.await;
|
||||
.await
|
||||
.error()
|
||||
{
|
||||
Some(err) => Err(err),
|
||||
None => Ok(()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,9 @@ use collab_entity::CollabType;
|
||||
use event_integration::user_event::user_localhost_af_cloud;
|
||||
use event_integration::{document_data_from_document_doc_state, EventIntegrationTest};
|
||||
use flowy_core::DEFAULT_NAME;
|
||||
use flowy_user::errors::ErrorCode;
|
||||
use serde_json::{json, Value};
|
||||
use std::env::temp_dir;
|
||||
|
||||
#[tokio::test]
|
||||
async fn import_appflowy_data_folder_test() {
|
||||
@ -29,7 +31,8 @@ async fn import_appflowy_data_folder_test() {
|
||||
user_db_path.to_str().unwrap().to_string(),
|
||||
&import_container_name,
|
||||
)
|
||||
.await;
|
||||
.await
|
||||
.unwrap();
|
||||
// after import, the structure is:
|
||||
// workspace:
|
||||
// view: Getting Started
|
||||
@ -74,7 +77,8 @@ async fn import_appflowy_data_folder_test2() {
|
||||
user_db_path.to_str().unwrap().to_string(),
|
||||
&import_container_name,
|
||||
)
|
||||
.await;
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let views = test.get_all_workspace_views().await;
|
||||
assert_eq!(views.len(), 2);
|
||||
@ -84,6 +88,19 @@ async fn import_appflowy_data_folder_test2() {
|
||||
drop(cleaner);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn import_empty_appflowy_data_folder_test() {
|
||||
let path = temp_dir();
|
||||
user_localhost_af_cloud().await;
|
||||
let test = EventIntegrationTest::new_with_name(DEFAULT_NAME).await;
|
||||
let _ = test.af_cloud_sign_up().await;
|
||||
let error = test
|
||||
.import_appflowy_data(path.to_str().unwrap().to_string(), "empty_folder")
|
||||
.await
|
||||
.unwrap_err();
|
||||
assert_eq!(error.code, ErrorCode::AppFlowyDataFolderImportError);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn import_appflowy_data_folder_multiple_times_test() {
|
||||
let import_container_name = "040_local_2".to_string();
|
||||
@ -106,7 +123,8 @@ async fn import_appflowy_data_folder_multiple_times_test() {
|
||||
user_db_path.to_str().unwrap().to_string(),
|
||||
&import_container_name,
|
||||
)
|
||||
.await;
|
||||
.await
|
||||
.unwrap();
|
||||
// after import, the structure is:
|
||||
// Getting Started
|
||||
// 040_local_2
|
||||
@ -121,7 +139,8 @@ async fn import_appflowy_data_folder_multiple_times_test() {
|
||||
user_db_path.to_str().unwrap().to_string(),
|
||||
&import_container_name,
|
||||
)
|
||||
.await;
|
||||
.await
|
||||
.unwrap();
|
||||
// after import, the structure is:
|
||||
// Getting Started
|
||||
// 040_local_2
|
@ -1,4 +1,4 @@
|
||||
mod anon_user_test;
|
||||
mod auth_test;
|
||||
mod import_af_data_folder_test;
|
||||
mod member_test;
|
||||
mod sync_third_party_data_test;
|
||||
|
@ -12,13 +12,12 @@ use flowy_server::supabase::SupabaseServer;
|
||||
use flowy_server::{AppFlowyEncryption, AppFlowyServer, EncryptionImpl};
|
||||
use flowy_server_config::af_cloud_config::AFCloudConfiguration;
|
||||
use flowy_server_config::supabase_config::SupabaseConfiguration;
|
||||
use flowy_server_config::AuthenticatorType;
|
||||
use flowy_sqlite::kv::StorePreferences;
|
||||
use flowy_user_deps::entities::*;
|
||||
|
||||
use crate::AppFlowyCoreConfig;
|
||||
|
||||
pub(crate) const SERVER_PROVIDER_TYPE_KEY: &str = "server_provider_type";
|
||||
|
||||
#[derive(Debug, Clone, Hash, Eq, PartialEq, Serialize_repr, Deserialize_repr)]
|
||||
#[repr(u8)]
|
||||
pub enum Server {
|
||||
@ -53,6 +52,7 @@ pub struct ServerProvider {
|
||||
server: RwLock<Server>,
|
||||
providers: RwLock<HashMap<Server, Arc<dyn AppFlowyServer>>>,
|
||||
pub(crate) encryption: RwLock<Arc<dyn AppFlowyEncryption>>,
|
||||
#[allow(dead_code)]
|
||||
pub(crate) store_preferences: Weak<StorePreferences>,
|
||||
pub(crate) enable_sync: RwLock<bool>,
|
||||
pub(crate) uid: Arc<RwLock<Option<i64>>>,
|
||||
@ -166,10 +166,12 @@ impl From<&Authenticator> for Server {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn current_server_type(store_preferences: &Arc<StorePreferences>) -> Server {
|
||||
store_preferences
|
||||
.get_object::<Server>(SERVER_PROVIDER_TYPE_KEY)
|
||||
.unwrap_or(Server::Local)
|
||||
pub fn current_server_type() -> Server {
|
||||
match AuthenticatorType::from_env() {
|
||||
AuthenticatorType::Local => Server::Local,
|
||||
AuthenticatorType::Supabase => Server::Supabase,
|
||||
AuthenticatorType::AppFlowyCloud => Server::AppFlowyCloud,
|
||||
}
|
||||
}
|
||||
|
||||
struct LocalServerDBImpl {
|
||||
|
@ -28,7 +28,7 @@ use flowy_user_deps::cloud::{UserCloudService, UserCloudServiceProvider};
|
||||
use flowy_user_deps::entities::{Authenticator, UserTokenState};
|
||||
use lib_infra::future::{to_fut, Fut, FutureResult};
|
||||
|
||||
use crate::integrate::server::{Server, ServerProvider, SERVER_PROVIDER_TYPE_KEY};
|
||||
use crate::integrate::server::{Server, ServerProvider};
|
||||
|
||||
impl FileStorageService for ServerProvider {
|
||||
fn create_object(&self, object: StorageObject) -> FutureResult<String, FlowyError> {
|
||||
@ -96,18 +96,6 @@ impl UserCloudServiceProvider for ServerProvider {
|
||||
fn set_authenticator(&self, authenticator: Authenticator) {
|
||||
let server_type: Server = authenticator.into();
|
||||
self.set_server_type(server_type.clone());
|
||||
|
||||
match self.store_preferences.upgrade() {
|
||||
None => tracing::error!("🔴Failed to update server provider type: store preferences is drop"),
|
||||
Some(store_preferences) => {
|
||||
match store_preferences.set_object(SERVER_PROVIDER_TYPE_KEY, server_type.clone()) {
|
||||
Ok(_) => tracing::trace!("Set server provider: {:?}", server_type),
|
||||
Err(e) => {
|
||||
tracing::error!("🔴Failed to update server provider type: {:?}", e);
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
fn get_authenticator(&self) -> Authenticator {
|
||||
|
@ -14,7 +14,7 @@ use flowy_user_deps::cloud::{UserCloudConfig, UserCloudServiceProvider};
|
||||
use flowy_user_deps::entities::{Authenticator, UserProfile, UserWorkspace};
|
||||
use lib_infra::future::{to_fut, Fut};
|
||||
|
||||
use crate::integrate::server::ServerProvider;
|
||||
use crate::integrate::server::{Server, ServerProvider};
|
||||
use crate::AppFlowyCoreConfig;
|
||||
|
||||
pub(crate) struct UserStatusCallbackImpl {
|
||||
@ -131,6 +131,7 @@ impl UserStatusCallback for UserStatusCallbackImpl {
|
||||
let database_manager = self.database_manager.clone();
|
||||
let user_workspace = user_workspace.clone();
|
||||
let document_manager = self.document_manager.clone();
|
||||
let server_type = self.server_provider.get_server_type();
|
||||
|
||||
to_fut(async move {
|
||||
event!(
|
||||
@ -155,7 +156,21 @@ impl UserStatusCallback for UserStatusCallbackImpl {
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(doc_state) => FolderInitDataSource::Cloud(doc_state),
|
||||
Ok(doc_state) => match server_type {
|
||||
Server::Local => FolderInitDataSource::LocalDisk {
|
||||
create_if_not_exist: true,
|
||||
},
|
||||
Server::AppFlowyCloud => FolderInitDataSource::Cloud(doc_state),
|
||||
Server::Supabase => {
|
||||
if is_new_user {
|
||||
FolderInitDataSource::LocalDisk {
|
||||
create_if_not_exist: true,
|
||||
}
|
||||
} else {
|
||||
FolderInitDataSource::Cloud(doc_state)
|
||||
}
|
||||
},
|
||||
},
|
||||
Err(_) => FolderInitDataSource::LocalDisk {
|
||||
create_if_not_exist: true,
|
||||
},
|
||||
|
@ -96,7 +96,7 @@ impl AppFlowyCore {
|
||||
let task_dispatcher = Arc::new(RwLock::new(task_scheduler));
|
||||
runtime.spawn(TaskRunner::run(task_dispatcher.clone()));
|
||||
|
||||
let server_type = current_server_type(&store_preference);
|
||||
let server_type = current_server_type();
|
||||
debug!("🔥runtime:{}, server:{}", runtime, server_type);
|
||||
let server_provider = Arc::new(ServerProvider::new(
|
||||
config.clone(),
|
||||
|
@ -265,6 +265,9 @@ pub enum ErrorCode {
|
||||
|
||||
#[error("Local version not support")]
|
||||
LocalVersionNotSupport = 88,
|
||||
|
||||
#[error("AppFlowy data folder import error")]
|
||||
AppFlowyDataFolderImportError = 89,
|
||||
}
|
||||
|
||||
impl ErrorCode {
|
||||
|
@ -75,7 +75,7 @@ where
|
||||
.doc_state
|
||||
.to_vec();
|
||||
let folder =
|
||||
Folder::from_collab_raw_data(uid, CollabOrigin::Empty, doc_state, &workspace_id, vec![])?;
|
||||
Folder::from_collab_doc_state(uid, CollabOrigin::Empty, doc_state, &workspace_id, vec![])?;
|
||||
Ok(folder.get_folder_data())
|
||||
})
|
||||
}
|
||||
|
@ -75,9 +75,9 @@ where
|
||||
|
||||
async fn get_snapshots(&self, object_id: &str, limit: usize) -> Vec<RemoteCollabSnapshot> {
|
||||
match self.server.try_get_postgrest() {
|
||||
Ok(postgrest) => match get_snapshots_from_server(object_id, postgrest, limit).await {
|
||||
Ok(snapshots) => snapshots,
|
||||
Err(err) => {
|
||||
Ok(postgrest) => get_snapshots_from_server(object_id, postgrest, limit)
|
||||
.await
|
||||
.unwrap_or_else(|err| {
|
||||
tracing::error!(
|
||||
"🔴fetch snapshots by oid:{} with limit: {} failed: {:?}",
|
||||
object_id,
|
||||
@ -85,8 +85,7 @@ where
|
||||
err
|
||||
);
|
||||
vec![]
|
||||
},
|
||||
},
|
||||
}),
|
||||
Err(err) => {
|
||||
tracing::error!("🔴get postgrest failed: {:?}", err);
|
||||
vec![]
|
||||
|
@ -82,7 +82,7 @@ where
|
||||
fn get_document_data(
|
||||
&self,
|
||||
document_id: &str,
|
||||
workspace_id: &str,
|
||||
_workspace_id: &str,
|
||||
) -> FutureResult<Option<DocumentData>, Error> {
|
||||
let try_get_postgrest = self.server.try_get_weak_postgrest();
|
||||
let document_id = document_id.to_string();
|
||||
|
@ -99,12 +99,11 @@ where
|
||||
.iter()
|
||||
.map(|update| update.value.as_ref())
|
||||
.collect::<Vec<&[u8]>>();
|
||||
|
||||
let doc_state = merge_updates_v1(&updates)
|
||||
.map_err(|err| anyhow::anyhow!("merge updates failed: {:?}", err))?;
|
||||
|
||||
let folder =
|
||||
Folder::from_collab_raw_data(uid, CollabOrigin::Empty, doc_state, &workspace_id, vec![])?;
|
||||
Folder::from_collab_doc_state(uid, CollabOrigin::Empty, doc_state, &workspace_id, vec![])?;
|
||||
Ok(folder.get_folder_data())
|
||||
})
|
||||
}
|
||||
|
@ -73,11 +73,14 @@ impl Action for FetchObjectUpdateAction {
|
||||
Some(postgrest) => {
|
||||
match get_updates_from_server(&object_id, &object_ty, &postgrest).await {
|
||||
Ok(items) => {
|
||||
if items.is_empty() {
|
||||
return Ok(vec![]);
|
||||
}
|
||||
|
||||
let updates = items
|
||||
.iter()
|
||||
.map(|update| update.value.as_ref())
|
||||
.collect::<Vec<&[u8]>>();
|
||||
|
||||
let doc_state = merge_updates_v1(&updates)
|
||||
.map_err(|err| anyhow::anyhow!("merge updates failed: {:?}", err))?;
|
||||
Ok(doc_state)
|
||||
@ -280,15 +283,18 @@ pub async fn batch_get_updates_from_server(
|
||||
if let Some(oid) = record.get("oid").and_then(|value| value.as_str()) {
|
||||
match parser_updates_form_json(record.clone(), &postgrest.secret()) {
|
||||
Ok(items) => {
|
||||
let updates = items
|
||||
.iter()
|
||||
.map(|update| update.value.as_ref())
|
||||
.collect::<Vec<&[u8]>>();
|
||||
if items.is_empty() {
|
||||
updates_by_oid.insert(oid.to_string(), vec![]);
|
||||
} else {
|
||||
let updates = items
|
||||
.iter()
|
||||
.map(|update| update.value.as_ref())
|
||||
.collect::<Vec<&[u8]>>();
|
||||
|
||||
let doc_state = merge_updates_v1(&updates)
|
||||
.map_err(|err| anyhow::anyhow!("merge updates failed: {:?}", err))?;
|
||||
|
||||
updates_by_oid.insert(oid.to_string(), doc_state);
|
||||
let doc_state = merge_updates_v1(&updates)
|
||||
.map_err(|err| anyhow::anyhow!("merge updates failed: {:?}", err))?;
|
||||
updates_by_oid.insert(oid.to_string(), doc_state);
|
||||
}
|
||||
},
|
||||
Err(e) => {
|
||||
tracing::error!("parser_updates_form_json error: {:?}", e);
|
||||
|
@ -120,7 +120,7 @@ pub async fn print_encryption_folder_snapshot(
|
||||
.pop()
|
||||
.unwrap();
|
||||
let collab = Arc::new(
|
||||
MutexCollab::new_with_raw_data(CollabOrigin::Empty, folder_id, snapshot.blob, vec![]).unwrap(),
|
||||
MutexCollab::new_with_doc_state(CollabOrigin::Empty, folder_id, snapshot.blob, vec![]).unwrap(),
|
||||
);
|
||||
let folder_data = Folder::open(uid, collab, None)
|
||||
.unwrap()
|
||||
|
@ -297,7 +297,7 @@ where
|
||||
}
|
||||
|
||||
let origin = CollabOrigin::Client(CollabClient::new(new_uid, "phantom"));
|
||||
let new_folder_collab = Collab::new_with_raw_data(origin, new_workspace_id, vec![], vec![])
|
||||
let new_folder_collab = Collab::new_with_doc_state(origin, new_workspace_id, vec![], vec![])
|
||||
.map_err(|err| PersistenceError::Internal(err.into()))?;
|
||||
let mutex_collab = Arc::new(MutexCollab::from_collab(new_folder_collab));
|
||||
let new_user_id = UserId::from(new_uid);
|
||||
|
@ -670,7 +670,8 @@ impl UserManager {
|
||||
pub fn import_data(&self, source: ImportDataSource) -> Result<ImportData, FlowyError> {
|
||||
let session = self.get_session()?;
|
||||
let collab_db = self.database.get_collab_db(session.user_id)?;
|
||||
let import_result = import_data(&session, source, collab_db)?;
|
||||
let import_result = import_data(&session, source, collab_db)
|
||||
.map_err(|err| FlowyError::new(ErrorCode::AppFlowyDataFolderImportError, err.to_string()))?;
|
||||
Ok(import_result)
|
||||
}
|
||||
|
||||
|
@ -332,7 +332,7 @@ where
|
||||
W: YrsDocAction<'a>,
|
||||
PersistenceError: From<W::Error>,
|
||||
{
|
||||
let collab = Collab::new_with_raw_data(CollabOrigin::Empty, new_object_id, doc_state, vec![])?;
|
||||
let collab = Collab::new_with_doc_state(CollabOrigin::Empty, new_object_id, doc_state, vec![])?;
|
||||
import_collab_object(&collab, new_uid, new_object_id, w_txn);
|
||||
Ok(())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user