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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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
# If using AppFlowy Cloud (CLOUD_TYPE=2), provide the following details:
APPFLOWY_CLOUD_BASE_URL=replace-with-your-appflowy-cloud-url
APPFLOWY_CLOUD_WS_BASE_URL=replace-with-your-appflowy-cloud-ws-url
APPFLOWY_CLOUD_GOTRUE_URL=replace-with-your-appflowy-cloud-gotrue-url
APPFLOWY_CLOUD_BASE_URL=https://xxxxxxxxx
APPFLOWY_CLOUD_WS_BASE_URL=wss://xxxxxxxxx
APPFLOWY_CLOUD_GOTRUE_URL=https://xxxxxxxxx

View File

@ -138,7 +138,7 @@ checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6"
[[package]]
name = "app-error"
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 = [
"anyhow",
"reqwest",
@ -768,10 +768,11 @@ dependencies = [
[[package]]
name = "client-api"
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 = [
"anyhow",
"app-error",
"async-trait",
"bytes",
"collab",
"collab-entity",
@ -784,6 +785,7 @@ dependencies = [
"mime",
"mime_guess",
"parking_lot",
"prost",
"realtime-entity",
"reqwest",
"scraper 0.17.1",
@ -861,7 +863,7 @@ dependencies = [
[[package]]
name = "collab"
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 = [
"anyhow",
"async-trait",
@ -881,7 +883,7 @@ dependencies = [
[[package]]
name = "collab-database"
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 = [
"anyhow",
"async-trait",
@ -911,7 +913,7 @@ dependencies = [
[[package]]
name = "collab-derive"
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 = [
"proc-macro2",
"quote",
@ -923,7 +925,7 @@ dependencies = [
[[package]]
name = "collab-document"
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 = [
"anyhow",
"collab",
@ -943,7 +945,7 @@ dependencies = [
[[package]]
name = "collab-entity"
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 = [
"anyhow",
"bytes",
@ -957,7 +959,7 @@ dependencies = [
[[package]]
name = "collab-folder"
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 = [
"anyhow",
"chrono",
@ -999,7 +1001,7 @@ dependencies = [
[[package]]
name = "collab-persistence"
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 = [
"async-trait",
"bincode",
@ -1020,7 +1022,7 @@ dependencies = [
[[package]]
name = "collab-plugins"
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 = [
"anyhow",
"async-trait",
@ -1047,7 +1049,7 @@ dependencies = [
[[package]]
name = "collab-user"
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 = [
"anyhow",
"collab",
@ -1446,7 +1448,7 @@ checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308"
[[package]]
name = "database-entity"
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 = [
"anyhow",
"app-error",
@ -1848,6 +1850,12 @@ dependencies = [
"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]]
name = "flate2"
version = "1.0.26"
@ -2796,7 +2804,7 @@ dependencies = [
[[package]]
name = "gotrue"
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 = [
"anyhow",
"futures-util",
@ -2812,7 +2820,7 @@ dependencies = [
[[package]]
name = "gotrue-entity"
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 = [
"anyhow",
"app-error",
@ -3248,7 +3256,7 @@ dependencies = [
[[package]]
name = "infra"
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 = [
"anyhow",
"reqwest",
@ -3813,6 +3821,12 @@ dependencies = [
"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]]
name = "nanoid"
version = "0.4.0"
@ -4286,6 +4300,16 @@ dependencies = [
"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]]
name = "phf"
version = "0.8.0"
@ -4642,6 +4666,60 @@ dependencies = [
"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]]
name = "protobuf"
version = "2.28.0"
@ -4922,14 +5000,19 @@ dependencies = [
[[package]]
name = "realtime-entity"
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 = [
"anyhow",
"bincode",
"bytes",
"collab",
"collab-entity",
"prost",
"prost-build",
"protoc-bin-vendored",
"serde",
"serde_json",
"tokio-tungstenite",
]
[[package]]
@ -5661,7 +5744,7 @@ dependencies = [
[[package]]
name = "shared_entity"
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 = [
"anyhow",
"app-error",

View File

@ -38,7 +38,7 @@ custom-protocol = ["tauri/custom-protocol"]
# Run the script:
# 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.
# 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:
# scripts/tool/update_collab_source.sh
# ⚠️⚠️⚠️️
collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "faf17b54" }
collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "faf17b54" }
collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "faf17b54" }
collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "faf17b54" }
collab-plugins = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "faf17b54" }
collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "faf17b54" }
collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "faf17b54" }
collab-persistence = { 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 = "68459c6c501cd6d69deda04605839db1b442bb01" }
collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "68459c6c501cd6d69deda04605839db1b442bb01" }
collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "68459c6c501cd6d69deda04605839db1b442bb01" }
collab-plugins = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "68459c6c501cd6d69deda04605839db1b442bb01" }
collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "68459c6c501cd6d69deda04605839db1b442bb01" }
collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "68459c6c501cd6d69deda04605839db1b442bb01" }
collab-persistence = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "68459c6c501cd6d69deda04605839db1b442bb01" }

View File

@ -124,7 +124,7 @@ checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6"
[[package]]
name = "app-error"
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 = [
"anyhow",
"reqwest",
@ -467,7 +467,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4114279215a005bc675e386011e594e1d9b800918cea18fcadadcce864a2046b"
dependencies = [
"borsh-derive",
"hashbrown 0.12.3",
"hashbrown 0.13.2",
]
[[package]]
@ -666,10 +666,11 @@ dependencies = [
[[package]]
name = "client-api"
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 = [
"anyhow",
"app-error",
"async-trait",
"bytes",
"collab",
"collab-entity",
@ -682,6 +683,7 @@ dependencies = [
"mime",
"mime_guess",
"parking_lot",
"prost 0.12.1",
"realtime-entity",
"reqwest",
"scraper 0.17.1",
@ -728,7 +730,7 @@ dependencies = [
[[package]]
name = "collab"
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 = [
"anyhow",
"async-trait",
@ -748,7 +750,7 @@ dependencies = [
[[package]]
name = "collab-database"
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 = [
"anyhow",
"async-trait",
@ -778,7 +780,7 @@ dependencies = [
[[package]]
name = "collab-derive"
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 = [
"proc-macro2",
"quote",
@ -790,7 +792,7 @@ dependencies = [
[[package]]
name = "collab-document"
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 = [
"anyhow",
"collab",
@ -810,7 +812,7 @@ dependencies = [
[[package]]
name = "collab-entity"
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 = [
"anyhow",
"bytes",
@ -824,7 +826,7 @@ dependencies = [
[[package]]
name = "collab-folder"
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 = [
"anyhow",
"chrono",
@ -866,7 +868,7 @@ dependencies = [
[[package]]
name = "collab-persistence"
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 = [
"async-trait",
"bincode",
@ -887,7 +889,7 @@ dependencies = [
[[package]]
name = "collab-plugins"
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 = [
"anyhow",
"async-trait",
@ -914,7 +916,7 @@ dependencies = [
[[package]]
name = "collab-user"
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 = [
"anyhow",
"collab",
@ -960,8 +962,8 @@ version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2895653b4d9f1538a83970077cb01dfc77a4810524e51a110944688e916b18e"
dependencies = [
"prost",
"prost-types",
"prost 0.11.9",
"prost-types 0.11.9",
"tonic",
"tracing-core",
]
@ -978,7 +980,7 @@ dependencies = [
"futures",
"hdrhistogram",
"humantime",
"prost-types",
"prost-types 0.11.9",
"serde",
"serde_json",
"thread_local",
@ -1273,7 +1275,7 @@ checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308"
[[package]]
name = "database-entity"
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 = [
"anyhow",
"app-error",
@ -1667,6 +1669,12 @@ version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8fcfdc7a0362c9f4444381a9e697c79d435fe65b52a37466fc2c1184cee9edc6"
[[package]]
name = "fixedbitset"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80"
[[package]]
name = "flate2"
version = "1.0.27"
@ -2455,7 +2463,7 @@ dependencies = [
[[package]]
name = "gotrue"
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 = [
"anyhow",
"futures-util",
@ -2471,7 +2479,7 @@ dependencies = [
[[package]]
name = "gotrue-entity"
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 = [
"anyhow",
"app-error",
@ -2832,7 +2840,7 @@ dependencies = [
[[package]]
name = "infra"
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 = [
"anyhow",
"reqwest",
@ -3262,6 +3270,12 @@ dependencies = [
"windows-sys",
]
[[package]]
name = "multimap"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a"
[[package]]
name = "nanoid"
version = "0.4.0"
@ -3624,6 +3638,16 @@ dependencies = [
"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]]
name = "phf"
version = "0.8.0"
@ -3923,7 +3947,39 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd"
dependencies = [
"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]]
@ -3939,13 +3995,35 @@ dependencies = [
"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]]
name = "prost-types"
version = "0.11.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "213622a1460818959ac1181aaeb2dc9c7f63df720db7d788b3e24eacd1983e13"
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]]
@ -4272,14 +4350,19 @@ dependencies = [
[[package]]
name = "realtime-entity"
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 = [
"anyhow",
"bincode",
"bytes",
"collab",
"collab-entity",
"prost 0.12.1",
"prost-build",
"protoc-bin-vendored",
"serde",
"serde_json",
"tokio-tungstenite",
]
[[package]]
@ -4910,7 +4993,7 @@ dependencies = [
[[package]]
name = "shared_entity"
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 = [
"anyhow",
"app-error",
@ -5584,7 +5667,7 @@ dependencies = [
"hyper-timeout",
"percent-encoding",
"pin-project",
"prost",
"prost 0.11.9",
"tokio",
"tokio-stream",
"tower",

View File

@ -26,6 +26,7 @@ members = [
"flowy-ai",
"flowy-date",
]
resolver = "2"
[workspace.dependencies]
lib-dispatch = { workspace = true, path = "lib-dispatch" }
@ -82,7 +83,7 @@ incremental = false
# Run the script:
# 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.
# 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:
# scripts/tool/update_collab_source.sh
# ⚠️⚠️⚠️️
collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "faf17b54" }
collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "faf17b54" }
collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "faf17b54" }
collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "faf17b54" }
collab-plugins = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "faf17b54" }
collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "faf17b54" }
collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "faf17b54" }
collab-persistence = { 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 = "68459c6c501cd6d69deda04605839db1b442bb01" }
collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "68459c6c501cd6d69deda04605839db1b442bb01" }
collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "68459c6c501cd6d69deda04605839db1b442bb01" }
collab-plugins = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "68459c6c501cd6d69deda04605839db1b442bb01" }
collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "68459c6c501cd6d69deda04605839db1b442bb01" }
collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "68459c6c501cd6d69deda04605839db1b442bb01" }
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_config = SinkConfig::new()
.send_timeout(8)
.with_max_payload_size(1024 * 10)
.with_strategy(SinkStrategy::FixInterval(Duration::from_secs(2)));
let sync_plugin = SyncPlugin::new(
origin,

View File

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

View File

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

View File

@ -17,8 +17,10 @@ impl DefaultFolderBuilder {
workspace_id: String,
handlers: &FolderOperationHandlers,
) -> FolderData {
let workspace_view_builder =
Arc::new(RwLock::new(WorkspaceViewBuilder::new(workspace_id.clone())));
let workspace_view_builder = Arc::new(RwLock::new(WorkspaceViewBuilder::new(
workspace_id.clone(),
uid,
)));
for handler in handlers.values() {
let _ = handler
.create_workspace_view(uid, workspace_view_builder.clone())
@ -41,6 +43,9 @@ impl DefaultFolderBuilder {
name: "Workspace".to_string(),
child_views: RepeatedViewIdentifier::new(first_level_views),
created_at: timestamp(),
created_by: Some(uid),
last_edited_time: timestamp(),
last_edited_by: Some(uid),
};
FolderData {
@ -48,6 +53,7 @@ impl DefaultFolderBuilder {
current_view: first_view.id,
views: FlattedViews::flatten_views(views),
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.
/// The views created by this builder will be the first level views of the workspace.
pub struct WorkspaceViewBuilder {
pub uid: i64,
pub workspace_id: String,
pub views: Vec<ParentChildViews>,
}
impl WorkspaceViewBuilder {
pub fn new(workspace_id: String) -> Self {
pub fn new(workspace_id: String, uid: i64) -> Self {
Self {
uid,
workspace_id,
views: vec![],
}
@ -37,7 +39,7 @@ impl WorkspaceViewBuilder {
F: Fn(ViewBuilder) -> O,
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);
}
@ -49,6 +51,7 @@ impl WorkspaceViewBuilder {
/// A builder for creating a view.
/// The default layout of the view is [ViewLayout::Document]
pub struct ViewBuilder {
uid: i64,
parent_view_id: String,
view_id: String,
name: String,
@ -60,8 +63,9 @@ pub struct ViewBuilder {
}
impl ViewBuilder {
pub fn new(parent_view_id: String) -> Self {
pub fn new(uid: i64, parent_view_id: String) -> Self {
Self {
uid,
parent_view_id,
view_id: gen_view_id().to_string(),
name: Default::default(),
@ -99,7 +103,7 @@ impl ViewBuilder {
F: Fn(ViewBuilder) -> O,
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
}
@ -114,6 +118,8 @@ impl ViewBuilder {
is_favorite: self.is_favorite,
layout: self.layout,
icon: self.icon,
created_by: Some(self.uid),
last_edited_time: 0,
children: RepeatedViewIdentifier::new(
self
.child_views
@ -123,6 +129,7 @@ impl ViewBuilder {
})
.collect(),
),
last_edited_by: Some(self.uid),
};
ParentChildViews {
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();
View {
id: params.view_id,
@ -258,6 +265,9 @@ pub(crate) fn create_view(params: CreateViewParams, layout: ViewLayout) -> View
is_favorite: false,
layout,
icon: None,
created_by: Some(uid),
last_edited_time: 0,
last_edited_by: Some(uid),
}
}
@ -268,7 +278,7 @@ mod tests {
#[tokio::test]
async fn create_first_level_views_test() {
let workspace_id = "w1".to_string();
let mut builder = WorkspaceViewBuilder::new(workspace_id);
let mut builder = WorkspaceViewBuilder::new(workspace_id, 1);
builder
.with_view_builder(|view_builder| async { view_builder.with_name("1").build() })
.await;
@ -288,7 +298,7 @@ mod tests {
#[tokio::test]
async fn create_view_with_child_views_test() {
let workspace_id = "w1".to_string();
let mut builder = WorkspaceViewBuilder::new(workspace_id);
let mut builder = WorkspaceViewBuilder::new(workspace_id, 1);
builder
.with_view_builder(|view_builder| async {
view_builder
@ -331,7 +341,7 @@ mod tests {
#[tokio::test]
async fn create_three_level_view_test() {
let workspace_id = "w1".to_string();
let mut builder = WorkspaceViewBuilder::new(workspace_id);
let mut builder = WorkspaceViewBuilder::new(workspace_id, 1);
builder
.with_view_builder(|view_builder| async {
view_builder

View File

@ -2,9 +2,10 @@ use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use anyhow::Error;
use client_api::collab_sync::collab_msg::CollabMessage;
use client_api::notify::{TokenState, TokenStateReceiver};
use client_api::ws::{
BusinessID, ConnectState, WSClient, WSClientConfig, WSConnectStateReceiver, WebSocketChannel,
ConnectState, WSClient, WSClientConfig, WSConnectStateReceiver, WebSocketChannel,
};
use client_api::Client;
use tokio::sync::watch;
@ -50,11 +51,7 @@ impl AFCloudServer {
let token_state_rx = api_client.subscribe_token_state();
let enable_sync = Arc::new(AtomicBool::new(enable_sync));
let ws_client = WSClient::new(WSClientConfig {
buffer_capacity: 100,
ping_per_secs: 8,
retry_connect_per_pings: 6,
});
let ws_client = WSClient::new(WSClientConfig::default(), api_client.clone());
let ws_client = Arc::new(ws_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 {
if let Some(client) = weak_client.upgrade() {
match token_state {
TokenState::Refresh => match client.get_token() {
TokenState::Revoked => match client.get_token() {
Ok(token) => {
let _ = watch_tx.send(UserTokenState::Refresh { token });
},
@ -110,6 +107,7 @@ impl AppFlowyServer for AFCloudServer {
TokenState::Invalid => {
let _ = watch_tx.send(UserTokenState::Invalid);
},
TokenState::DidRefresh => {},
}
}
}
@ -142,19 +140,26 @@ impl AppFlowyServer for AFCloudServer {
Arc::new(AFCloudDocumentCloudServiceImpl(server))
}
#[allow(clippy::type_complexity)]
fn collab_ws_channel(
&self,
object_id: &str,
) -> FutureResult<Option<(Arc<WebSocketChannel>, WSConnectStateReceiver, bool)>, anyhow::Error>
{
_object_id: &str,
) -> FutureResult<
Option<(
Arc<WebSocketChannel<CollabMessage>>,
WSConnectStateReceiver,
bool,
)>,
anyhow::Error,
> {
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);
FutureResult::new(async move {
match weak_ws_client.upgrade() {
None => Ok(None),
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();
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) {
Ok(ws_addr) => {
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),
}
@ -212,8 +217,8 @@ fn spawn_ws_conn(
},
ConnectState::Unauthorized => {
if let Some(api_client) = weak_api_client.upgrade() {
if enable_sync.load(Ordering::SeqCst) {
let _ = api_client.refresh().await;
if let Err(err) = api_client.refresh_token().await {
error!("Failed to refresh token: {}", err);
}
}
},
@ -229,7 +234,7 @@ fn spawn_ws_conn(
af_spawn(async move {
while let Ok(token_state) = token_state_rx.recv().await {
match token_state {
TokenState::Refresh => {
TokenState::Revoked => {
if let (Some(api_client), Some(ws_client), Some(device_id)) = (
weak_api_client.upgrade(),
weak_ws_client.upgrade(),
@ -239,7 +244,7 @@ fn spawn_ws_conn(
match api_client.ws_url(&device_id) {
Ok(ws_addr) => {
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),
}
@ -251,6 +256,7 @@ fn spawn_ws_conn(
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,
};
use lib_infra::future::FutureResult;
use lib_infra::util::timestamp;
use crate::local_server::LocalServerDB;
@ -16,15 +15,14 @@ pub(crate) struct 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();
FutureResult::new(async move {
Ok(Workspace {
id: gen_workspace_id().to_string(),
name: name.to_string(),
child_views: Default::default(),
created_at: timestamp(),
})
Ok(Workspace::new(
gen_workspace_id().to_string(),
name.to_string(),
uid,
))
})
}

View File

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

View File

@ -13,6 +13,7 @@ use flowy_folder_deps::cloud::{
};
use lib_dispatch::prelude::af_spawn;
use lib_infra::future::FutureResult;
use lib_infra::util::timestamp;
use crate::response::ExtendedResponse;
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())
.map(|date| date.timestamp())
.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,
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));
folder.encode_collab_v1().doc_state.to_vec()
}

View File

@ -7,7 +7,7 @@ use serde::de::DeserializeOwned;
use serde::Serialize;
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";

View File

@ -10,11 +10,11 @@ use std::{fmt::Debug, io, path::Path};
pub use diesel::*;
pub use diesel_derives::*;
use crate::sqlite::PoolConfig;
pub use crate::sqlite::{ConnectionPool, DBConnection, Database};
use crate::sqlite_impl::PoolConfig;
pub use crate::sqlite_impl::{ConnectionPool, DBConnection, Database};
pub mod kv;
mod sqlite;
mod sqlite_impl;
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
where
E: Into<crate::sqlite::Error> + Debug,
E: Into<crate::sqlite_impl::Error> + Debug,
{
let msg = format!("{:?}", e);
io::Error::new(io::ErrorKind::NotConnected, msg)

View File

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

View File

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

View File

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

View File

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