fix: Invalid refresh token (#3879)

* chore: update client api

* chore: update client api

* chore: update client api

* chore: fix clippy

* chore: fix clippy

* ci: fix

* chore: update client api
This commit is contained in:
Nathan.fooo
2023-11-08 21:48:17 +08:00
committed by GitHub
parent afc6473582
commit 73f1c211c2
23 changed files with 332 additions and 124 deletions

View File

@ -26,8 +26,8 @@ SUPABASE_ANON_KEY=replace-with-your-supabase-key
# AppFlowy Cloud Configuration # AppFlowy Cloud Configuration
# If using AppFlowy Cloud (CLOUD_TYPE=2), provide the following details: # If using AppFlowy Cloud (CLOUD_TYPE=2), provide the following details:
APPFLOWY_CLOUD_BASE_URL=replace-with-your-appflowy-cloud-url APPFLOWY_CLOUD_BASE_URL=https://xxxxxxxxx
APPFLOWY_CLOUD_WS_BASE_URL=replace-with-your-appflowy-cloud-ws-url APPFLOWY_CLOUD_WS_BASE_URL=wss://xxxxxxxxx
APPFLOWY_CLOUD_GOTRUE_URL=replace-with-your-appflowy-cloud-gotrue-url APPFLOWY_CLOUD_GOTRUE_URL=https://xxxxxxxxx

View File

@ -138,7 +138,7 @@ checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6"
[[package]] [[package]]
name = "app-error" name = "app-error"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7752ab68a91ff742fae595c1b45babdc17927fea#7752ab68a91ff742fae595c1b45babdc17927fea" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d37fbbf486dc44336c87acd59cf8b6feff57b330#d37fbbf486dc44336c87acd59cf8b6feff57b330"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"reqwest", "reqwest",
@ -768,10 +768,11 @@ dependencies = [
[[package]] [[package]]
name = "client-api" name = "client-api"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7752ab68a91ff742fae595c1b45babdc17927fea#7752ab68a91ff742fae595c1b45babdc17927fea" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d37fbbf486dc44336c87acd59cf8b6feff57b330#d37fbbf486dc44336c87acd59cf8b6feff57b330"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"app-error", "app-error",
"async-trait",
"bytes", "bytes",
"collab", "collab",
"collab-entity", "collab-entity",
@ -784,6 +785,7 @@ dependencies = [
"mime", "mime",
"mime_guess", "mime_guess",
"parking_lot", "parking_lot",
"prost",
"realtime-entity", "realtime-entity",
"reqwest", "reqwest",
"scraper 0.17.1", "scraper 0.17.1",
@ -861,7 +863,7 @@ dependencies = [
[[package]] [[package]]
name = "collab" name = "collab"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=faf17b54#faf17b54ead0c1286e4ba8332d25e42bf1e1d627" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=68459c6c501cd6d69deda04605839db1b442bb01#68459c6c501cd6d69deda04605839db1b442bb01"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",
@ -881,7 +883,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-database" name = "collab-database"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=faf17b54#faf17b54ead0c1286e4ba8332d25e42bf1e1d627" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=68459c6c501cd6d69deda04605839db1b442bb01#68459c6c501cd6d69deda04605839db1b442bb01"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",
@ -911,7 +913,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-derive" name = "collab-derive"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=faf17b54#faf17b54ead0c1286e4ba8332d25e42bf1e1d627" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=68459c6c501cd6d69deda04605839db1b442bb01#68459c6c501cd6d69deda04605839db1b442bb01"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -923,7 +925,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-document" name = "collab-document"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=faf17b54#faf17b54ead0c1286e4ba8332d25e42bf1e1d627" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=68459c6c501cd6d69deda04605839db1b442bb01#68459c6c501cd6d69deda04605839db1b442bb01"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"collab", "collab",
@ -943,7 +945,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-entity" name = "collab-entity"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=faf17b54#faf17b54ead0c1286e4ba8332d25e42bf1e1d627" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=68459c6c501cd6d69deda04605839db1b442bb01#68459c6c501cd6d69deda04605839db1b442bb01"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bytes", "bytes",
@ -957,7 +959,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-folder" name = "collab-folder"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=faf17b54#faf17b54ead0c1286e4ba8332d25e42bf1e1d627" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=68459c6c501cd6d69deda04605839db1b442bb01#68459c6c501cd6d69deda04605839db1b442bb01"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"chrono", "chrono",
@ -999,7 +1001,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-persistence" name = "collab-persistence"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=faf17b54#faf17b54ead0c1286e4ba8332d25e42bf1e1d627" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=68459c6c501cd6d69deda04605839db1b442bb01#68459c6c501cd6d69deda04605839db1b442bb01"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"bincode", "bincode",
@ -1020,7 +1022,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-plugins" name = "collab-plugins"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=faf17b54#faf17b54ead0c1286e4ba8332d25e42bf1e1d627" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=68459c6c501cd6d69deda04605839db1b442bb01#68459c6c501cd6d69deda04605839db1b442bb01"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",
@ -1047,7 +1049,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-user" name = "collab-user"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=faf17b54#faf17b54ead0c1286e4ba8332d25e42bf1e1d627" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=68459c6c501cd6d69deda04605839db1b442bb01#68459c6c501cd6d69deda04605839db1b442bb01"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"collab", "collab",
@ -1446,7 +1448,7 @@ checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308"
[[package]] [[package]]
name = "database-entity" name = "database-entity"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7752ab68a91ff742fae595c1b45babdc17927fea#7752ab68a91ff742fae595c1b45babdc17927fea" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d37fbbf486dc44336c87acd59cf8b6feff57b330#d37fbbf486dc44336c87acd59cf8b6feff57b330"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"app-error", "app-error",
@ -1848,6 +1850,12 @@ dependencies = [
"windows-sys 0.48.0", "windows-sys 0.48.0",
] ]
[[package]]
name = "fixedbitset"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80"
[[package]] [[package]]
name = "flate2" name = "flate2"
version = "1.0.26" version = "1.0.26"
@ -2796,7 +2804,7 @@ dependencies = [
[[package]] [[package]]
name = "gotrue" name = "gotrue"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7752ab68a91ff742fae595c1b45babdc17927fea#7752ab68a91ff742fae595c1b45babdc17927fea" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d37fbbf486dc44336c87acd59cf8b6feff57b330#d37fbbf486dc44336c87acd59cf8b6feff57b330"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"futures-util", "futures-util",
@ -2812,7 +2820,7 @@ dependencies = [
[[package]] [[package]]
name = "gotrue-entity" name = "gotrue-entity"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7752ab68a91ff742fae595c1b45babdc17927fea#7752ab68a91ff742fae595c1b45babdc17927fea" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d37fbbf486dc44336c87acd59cf8b6feff57b330#d37fbbf486dc44336c87acd59cf8b6feff57b330"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"app-error", "app-error",
@ -3248,7 +3256,7 @@ dependencies = [
[[package]] [[package]]
name = "infra" name = "infra"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7752ab68a91ff742fae595c1b45babdc17927fea#7752ab68a91ff742fae595c1b45babdc17927fea" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d37fbbf486dc44336c87acd59cf8b6feff57b330#d37fbbf486dc44336c87acd59cf8b6feff57b330"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"reqwest", "reqwest",
@ -3813,6 +3821,12 @@ dependencies = [
"windows-sys 0.48.0", "windows-sys 0.48.0",
] ]
[[package]]
name = "multimap"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a"
[[package]] [[package]]
name = "nanoid" name = "nanoid"
version = "0.4.0" version = "0.4.0"
@ -4286,6 +4300,16 @@ dependencies = [
"sha2", "sha2",
] ]
[[package]]
name = "petgraph"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9"
dependencies = [
"fixedbitset",
"indexmap 2.0.0",
]
[[package]] [[package]]
name = "phf" name = "phf"
version = "0.8.0" version = "0.8.0"
@ -4642,6 +4666,60 @@ dependencies = [
"unicode-ident", "unicode-ident",
] ]
[[package]]
name = "prost"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4fdd22f3b9c31b53c060df4a0613a1c7f062d4115a2b984dd15b1858f7e340d"
dependencies = [
"bytes",
"prost-derive",
]
[[package]]
name = "prost-build"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8bdf592881d821b83d471f8af290226c8d51402259e9bb5be7f9f8bdebbb11ac"
dependencies = [
"bytes",
"heck 0.4.1",
"itertools 0.11.0",
"log",
"multimap",
"once_cell",
"petgraph",
"prettyplease",
"prost",
"prost-types",
"regex",
"syn 2.0.29",
"tempfile",
"which",
]
[[package]]
name = "prost-derive"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "265baba7fabd416cf5078179f7d2cbeca4ce7a9041111900675ea7c4cb8a4c32"
dependencies = [
"anyhow",
"itertools 0.11.0",
"proc-macro2",
"quote",
"syn 2.0.29",
]
[[package]]
name = "prost-types"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e081b29f63d83a4bc75cfc9f3fe424f9156cf92d8a4f0c9407cce9a1b67327cf"
dependencies = [
"prost",
]
[[package]] [[package]]
name = "protobuf" name = "protobuf"
version = "2.28.0" version = "2.28.0"
@ -4922,14 +5000,19 @@ dependencies = [
[[package]] [[package]]
name = "realtime-entity" name = "realtime-entity"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7752ab68a91ff742fae595c1b45babdc17927fea#7752ab68a91ff742fae595c1b45babdc17927fea" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d37fbbf486dc44336c87acd59cf8b6feff57b330#d37fbbf486dc44336c87acd59cf8b6feff57b330"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bincode",
"bytes", "bytes",
"collab", "collab",
"collab-entity", "collab-entity",
"prost",
"prost-build",
"protoc-bin-vendored",
"serde", "serde",
"serde_json", "serde_json",
"tokio-tungstenite",
] ]
[[package]] [[package]]
@ -5661,7 +5744,7 @@ dependencies = [
[[package]] [[package]]
name = "shared_entity" name = "shared_entity"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7752ab68a91ff742fae595c1b45babdc17927fea#7752ab68a91ff742fae595c1b45babdc17927fea" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d37fbbf486dc44336c87acd59cf8b6feff57b330#d37fbbf486dc44336c87acd59cf8b6feff57b330"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"app-error", "app-error",

View File

@ -38,7 +38,7 @@ custom-protocol = ["tauri/custom-protocol"]
# Run the script: # Run the script:
# scripts/tool/update_client_api_rev.sh new_rev_id # scripts/tool/update_client_api_rev.sh new_rev_id
# ⚠️⚠️⚠️️ # ⚠️⚠️⚠️️
client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "7752ab68a91ff742fae595c1b45babdc17927fea" } client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "d37fbbf486dc44336c87acd59cf8b6feff57b330" }
# Please use the following script to update collab. # Please use the following script to update collab.
# Working directory: frontend # Working directory: frontend
# #
@ -48,14 +48,14 @@ client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "775
# To switch to the local path, run: # To switch to the local path, run:
# scripts/tool/update_collab_source.sh # scripts/tool/update_collab_source.sh
# ⚠️⚠️⚠️️ # ⚠️⚠️⚠️️
collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "faf17b54" } collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "68459c6c501cd6d69deda04605839db1b442bb01" }
collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "faf17b54" } collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "68459c6c501cd6d69deda04605839db1b442bb01" }
collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "faf17b54" } collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "68459c6c501cd6d69deda04605839db1b442bb01" }
collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "faf17b54" } collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "68459c6c501cd6d69deda04605839db1b442bb01" }
collab-plugins = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "faf17b54" } collab-plugins = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "68459c6c501cd6d69deda04605839db1b442bb01" }
collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "faf17b54" } collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "68459c6c501cd6d69deda04605839db1b442bb01" }
collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "faf17b54" } collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "68459c6c501cd6d69deda04605839db1b442bb01" }
collab-persistence = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "faf17b54" } collab-persistence = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "68459c6c501cd6d69deda04605839db1b442bb01" }

View File

@ -124,7 +124,7 @@ checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6"
[[package]] [[package]]
name = "app-error" name = "app-error"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7752ab68a91ff742fae595c1b45babdc17927fea#7752ab68a91ff742fae595c1b45babdc17927fea" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d37fbbf486dc44336c87acd59cf8b6feff57b330#d37fbbf486dc44336c87acd59cf8b6feff57b330"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"reqwest", "reqwest",
@ -467,7 +467,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4114279215a005bc675e386011e594e1d9b800918cea18fcadadcce864a2046b" checksum = "4114279215a005bc675e386011e594e1d9b800918cea18fcadadcce864a2046b"
dependencies = [ dependencies = [
"borsh-derive", "borsh-derive",
"hashbrown 0.12.3", "hashbrown 0.13.2",
] ]
[[package]] [[package]]
@ -666,10 +666,11 @@ dependencies = [
[[package]] [[package]]
name = "client-api" name = "client-api"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7752ab68a91ff742fae595c1b45babdc17927fea#7752ab68a91ff742fae595c1b45babdc17927fea" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d37fbbf486dc44336c87acd59cf8b6feff57b330#d37fbbf486dc44336c87acd59cf8b6feff57b330"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"app-error", "app-error",
"async-trait",
"bytes", "bytes",
"collab", "collab",
"collab-entity", "collab-entity",
@ -682,6 +683,7 @@ dependencies = [
"mime", "mime",
"mime_guess", "mime_guess",
"parking_lot", "parking_lot",
"prost 0.12.1",
"realtime-entity", "realtime-entity",
"reqwest", "reqwest",
"scraper 0.17.1", "scraper 0.17.1",
@ -728,7 +730,7 @@ dependencies = [
[[package]] [[package]]
name = "collab" name = "collab"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=faf17b54#faf17b54ead0c1286e4ba8332d25e42bf1e1d627" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=68459c6c501cd6d69deda04605839db1b442bb01#68459c6c501cd6d69deda04605839db1b442bb01"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",
@ -748,7 +750,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-database" name = "collab-database"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=faf17b54#faf17b54ead0c1286e4ba8332d25e42bf1e1d627" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=68459c6c501cd6d69deda04605839db1b442bb01#68459c6c501cd6d69deda04605839db1b442bb01"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",
@ -778,7 +780,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-derive" name = "collab-derive"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=faf17b54#faf17b54ead0c1286e4ba8332d25e42bf1e1d627" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=68459c6c501cd6d69deda04605839db1b442bb01#68459c6c501cd6d69deda04605839db1b442bb01"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -790,7 +792,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-document" name = "collab-document"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=faf17b54#faf17b54ead0c1286e4ba8332d25e42bf1e1d627" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=68459c6c501cd6d69deda04605839db1b442bb01#68459c6c501cd6d69deda04605839db1b442bb01"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"collab", "collab",
@ -810,7 +812,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-entity" name = "collab-entity"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=faf17b54#faf17b54ead0c1286e4ba8332d25e42bf1e1d627" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=68459c6c501cd6d69deda04605839db1b442bb01#68459c6c501cd6d69deda04605839db1b442bb01"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bytes", "bytes",
@ -824,7 +826,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-folder" name = "collab-folder"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=faf17b54#faf17b54ead0c1286e4ba8332d25e42bf1e1d627" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=68459c6c501cd6d69deda04605839db1b442bb01#68459c6c501cd6d69deda04605839db1b442bb01"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"chrono", "chrono",
@ -866,7 +868,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-persistence" name = "collab-persistence"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=faf17b54#faf17b54ead0c1286e4ba8332d25e42bf1e1d627" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=68459c6c501cd6d69deda04605839db1b442bb01#68459c6c501cd6d69deda04605839db1b442bb01"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"bincode", "bincode",
@ -887,7 +889,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-plugins" name = "collab-plugins"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=faf17b54#faf17b54ead0c1286e4ba8332d25e42bf1e1d627" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=68459c6c501cd6d69deda04605839db1b442bb01#68459c6c501cd6d69deda04605839db1b442bb01"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",
@ -914,7 +916,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-user" name = "collab-user"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=faf17b54#faf17b54ead0c1286e4ba8332d25e42bf1e1d627" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=68459c6c501cd6d69deda04605839db1b442bb01#68459c6c501cd6d69deda04605839db1b442bb01"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"collab", "collab",
@ -960,8 +962,8 @@ version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2895653b4d9f1538a83970077cb01dfc77a4810524e51a110944688e916b18e" checksum = "c2895653b4d9f1538a83970077cb01dfc77a4810524e51a110944688e916b18e"
dependencies = [ dependencies = [
"prost", "prost 0.11.9",
"prost-types", "prost-types 0.11.9",
"tonic", "tonic",
"tracing-core", "tracing-core",
] ]
@ -978,7 +980,7 @@ dependencies = [
"futures", "futures",
"hdrhistogram", "hdrhistogram",
"humantime", "humantime",
"prost-types", "prost-types 0.11.9",
"serde", "serde",
"serde_json", "serde_json",
"thread_local", "thread_local",
@ -1273,7 +1275,7 @@ checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308"
[[package]] [[package]]
name = "database-entity" name = "database-entity"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7752ab68a91ff742fae595c1b45babdc17927fea#7752ab68a91ff742fae595c1b45babdc17927fea" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d37fbbf486dc44336c87acd59cf8b6feff57b330#d37fbbf486dc44336c87acd59cf8b6feff57b330"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"app-error", "app-error",
@ -1667,6 +1669,12 @@ version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8fcfdc7a0362c9f4444381a9e697c79d435fe65b52a37466fc2c1184cee9edc6" checksum = "8fcfdc7a0362c9f4444381a9e697c79d435fe65b52a37466fc2c1184cee9edc6"
[[package]]
name = "fixedbitset"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80"
[[package]] [[package]]
name = "flate2" name = "flate2"
version = "1.0.27" version = "1.0.27"
@ -2455,7 +2463,7 @@ dependencies = [
[[package]] [[package]]
name = "gotrue" name = "gotrue"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7752ab68a91ff742fae595c1b45babdc17927fea#7752ab68a91ff742fae595c1b45babdc17927fea" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d37fbbf486dc44336c87acd59cf8b6feff57b330#d37fbbf486dc44336c87acd59cf8b6feff57b330"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"futures-util", "futures-util",
@ -2471,7 +2479,7 @@ dependencies = [
[[package]] [[package]]
name = "gotrue-entity" name = "gotrue-entity"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7752ab68a91ff742fae595c1b45babdc17927fea#7752ab68a91ff742fae595c1b45babdc17927fea" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d37fbbf486dc44336c87acd59cf8b6feff57b330#d37fbbf486dc44336c87acd59cf8b6feff57b330"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"app-error", "app-error",
@ -2832,7 +2840,7 @@ dependencies = [
[[package]] [[package]]
name = "infra" name = "infra"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7752ab68a91ff742fae595c1b45babdc17927fea#7752ab68a91ff742fae595c1b45babdc17927fea" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d37fbbf486dc44336c87acd59cf8b6feff57b330#d37fbbf486dc44336c87acd59cf8b6feff57b330"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"reqwest", "reqwest",
@ -3262,6 +3270,12 @@ dependencies = [
"windows-sys", "windows-sys",
] ]
[[package]]
name = "multimap"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a"
[[package]] [[package]]
name = "nanoid" name = "nanoid"
version = "0.4.0" version = "0.4.0"
@ -3624,6 +3638,16 @@ dependencies = [
"sha2", "sha2",
] ]
[[package]]
name = "petgraph"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9"
dependencies = [
"fixedbitset",
"indexmap 2.0.0",
]
[[package]] [[package]]
name = "phf" name = "phf"
version = "0.8.0" version = "0.8.0"
@ -3923,7 +3947,39 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd" checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd"
dependencies = [ dependencies = [
"bytes", "bytes",
"prost-derive", "prost-derive 0.11.9",
]
[[package]]
name = "prost"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4fdd22f3b9c31b53c060df4a0613a1c7f062d4115a2b984dd15b1858f7e340d"
dependencies = [
"bytes",
"prost-derive 0.12.1",
]
[[package]]
name = "prost-build"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8bdf592881d821b83d471f8af290226c8d51402259e9bb5be7f9f8bdebbb11ac"
dependencies = [
"bytes",
"heck 0.4.1",
"itertools 0.11.0",
"log",
"multimap",
"once_cell",
"petgraph",
"prettyplease",
"prost 0.12.1",
"prost-types 0.12.1",
"regex",
"syn 2.0.31",
"tempfile",
"which",
] ]
[[package]] [[package]]
@ -3939,13 +3995,35 @@ dependencies = [
"syn 1.0.109", "syn 1.0.109",
] ]
[[package]]
name = "prost-derive"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "265baba7fabd416cf5078179f7d2cbeca4ce7a9041111900675ea7c4cb8a4c32"
dependencies = [
"anyhow",
"itertools 0.11.0",
"proc-macro2",
"quote",
"syn 2.0.31",
]
[[package]] [[package]]
name = "prost-types" name = "prost-types"
version = "0.11.9" version = "0.11.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "213622a1460818959ac1181aaeb2dc9c7f63df720db7d788b3e24eacd1983e13" checksum = "213622a1460818959ac1181aaeb2dc9c7f63df720db7d788b3e24eacd1983e13"
dependencies = [ dependencies = [
"prost", "prost 0.11.9",
]
[[package]]
name = "prost-types"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e081b29f63d83a4bc75cfc9f3fe424f9156cf92d8a4f0c9407cce9a1b67327cf"
dependencies = [
"prost 0.12.1",
] ]
[[package]] [[package]]
@ -4272,14 +4350,19 @@ dependencies = [
[[package]] [[package]]
name = "realtime-entity" name = "realtime-entity"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7752ab68a91ff742fae595c1b45babdc17927fea#7752ab68a91ff742fae595c1b45babdc17927fea" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d37fbbf486dc44336c87acd59cf8b6feff57b330#d37fbbf486dc44336c87acd59cf8b6feff57b330"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bincode",
"bytes", "bytes",
"collab", "collab",
"collab-entity", "collab-entity",
"prost 0.12.1",
"prost-build",
"protoc-bin-vendored",
"serde", "serde",
"serde_json", "serde_json",
"tokio-tungstenite",
] ]
[[package]] [[package]]
@ -4910,7 +4993,7 @@ dependencies = [
[[package]] [[package]]
name = "shared_entity" name = "shared_entity"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=7752ab68a91ff742fae595c1b45babdc17927fea#7752ab68a91ff742fae595c1b45babdc17927fea" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d37fbbf486dc44336c87acd59cf8b6feff57b330#d37fbbf486dc44336c87acd59cf8b6feff57b330"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"app-error", "app-error",
@ -5584,7 +5667,7 @@ dependencies = [
"hyper-timeout", "hyper-timeout",
"percent-encoding", "percent-encoding",
"pin-project", "pin-project",
"prost", "prost 0.11.9",
"tokio", "tokio",
"tokio-stream", "tokio-stream",
"tower", "tower",

View File

@ -26,6 +26,7 @@ members = [
"flowy-ai", "flowy-ai",
"flowy-date", "flowy-date",
] ]
resolver = "2"
[workspace.dependencies] [workspace.dependencies]
lib-dispatch = { workspace = true, path = "lib-dispatch" } lib-dispatch = { workspace = true, path = "lib-dispatch" }
@ -82,7 +83,7 @@ incremental = false
# Run the script: # Run the script:
# scripts/tool/update_client_api_rev.sh new_rev_id # scripts/tool/update_client_api_rev.sh new_rev_id
# ⚠️⚠️⚠️️ # ⚠️⚠️⚠️️
client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "7752ab68a91ff742fae595c1b45babdc17927fea" } client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "d37fbbf486dc44336c87acd59cf8b6feff57b330" }
# Please use the following script to update collab. # Please use the following script to update collab.
# Working directory: frontend # Working directory: frontend
# #
@ -92,11 +93,11 @@ client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "775
# To switch to the local path, run: # To switch to the local path, run:
# scripts/tool/update_collab_source.sh # scripts/tool/update_collab_source.sh
# ⚠️⚠️⚠️️ # ⚠️⚠️⚠️️
collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "faf17b54" } collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "68459c6c501cd6d69deda04605839db1b442bb01" }
collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "faf17b54" } collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "68459c6c501cd6d69deda04605839db1b442bb01" }
collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "faf17b54" } collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "68459c6c501cd6d69deda04605839db1b442bb01" }
collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "faf17b54" } collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "68459c6c501cd6d69deda04605839db1b442bb01" }
collab-plugins = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "faf17b54" } collab-plugins = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "68459c6c501cd6d69deda04605839db1b442bb01" }
collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "faf17b54" } collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "68459c6c501cd6d69deda04605839db1b442bb01" }
collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "faf17b54" } collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "68459c6c501cd6d69deda04605839db1b442bb01" }
collab-persistence = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "faf17b54" } collab-persistence = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "68459c6c501cd6d69deda04605839db1b442bb01" }

View File

@ -330,6 +330,7 @@ impl CollabStorageProvider for ServerProvider {
let (sink, stream) = (channel.sink(), channel.stream()); let (sink, stream) = (channel.sink(), channel.stream());
let sink_config = SinkConfig::new() let sink_config = SinkConfig::new()
.send_timeout(8) .send_timeout(8)
.with_max_payload_size(1024 * 10)
.with_strategy(SinkStrategy::FixInterval(Duration::from_secs(2))); .with_strategy(SinkStrategy::FixInterval(Duration::from_secs(2)));
let sync_plugin = SyncPlugin::new( let sync_plugin = SyncPlugin::new(
origin, origin,

View File

@ -15,8 +15,7 @@ impl From<AppResponseError> for FlowyError {
AppErrorCode::MissingPayload => ErrorCode::MissingPayload, AppErrorCode::MissingPayload => ErrorCode::MissingPayload,
AppErrorCode::OpenError => ErrorCode::Internal, AppErrorCode::OpenError => ErrorCode::Internal,
AppErrorCode::InvalidUrl => ErrorCode::InvalidURL, AppErrorCode::InvalidUrl => ErrorCode::InvalidURL,
AppErrorCode::InvalidRequestParams => ErrorCode::InvalidParams, AppErrorCode::InvalidRequest => ErrorCode::InvalidParams,
AppErrorCode::UrlMissingParameter => ErrorCode::InvalidParams,
AppErrorCode::InvalidOAuthProvider => ErrorCode::InvalidAuthConfig, AppErrorCode::InvalidOAuthProvider => ErrorCode::InvalidAuthConfig,
AppErrorCode::NotLoggedIn => ErrorCode::UserUnauthorized, AppErrorCode::NotLoggedIn => ErrorCode::UserUnauthorized,
AppErrorCode::NotEnoughPermissions => ErrorCode::NotEnoughPermissions, AppErrorCode::NotEnoughPermissions => ErrorCode::NotEnoughPermissions,

View File

@ -450,7 +450,7 @@ impl FolderManager {
} }
let index = params.index; let index = params.index;
let view = create_view(params, view_layout); let view = create_view(self.user.user_id()?, params, view_layout);
self.with_folder( self.with_folder(
|| (), || (),
|folder| { |folder| {
@ -474,7 +474,7 @@ impl FolderManager {
handler handler
.create_built_in_view(user_id, &params.view_id, &params.name, view_layout.clone()) .create_built_in_view(user_id, &params.view_id, &params.name, view_layout.clone())
.await?; .await?;
let view = create_view(params, view_layout); let view = create_view(self.user.user_id()?, params, view_layout);
self.with_folder( self.with_folder(
|| (), || (),
|folder| { |folder| {
@ -915,7 +915,7 @@ impl FolderManager {
index: None, index: None,
}; };
let view = create_view(params, import_data.view_layout); let view = create_view(self.user.user_id()?, params, import_data.view_layout);
self.with_folder( self.with_folder(
|| (), || (),
|folder| { |folder| {
@ -1278,6 +1278,7 @@ impl Deref for MutexFolder {
unsafe impl Sync for MutexFolder {} unsafe impl Sync for MutexFolder {}
unsafe impl Send for MutexFolder {} unsafe impl Send for MutexFolder {}
#[allow(clippy::large_enum_variant)]
pub enum FolderInitDataSource { pub enum FolderInitDataSource {
/// It means using the data stored on local disk to initialize the folder /// It means using the data stored on local disk to initialize the folder
LocalDisk { create_if_not_exist: bool }, LocalDisk { create_if_not_exist: bool },

View File

@ -17,8 +17,10 @@ impl DefaultFolderBuilder {
workspace_id: String, workspace_id: String,
handlers: &FolderOperationHandlers, handlers: &FolderOperationHandlers,
) -> FolderData { ) -> FolderData {
let workspace_view_builder = let workspace_view_builder = Arc::new(RwLock::new(WorkspaceViewBuilder::new(
Arc::new(RwLock::new(WorkspaceViewBuilder::new(workspace_id.clone()))); workspace_id.clone(),
uid,
)));
for handler in handlers.values() { for handler in handlers.values() {
let _ = handler let _ = handler
.create_workspace_view(uid, workspace_view_builder.clone()) .create_workspace_view(uid, workspace_view_builder.clone())
@ -41,6 +43,9 @@ impl DefaultFolderBuilder {
name: "Workspace".to_string(), name: "Workspace".to_string(),
child_views: RepeatedViewIdentifier::new(first_level_views), child_views: RepeatedViewIdentifier::new(first_level_views),
created_at: timestamp(), created_at: timestamp(),
created_by: Some(uid),
last_edited_time: timestamp(),
last_edited_by: Some(uid),
}; };
FolderData { FolderData {
@ -48,6 +53,7 @@ impl DefaultFolderBuilder {
current_view: first_view.id, current_view: first_view.id,
views: FlattedViews::flatten_views(views), views: FlattedViews::flatten_views(views),
favorites: Default::default(), favorites: Default::default(),
recent: Default::default(),
} }
} }
} }

View File

@ -20,13 +20,15 @@ pub type ViewData = Bytes;
/// A builder for creating a view for a workspace. /// A builder for creating a view for a workspace.
/// The views created by this builder will be the first level views of the workspace. /// The views created by this builder will be the first level views of the workspace.
pub struct WorkspaceViewBuilder { pub struct WorkspaceViewBuilder {
pub uid: i64,
pub workspace_id: String, pub workspace_id: String,
pub views: Vec<ParentChildViews>, pub views: Vec<ParentChildViews>,
} }
impl WorkspaceViewBuilder { impl WorkspaceViewBuilder {
pub fn new(workspace_id: String) -> Self { pub fn new(workspace_id: String, uid: i64) -> Self {
Self { Self {
uid,
workspace_id, workspace_id,
views: vec![], views: vec![],
} }
@ -37,7 +39,7 @@ impl WorkspaceViewBuilder {
F: Fn(ViewBuilder) -> O, F: Fn(ViewBuilder) -> O,
O: Future<Output = ParentChildViews>, O: Future<Output = ParentChildViews>,
{ {
let builder = ViewBuilder::new(self.workspace_id.clone()); let builder = ViewBuilder::new(self.uid, self.workspace_id.clone());
self.views.push(view_builder(builder).await); self.views.push(view_builder(builder).await);
} }
@ -49,6 +51,7 @@ impl WorkspaceViewBuilder {
/// A builder for creating a view. /// A builder for creating a view.
/// The default layout of the view is [ViewLayout::Document] /// The default layout of the view is [ViewLayout::Document]
pub struct ViewBuilder { pub struct ViewBuilder {
uid: i64,
parent_view_id: String, parent_view_id: String,
view_id: String, view_id: String,
name: String, name: String,
@ -60,8 +63,9 @@ pub struct ViewBuilder {
} }
impl ViewBuilder { impl ViewBuilder {
pub fn new(parent_view_id: String) -> Self { pub fn new(uid: i64, parent_view_id: String) -> Self {
Self { Self {
uid,
parent_view_id, parent_view_id,
view_id: gen_view_id().to_string(), view_id: gen_view_id().to_string(),
name: Default::default(), name: Default::default(),
@ -99,7 +103,7 @@ impl ViewBuilder {
F: Fn(ViewBuilder) -> O, F: Fn(ViewBuilder) -> O,
O: Future<Output = ParentChildViews>, O: Future<Output = ParentChildViews>,
{ {
let builder = ViewBuilder::new(self.view_id.clone()); let builder = ViewBuilder::new(self.uid, self.view_id.clone());
self.child_views.push(child_view_builder(builder).await); self.child_views.push(child_view_builder(builder).await);
self self
} }
@ -114,6 +118,8 @@ impl ViewBuilder {
is_favorite: self.is_favorite, is_favorite: self.is_favorite,
layout: self.layout, layout: self.layout,
icon: self.icon, icon: self.icon,
created_by: Some(self.uid),
last_edited_time: 0,
children: RepeatedViewIdentifier::new( children: RepeatedViewIdentifier::new(
self self
.child_views .child_views
@ -123,6 +129,7 @@ impl ViewBuilder {
}) })
.collect(), .collect(),
), ),
last_edited_by: Some(self.uid),
}; };
ParentChildViews { ParentChildViews {
parent_view: view, parent_view: view,
@ -246,7 +253,7 @@ impl From<ViewLayoutPB> for ViewLayout {
} }
} }
pub(crate) fn create_view(params: CreateViewParams, layout: ViewLayout) -> View { pub(crate) fn create_view(uid: i64, params: CreateViewParams, layout: ViewLayout) -> View {
let time = timestamp(); let time = timestamp();
View { View {
id: params.view_id, id: params.view_id,
@ -258,6 +265,9 @@ pub(crate) fn create_view(params: CreateViewParams, layout: ViewLayout) -> View
is_favorite: false, is_favorite: false,
layout, layout,
icon: None, icon: None,
created_by: Some(uid),
last_edited_time: 0,
last_edited_by: Some(uid),
} }
} }
@ -268,7 +278,7 @@ mod tests {
#[tokio::test] #[tokio::test]
async fn create_first_level_views_test() { async fn create_first_level_views_test() {
let workspace_id = "w1".to_string(); let workspace_id = "w1".to_string();
let mut builder = WorkspaceViewBuilder::new(workspace_id); let mut builder = WorkspaceViewBuilder::new(workspace_id, 1);
builder builder
.with_view_builder(|view_builder| async { view_builder.with_name("1").build() }) .with_view_builder(|view_builder| async { view_builder.with_name("1").build() })
.await; .await;
@ -288,7 +298,7 @@ mod tests {
#[tokio::test] #[tokio::test]
async fn create_view_with_child_views_test() { async fn create_view_with_child_views_test() {
let workspace_id = "w1".to_string(); let workspace_id = "w1".to_string();
let mut builder = WorkspaceViewBuilder::new(workspace_id); let mut builder = WorkspaceViewBuilder::new(workspace_id, 1);
builder builder
.with_view_builder(|view_builder| async { .with_view_builder(|view_builder| async {
view_builder view_builder
@ -331,7 +341,7 @@ mod tests {
#[tokio::test] #[tokio::test]
async fn create_three_level_view_test() { async fn create_three_level_view_test() {
let workspace_id = "w1".to_string(); let workspace_id = "w1".to_string();
let mut builder = WorkspaceViewBuilder::new(workspace_id); let mut builder = WorkspaceViewBuilder::new(workspace_id, 1);
builder builder
.with_view_builder(|view_builder| async { .with_view_builder(|view_builder| async {
view_builder view_builder

View File

@ -2,9 +2,10 @@ use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc; use std::sync::Arc;
use anyhow::Error; use anyhow::Error;
use client_api::collab_sync::collab_msg::CollabMessage;
use client_api::notify::{TokenState, TokenStateReceiver}; use client_api::notify::{TokenState, TokenStateReceiver};
use client_api::ws::{ use client_api::ws::{
BusinessID, ConnectState, WSClient, WSClientConfig, WSConnectStateReceiver, WebSocketChannel, ConnectState, WSClient, WSClientConfig, WSConnectStateReceiver, WebSocketChannel,
}; };
use client_api::Client; use client_api::Client;
use tokio::sync::watch; use tokio::sync::watch;
@ -50,11 +51,7 @@ impl AFCloudServer {
let token_state_rx = api_client.subscribe_token_state(); let token_state_rx = api_client.subscribe_token_state();
let enable_sync = Arc::new(AtomicBool::new(enable_sync)); let enable_sync = Arc::new(AtomicBool::new(enable_sync));
let ws_client = WSClient::new(WSClientConfig { let ws_client = WSClient::new(WSClientConfig::default(), api_client.clone());
buffer_capacity: 100,
ping_per_secs: 8,
retry_connect_per_pings: 6,
});
let ws_client = Arc::new(ws_client); let ws_client = Arc::new(ws_client);
let api_client = Arc::new(api_client); let api_client = Arc::new(api_client);
@ -99,7 +96,7 @@ impl AppFlowyServer for AFCloudServer {
while let Ok(token_state) = token_state_rx.recv().await { while let Ok(token_state) = token_state_rx.recv().await {
if let Some(client) = weak_client.upgrade() { if let Some(client) = weak_client.upgrade() {
match token_state { match token_state {
TokenState::Refresh => match client.get_token() { TokenState::Revoked => match client.get_token() {
Ok(token) => { Ok(token) => {
let _ = watch_tx.send(UserTokenState::Refresh { token }); let _ = watch_tx.send(UserTokenState::Refresh { token });
}, },
@ -110,6 +107,7 @@ impl AppFlowyServer for AFCloudServer {
TokenState::Invalid => { TokenState::Invalid => {
let _ = watch_tx.send(UserTokenState::Invalid); let _ = watch_tx.send(UserTokenState::Invalid);
}, },
TokenState::DidRefresh => {},
} }
} }
} }
@ -142,19 +140,26 @@ impl AppFlowyServer for AFCloudServer {
Arc::new(AFCloudDocumentCloudServiceImpl(server)) Arc::new(AFCloudDocumentCloudServiceImpl(server))
} }
#[allow(clippy::type_complexity)]
fn collab_ws_channel( fn collab_ws_channel(
&self, &self,
object_id: &str, _object_id: &str,
) -> FutureResult<Option<(Arc<WebSocketChannel>, WSConnectStateReceiver, bool)>, anyhow::Error> ) -> FutureResult<
{ Option<(
Arc<WebSocketChannel<CollabMessage>>,
WSConnectStateReceiver,
bool,
)>,
anyhow::Error,
> {
if self.enable_sync.load(Ordering::SeqCst) { if self.enable_sync.load(Ordering::SeqCst) {
let object_id = object_id.to_string(); let object_id = _object_id.to_string();
let weak_ws_client = Arc::downgrade(&self.ws_client); let weak_ws_client = Arc::downgrade(&self.ws_client);
FutureResult::new(async move { FutureResult::new(async move {
match weak_ws_client.upgrade() { match weak_ws_client.upgrade() {
None => Ok(None), None => Ok(None),
Some(ws_client) => { Some(ws_client) => {
let channel = ws_client.subscribe(BusinessID::CollabId, object_id).ok(); let channel = ws_client.subscribe(object_id).ok();
let connect_state_recv = ws_client.subscribe_connect_state(); let connect_state_recv = ws_client.subscribe_connect_state();
Ok(channel.map(|c| (c, connect_state_recv, ws_client.is_connected()))) Ok(channel.map(|c| (c, connect_state_recv, ws_client.is_connected())))
}, },
@ -203,7 +208,7 @@ fn spawn_ws_conn(
match api_client.ws_url(&device_id) { match api_client.ws_url(&device_id) {
Ok(ws_addr) => { Ok(ws_addr) => {
event!(tracing::Level::INFO, "🟢reconnecting websocket"); event!(tracing::Level::INFO, "🟢reconnecting websocket");
let _ = ws_client.connect(ws_addr).await; let _ = ws_client.connect(ws_addr, &device_id).await;
}, },
Err(err) => error!("Failed to get ws url: {}", err), Err(err) => error!("Failed to get ws url: {}", err),
} }
@ -212,8 +217,8 @@ fn spawn_ws_conn(
}, },
ConnectState::Unauthorized => { ConnectState::Unauthorized => {
if let Some(api_client) = weak_api_client.upgrade() { if let Some(api_client) = weak_api_client.upgrade() {
if enable_sync.load(Ordering::SeqCst) { if let Err(err) = api_client.refresh_token().await {
let _ = api_client.refresh().await; error!("Failed to refresh token: {}", err);
} }
} }
}, },
@ -229,7 +234,7 @@ fn spawn_ws_conn(
af_spawn(async move { af_spawn(async move {
while let Ok(token_state) = token_state_rx.recv().await { while let Ok(token_state) = token_state_rx.recv().await {
match token_state { match token_state {
TokenState::Refresh => { TokenState::Revoked => {
if let (Some(api_client), Some(ws_client), Some(device_id)) = ( if let (Some(api_client), Some(ws_client), Some(device_id)) = (
weak_api_client.upgrade(), weak_api_client.upgrade(),
weak_ws_client.upgrade(), weak_ws_client.upgrade(),
@ -239,7 +244,7 @@ fn spawn_ws_conn(
match api_client.ws_url(&device_id) { match api_client.ws_url(&device_id) {
Ok(ws_addr) => { Ok(ws_addr) => {
info!("🟢token state: {:?}, reconnecting websocket", token_state); info!("🟢token state: {:?}, reconnecting websocket", token_state);
let _ = ws_client.connect(ws_addr).await; let _ = ws_client.connect(ws_addr, &device_id).await;
}, },
Err(err) => error!("Failed to get ws url: {}", err), Err(err) => error!("Failed to get ws url: {}", err),
} }
@ -251,6 +256,7 @@ fn spawn_ws_conn(
ws_client.disconnect().await; ws_client.disconnect().await;
} }
}, },
TokenState::DidRefresh => {},
} }
} }
}); });

View File

@ -6,7 +6,6 @@ use flowy_folder_deps::cloud::{
gen_workspace_id, FolderCloudService, FolderData, FolderSnapshot, Workspace, WorkspaceRecord, gen_workspace_id, FolderCloudService, FolderData, FolderSnapshot, Workspace, WorkspaceRecord,
}; };
use lib_infra::future::FutureResult; use lib_infra::future::FutureResult;
use lib_infra::util::timestamp;
use crate::local_server::LocalServerDB; use crate::local_server::LocalServerDB;
@ -16,15 +15,14 @@ pub(crate) struct LocalServerFolderCloudServiceImpl {
} }
impl FolderCloudService for LocalServerFolderCloudServiceImpl { impl FolderCloudService for LocalServerFolderCloudServiceImpl {
fn create_workspace(&self, _uid: i64, name: &str) -> FutureResult<Workspace, Error> { fn create_workspace(&self, uid: i64, name: &str) -> FutureResult<Workspace, Error> {
let name = name.to_string(); let name = name.to_string();
FutureResult::new(async move { FutureResult::new(async move {
Ok(Workspace { Ok(Workspace::new(
id: gen_workspace_id().to_string(), gen_workspace_id().to_string(),
name: name.to_string(), name.to_string(),
child_views: Default::default(), uid,
created_at: timestamp(), ))
})
}) })
} }

View File

@ -1,6 +1,7 @@
use std::sync::Arc; use std::sync::Arc;
use anyhow::Error; use anyhow::Error;
use client_api::collab_sync::collab_msg::CollabMessage;
use client_api::ws::{WSConnectStateReceiver, WebSocketChannel}; use client_api::ws::{WSConnectStateReceiver, WebSocketChannel};
use collab_entity::CollabObject; use collab_entity::CollabObject;
use collab_plugins::cloud_storage::RemoteCollabStorage; use collab_plugins::cloud_storage::RemoteCollabStorage;
@ -101,11 +102,18 @@ pub trait AppFlowyServer: Send + Sync + 'static {
None None
} }
#[allow(clippy::type_complexity)]
fn collab_ws_channel( fn collab_ws_channel(
&self, &self,
_object_id: &str, _object_id: &str,
) -> FutureResult<Option<(Arc<WebSocketChannel>, WSConnectStateReceiver, bool)>, anyhow::Error> ) -> FutureResult<
{ Option<(
Arc<WebSocketChannel<CollabMessage>>,
WSConnectStateReceiver,
bool,
)>,
anyhow::Error,
> {
FutureResult::new(async { Ok(None) }) FutureResult::new(async { Ok(None) })
} }

View File

@ -13,6 +13,7 @@ use flowy_folder_deps::cloud::{
}; };
use lib_dispatch::prelude::af_spawn; use lib_dispatch::prelude::af_spawn;
use lib_infra::future::FutureResult; use lib_infra::future::FutureResult;
use lib_infra::util::timestamp;
use crate::response::ExtendedResponse; use crate::response::ExtendedResponse;
use crate::supabase::api::request::{ use crate::supabase::api::request::{
@ -170,5 +171,11 @@ fn workspace_from_json_value(value: Value) -> Result<Workspace, Error> {
.and_then(|s| DateTime::<Utc>::from_str(s).ok()) .and_then(|s| DateTime::<Utc>::from_str(s).ok())
.map(|date| date.timestamp()) .map(|date| date.timestamp())
.unwrap_or_default(), .unwrap_or_default(),
created_by: json.get("created_by").and_then(|value| value.as_i64()),
last_edited_time: json
.get("last_edited_time")
.and_then(|value| value.as_i64())
.unwrap_or(timestamp()),
last_edited_by: json.get("last_edited_by").and_then(|value| value.as_i64()),
}) })
} }

View File

@ -614,7 +614,7 @@ fn default_workspace_doc_state(collab_object: &CollabObject) -> Vec<u8> {
&collab_object.object_id, &collab_object.object_id,
vec![], vec![],
)); ));
let workspace = Workspace::new(workspace_id, "My workspace".to_string()); let workspace = Workspace::new(workspace_id, "My workspace".to_string(), collab_object.uid);
let folder = Folder::create(collab_object.uid, collab, None, FolderData::new(workspace)); let folder = Folder::create(collab_object.uid, collab, None, FolderData::new(workspace));
folder.encode_collab_v1().doc_state.to_vec() folder.encode_collab_v1().doc_state.to_vec()
} }

View File

@ -7,7 +7,7 @@ use serde::de::DeserializeOwned;
use serde::Serialize; use serde::Serialize;
use crate::kv::schema::{kv_table, kv_table::dsl, KV_SQL}; use crate::kv::schema::{kv_table, kv_table::dsl, KV_SQL};
use crate::sqlite::{Database, PoolConfig}; use crate::sqlite_impl::{Database, PoolConfig};
const DB_NAME: &str = "cache.db"; const DB_NAME: &str = "cache.db";

View File

@ -10,11 +10,11 @@ use std::{fmt::Debug, io, path::Path};
pub use diesel::*; pub use diesel::*;
pub use diesel_derives::*; pub use diesel_derives::*;
use crate::sqlite::PoolConfig; use crate::sqlite_impl::PoolConfig;
pub use crate::sqlite::{ConnectionPool, DBConnection, Database}; pub use crate::sqlite_impl::{ConnectionPool, DBConnection, Database};
pub mod kv; pub mod kv;
mod sqlite; mod sqlite_impl;
pub mod schema; pub mod schema;
@ -46,7 +46,7 @@ pub fn init<P: AsRef<Path>>(storage_path: P) -> Result<Database, io::Error> {
fn as_io_error<E>(e: E) -> io::Error fn as_io_error<E>(e: E) -> io::Error
where where
E: Into<crate::sqlite::Error> + Debug, E: Into<crate::sqlite_impl::Error> + Debug,
{ {
let msg = format!("{:?}", e); let msg = format!("{:?}", e);
io::Error::new(io::ErrorKind::NotConnected, msg) io::Error::new(io::ErrorKind::NotConnected, msg)

View File

@ -1,8 +1,9 @@
use crate::sqlite::errors::*;
use diesel::{ use diesel::{
dsl::sql, expression::SqlLiteral, query_dsl::LoadQuery, Connection, RunQueryDsl, SqliteConnection, dsl::sql, expression::SqlLiteral, query_dsl::LoadQuery, Connection, RunQueryDsl, SqliteConnection,
}; };
use crate::sqlite_impl::errors::*;
pub trait ConnectionExtension: Connection { pub trait ConnectionExtension: Connection {
fn query<ST, T>(&self, query: &str) -> Result<T> fn query<ST, T>(&self, query: &str) -> Result<T>
where where

View File

@ -1,9 +1,11 @@
use crate::sqlite::{ use std::sync::Arc;
use r2d2::PooledConnection;
use crate::sqlite_impl::{
errors::*, errors::*,
pool::{ConnectionManager, ConnectionPool, PoolConfig}, pool::{ConnectionManager, ConnectionPool, PoolConfig},
}; };
use r2d2::PooledConnection;
use std::sync::Arc;
pub struct Database { pub struct Database {
uri: String, uri: String,

View File

@ -4,7 +4,7 @@ use diesel::{connection::Connection, SqliteConnection};
use r2d2::{CustomizeConnection, ManageConnection, Pool}; use r2d2::{CustomizeConnection, ManageConnection, Pool};
use scheduled_thread_pool::ScheduledThreadPool; use scheduled_thread_pool::ScheduledThreadPool;
use crate::sqlite::{errors::*, pragma::*}; use crate::sqlite_impl::{errors::*, pragma::*};
pub struct ConnectionPool { pub struct ConnectionPool {
pub(crate) inner: Pool<ConnectionManager>, pub(crate) inner: Pool<ConnectionManager>,
@ -87,7 +87,7 @@ pub struct ConnectionManager {
impl ManageConnection for ConnectionManager { impl ManageConnection for ConnectionManager {
type Connection = SqliteConnection; type Connection = SqliteConnection;
type Error = crate::sqlite::Error; type Error = crate::sqlite_impl::Error;
fn connect(&self) -> Result<Self::Connection> { fn connect(&self) -> Result<Self::Connection> {
Ok(SqliteConnection::establish(&self.db_uri)?) Ok(SqliteConnection::establish(&self.db_uri)?)
@ -142,7 +142,7 @@ impl DatabaseCustomizer {
} }
} }
impl CustomizeConnection<SqliteConnection, crate::sqlite::Error> for DatabaseCustomizer { impl CustomizeConnection<SqliteConnection, crate::sqlite_impl::Error> for DatabaseCustomizer {
fn on_acquire(&self, conn: &mut SqliteConnection) -> Result<()> { fn on_acquire(&self, conn: &mut SqliteConnection) -> Result<()> {
conn.pragma_set_busy_timeout(self.config.busy_timeout)?; conn.pragma_set_busy_timeout(self.config.busy_timeout)?;
if self.config.journal_mode != SQLiteJournalMode::WAL { if self.config.journal_mode != SQLiteJournalMode::WAL {

View File

@ -1,5 +1,11 @@
#![allow(clippy::upper_case_acronyms)] #![allow(clippy::upper_case_acronyms)]
use crate::sqlite::errors::{Error, Result};
use std::{
convert::{TryFrom, TryInto},
fmt,
str::FromStr,
};
use diesel::{ use diesel::{
expression::SqlLiteral, expression::SqlLiteral,
query_dsl::load_dsl::LoadQuery, query_dsl::load_dsl::LoadQuery,
@ -7,12 +13,8 @@ use diesel::{
SqliteConnection, SqliteConnection,
}; };
use crate::sqlite::conn_ext::ConnectionExtension; use crate::sqlite_impl::conn_ext::ConnectionExtension;
use std::{ use crate::sqlite_impl::errors::{Error, Result};
convert::{TryFrom, TryInto},
fmt,
str::FromStr,
};
pub trait PragmaExtension: ConnectionExtension { pub trait PragmaExtension: ConnectionExtension {
fn pragma<D: std::fmt::Display>(&self, key: &str, val: D, schema: Option<&str>) -> Result<()> { fn pragma<D: std::fmt::Display>(&self, key: &str, val: D, schema: Option<&str>) -> Result<()> {