feat: User profile notify (#3937)

* chore: collab rev

* feat: recv user change via websocket
This commit is contained in:
Nathan.fooo 2023-11-14 14:01:46 +08:00 committed by GitHub
parent e788c71602
commit 75c26c807c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 130 additions and 128 deletions

View File

@ -31,10 +31,14 @@ SUPABASE_ANON_KEY=
# APPFLOWY_CLOUD_WS_BASE_URL=wss://xxxxxxxxx
# APPFLOWY_CLOUD_GOTRUE_URL=https://xxxxxxxxx
#
# Local host machine(For local develop)
# APPFLOWY_CLOUD_BASE_URL=http://localhost:8000
# APPFLOWY_CLOUD_WS_BASE_URL=ws://localhost:8000/ws
# APPFLOWY_CLOUD_GOTRUE_URL=http://localhost:9998
# When using localhost for development, you must run AppFlowy Cloud locally
# first. Plese Please follow the instructions below:
# https://github.com/AppFlowy-IO/AppFlowy-Cloud#development
#
# After running AppFlowy Cloud locally, you can use the following settings:
# APPFLOWY_CLOUD_BASE_URL=http://localhost:8000
# APPFLOWY_CLOUD_WS_BASE_URL=ws://localhost:8000/ws
# APPFLOWY_CLOUD_GOTRUE_URL=http://localhost:9998
APPFLOWY_CLOUD_BASE_URL=
APPFLOWY_CLOUD_WS_BASE_URL=

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=2e14dcf129cab5e1c980655971cfb5ff321b0844#2e14dcf129cab5e1c980655971cfb5ff321b0844"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=fe977fc8285addd5386e940738cdffbbda9eb44e#fe977fc8285addd5386e940738cdffbbda9eb44e"
dependencies = [
"anyhow",
"reqwest",
@ -460,7 +460,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4114279215a005bc675e386011e594e1d9b800918cea18fcadadcce864a2046b"
dependencies = [
"borsh-derive",
"hashbrown 0.13.2",
"hashbrown 0.12.3",
]
[[package]]
@ -768,7 +768,7 @@ dependencies = [
[[package]]
name = "client-api"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=2e14dcf129cab5e1c980655971cfb5ff321b0844#2e14dcf129cab5e1c980655971cfb5ff321b0844"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=fe977fc8285addd5386e940738cdffbbda9eb44e#fe977fc8285addd5386e940738cdffbbda9eb44e"
dependencies = [
"anyhow",
"app-error",
@ -863,7 +863,7 @@ dependencies = [
[[package]]
name = "collab"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=27575c570b3a6975d2efb577367a9c56cbf5a6e1#27575c570b3a6975d2efb577367a9c56cbf5a6e1"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=da072600#da07260061c6ace8bca0bee1504f333fb8061713"
dependencies = [
"anyhow",
"async-trait",
@ -883,7 +883,7 @@ dependencies = [
[[package]]
name = "collab-database"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=27575c570b3a6975d2efb577367a9c56cbf5a6e1#27575c570b3a6975d2efb577367a9c56cbf5a6e1"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=da072600#da07260061c6ace8bca0bee1504f333fb8061713"
dependencies = [
"anyhow",
"async-trait",
@ -913,7 +913,7 @@ dependencies = [
[[package]]
name = "collab-derive"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=27575c570b3a6975d2efb577367a9c56cbf5a6e1#27575c570b3a6975d2efb577367a9c56cbf5a6e1"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=da072600#da07260061c6ace8bca0bee1504f333fb8061713"
dependencies = [
"proc-macro2",
"quote",
@ -925,7 +925,7 @@ dependencies = [
[[package]]
name = "collab-document"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=27575c570b3a6975d2efb577367a9c56cbf5a6e1#27575c570b3a6975d2efb577367a9c56cbf5a6e1"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=da072600#da07260061c6ace8bca0bee1504f333fb8061713"
dependencies = [
"anyhow",
"collab",
@ -945,7 +945,7 @@ dependencies = [
[[package]]
name = "collab-entity"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=27575c570b3a6975d2efb577367a9c56cbf5a6e1#27575c570b3a6975d2efb577367a9c56cbf5a6e1"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=da072600#da07260061c6ace8bca0bee1504f333fb8061713"
dependencies = [
"anyhow",
"bytes",
@ -959,7 +959,7 @@ dependencies = [
[[package]]
name = "collab-folder"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=27575c570b3a6975d2efb577367a9c56cbf5a6e1#27575c570b3a6975d2efb577367a9c56cbf5a6e1"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=da072600#da07260061c6ace8bca0bee1504f333fb8061713"
dependencies = [
"anyhow",
"chrono",
@ -1001,7 +1001,7 @@ dependencies = [
[[package]]
name = "collab-persistence"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=27575c570b3a6975d2efb577367a9c56cbf5a6e1#27575c570b3a6975d2efb577367a9c56cbf5a6e1"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=da072600#da07260061c6ace8bca0bee1504f333fb8061713"
dependencies = [
"anyhow",
"async-trait",
@ -1023,7 +1023,7 @@ dependencies = [
[[package]]
name = "collab-plugins"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=27575c570b3a6975d2efb577367a9c56cbf5a6e1#27575c570b3a6975d2efb577367a9c56cbf5a6e1"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=da072600#da07260061c6ace8bca0bee1504f333fb8061713"
dependencies = [
"anyhow",
"async-trait",
@ -1050,7 +1050,7 @@ dependencies = [
[[package]]
name = "collab-user"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=27575c570b3a6975d2efb577367a9c56cbf5a6e1#27575c570b3a6975d2efb577367a9c56cbf5a6e1"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=da072600#da07260061c6ace8bca0bee1504f333fb8061713"
dependencies = [
"anyhow",
"collab",
@ -1449,7 +1449,7 @@ checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308"
[[package]]
name = "database-entity"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=2e14dcf129cab5e1c980655971cfb5ff321b0844#2e14dcf129cab5e1c980655971cfb5ff321b0844"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=fe977fc8285addd5386e940738cdffbbda9eb44e#fe977fc8285addd5386e940738cdffbbda9eb44e"
dependencies = [
"anyhow",
"app-error",
@ -2090,6 +2090,7 @@ dependencies = [
"indexmap 1.9.3",
"lib-dispatch",
"lib-infra",
"lru",
"nanoid",
"parking_lot",
"protobuf",
@ -2806,7 +2807,7 @@ dependencies = [
[[package]]
name = "gotrue"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=2e14dcf129cab5e1c980655971cfb5ff321b0844#2e14dcf129cab5e1c980655971cfb5ff321b0844"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=fe977fc8285addd5386e940738cdffbbda9eb44e#fe977fc8285addd5386e940738cdffbbda9eb44e"
dependencies = [
"anyhow",
"futures-util",
@ -2822,7 +2823,7 @@ dependencies = [
[[package]]
name = "gotrue-entity"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=2e14dcf129cab5e1c980655971cfb5ff321b0844#2e14dcf129cab5e1c980655971cfb5ff321b0844"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=fe977fc8285addd5386e940738cdffbbda9eb44e#fe977fc8285addd5386e940738cdffbbda9eb44e"
dependencies = [
"anyhow",
"app-error",
@ -2916,15 +2917,6 @@ dependencies = [
"ahash 0.7.6",
]
[[package]]
name = "hashbrown"
version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e"
dependencies = [
"ahash 0.8.3",
]
[[package]]
name = "hashbrown"
version = "0.14.0"
@ -3258,7 +3250,7 @@ dependencies = [
[[package]]
name = "infra"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=2e14dcf129cab5e1c980655971cfb5ff321b0844#2e14dcf129cab5e1c980655971cfb5ff321b0844"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=fe977fc8285addd5386e940738cdffbbda9eb44e#fe977fc8285addd5386e940738cdffbbda9eb44e"
dependencies = [
"anyhow",
"reqwest",
@ -3634,11 +3626,11 @@ dependencies = [
[[package]]
name = "lru"
version = "0.10.0"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "03f1160296536f10c833a82dca22267d5486734230d47bf00bf435885814ba1e"
checksum = "1efa59af2ddfad1854ae27d75009d538d0998b4b2fd47083e743ac1a10e46c60"
dependencies = [
"hashbrown 0.13.2",
"hashbrown 0.14.0",
]
[[package]]
@ -5001,13 +4993,14 @@ dependencies = [
[[package]]
name = "realtime-entity"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=2e14dcf129cab5e1c980655971cfb5ff321b0844#2e14dcf129cab5e1c980655971cfb5ff321b0844"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=fe977fc8285addd5386e940738cdffbbda9eb44e#fe977fc8285addd5386e940738cdffbbda9eb44e"
dependencies = [
"anyhow",
"bincode",
"bytes",
"collab",
"collab-entity",
"database-entity",
"prost",
"prost-build",
"protoc-bin-vendored",
@ -5745,7 +5738,7 @@ dependencies = [
[[package]]
name = "shared_entity"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=2e14dcf129cab5e1c980655971cfb5ff321b0844#2e14dcf129cab5e1c980655971cfb5ff321b0844"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=fe977fc8285addd5386e940738cdffbbda9eb44e#fe977fc8285addd5386e940738cdffbbda9eb44e"
dependencies = [
"anyhow",
"app-error",

View File

@ -29,6 +29,7 @@ tokio = "1.34.0"
tokio-stream = "0.1.14"
async-trait = "0.1.74"
chrono = { version = "0.4.31", default-features = false, features = ["clock"] }
lru = "0.12.0"
[dependencies]
serde_json.workspace = true
@ -55,7 +56,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 = "2e14dcf129cab5e1c980655971cfb5ff321b0844" }
client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "fe977fc8285addd5386e940738cdffbbda9eb44e" }
# Please use the following script to update collab.
# Working directory: frontend
#
@ -65,14 +66,14 @@ client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "2e1
# To switch to the local path, run:
# scripts/tool/update_collab_source.sh
# ⚠️⚠️⚠️️
collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "27575c570b3a6975d2efb577367a9c56cbf5a6e1" }
collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "27575c570b3a6975d2efb577367a9c56cbf5a6e1" }
collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "27575c570b3a6975d2efb577367a9c56cbf5a6e1" }
collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "27575c570b3a6975d2efb577367a9c56cbf5a6e1" }
collab-plugins = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "27575c570b3a6975d2efb577367a9c56cbf5a6e1" }
collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "27575c570b3a6975d2efb577367a9c56cbf5a6e1" }
collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "27575c570b3a6975d2efb577367a9c56cbf5a6e1" }
collab-persistence = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "27575c570b3a6975d2efb577367a9c56cbf5a6e1" }
collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "da072600" }
collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "da072600" }
collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "da072600" }
collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "da072600" }
collab-plugins = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "da072600" }
collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "da072600" }
collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "da072600" }
collab-persistence = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "da072600" }

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=2e14dcf129cab5e1c980655971cfb5ff321b0844#2e14dcf129cab5e1c980655971cfb5ff321b0844"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=fe977fc8285addd5386e940738cdffbbda9eb44e#fe977fc8285addd5386e940738cdffbbda9eb44e"
dependencies = [
"anyhow",
"reqwest",
@ -467,7 +467,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4114279215a005bc675e386011e594e1d9b800918cea18fcadadcce864a2046b"
dependencies = [
"borsh-derive",
"hashbrown 0.13.2",
"hashbrown 0.12.3",
]
[[package]]
@ -666,7 +666,7 @@ dependencies = [
[[package]]
name = "client-api"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=2e14dcf129cab5e1c980655971cfb5ff321b0844#2e14dcf129cab5e1c980655971cfb5ff321b0844"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=fe977fc8285addd5386e940738cdffbbda9eb44e#fe977fc8285addd5386e940738cdffbbda9eb44e"
dependencies = [
"anyhow",
"app-error",
@ -730,7 +730,7 @@ dependencies = [
[[package]]
name = "collab"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=27575c570b3a6975d2efb577367a9c56cbf5a6e1#27575c570b3a6975d2efb577367a9c56cbf5a6e1"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=da072600#da07260061c6ace8bca0bee1504f333fb8061713"
dependencies = [
"anyhow",
"async-trait",
@ -750,7 +750,7 @@ dependencies = [
[[package]]
name = "collab-database"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=27575c570b3a6975d2efb577367a9c56cbf5a6e1#27575c570b3a6975d2efb577367a9c56cbf5a6e1"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=da072600#da07260061c6ace8bca0bee1504f333fb8061713"
dependencies = [
"anyhow",
"async-trait",
@ -780,7 +780,7 @@ dependencies = [
[[package]]
name = "collab-derive"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=27575c570b3a6975d2efb577367a9c56cbf5a6e1#27575c570b3a6975d2efb577367a9c56cbf5a6e1"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=da072600#da07260061c6ace8bca0bee1504f333fb8061713"
dependencies = [
"proc-macro2",
"quote",
@ -792,7 +792,7 @@ dependencies = [
[[package]]
name = "collab-document"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=27575c570b3a6975d2efb577367a9c56cbf5a6e1#27575c570b3a6975d2efb577367a9c56cbf5a6e1"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=da072600#da07260061c6ace8bca0bee1504f333fb8061713"
dependencies = [
"anyhow",
"collab",
@ -812,7 +812,7 @@ dependencies = [
[[package]]
name = "collab-entity"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=27575c570b3a6975d2efb577367a9c56cbf5a6e1#27575c570b3a6975d2efb577367a9c56cbf5a6e1"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=da072600#da07260061c6ace8bca0bee1504f333fb8061713"
dependencies = [
"anyhow",
"bytes",
@ -826,7 +826,7 @@ dependencies = [
[[package]]
name = "collab-folder"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=27575c570b3a6975d2efb577367a9c56cbf5a6e1#27575c570b3a6975d2efb577367a9c56cbf5a6e1"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=da072600#da07260061c6ace8bca0bee1504f333fb8061713"
dependencies = [
"anyhow",
"chrono",
@ -868,7 +868,7 @@ dependencies = [
[[package]]
name = "collab-persistence"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=27575c570b3a6975d2efb577367a9c56cbf5a6e1#27575c570b3a6975d2efb577367a9c56cbf5a6e1"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=da072600#da07260061c6ace8bca0bee1504f333fb8061713"
dependencies = [
"anyhow",
"async-trait",
@ -890,7 +890,7 @@ dependencies = [
[[package]]
name = "collab-plugins"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=27575c570b3a6975d2efb577367a9c56cbf5a6e1#27575c570b3a6975d2efb577367a9c56cbf5a6e1"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=da072600#da07260061c6ace8bca0bee1504f333fb8061713"
dependencies = [
"anyhow",
"async-trait",
@ -917,7 +917,7 @@ dependencies = [
[[package]]
name = "collab-user"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=27575c570b3a6975d2efb577367a9c56cbf5a6e1#27575c570b3a6975d2efb577367a9c56cbf5a6e1"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=da072600#da07260061c6ace8bca0bee1504f333fb8061713"
dependencies = [
"anyhow",
"collab",
@ -1150,7 +1150,7 @@ dependencies = [
"cssparser-macros",
"dtoa-short",
"itoa",
"phf 0.11.2",
"phf 0.8.0",
"smallvec",
]
@ -1276,7 +1276,7 @@ checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308"
[[package]]
name = "database-entity"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=2e14dcf129cab5e1c980655971cfb5ff321b0844#2e14dcf129cab5e1c980655971cfb5ff321b0844"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=fe977fc8285addd5386e940738cdffbbda9eb44e#fe977fc8285addd5386e940738cdffbbda9eb44e"
dependencies = [
"anyhow",
"app-error",
@ -1911,6 +1911,7 @@ dependencies = [
"indexmap 1.9.3",
"lib-dispatch",
"lib-infra",
"lru",
"nanoid",
"parking_lot",
"protobuf",
@ -2465,7 +2466,7 @@ dependencies = [
[[package]]
name = "gotrue"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=2e14dcf129cab5e1c980655971cfb5ff321b0844#2e14dcf129cab5e1c980655971cfb5ff321b0844"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=fe977fc8285addd5386e940738cdffbbda9eb44e#fe977fc8285addd5386e940738cdffbbda9eb44e"
dependencies = [
"anyhow",
"futures-util",
@ -2481,7 +2482,7 @@ dependencies = [
[[package]]
name = "gotrue-entity"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=2e14dcf129cab5e1c980655971cfb5ff321b0844#2e14dcf129cab5e1c980655971cfb5ff321b0844"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=fe977fc8285addd5386e940738cdffbbda9eb44e#fe977fc8285addd5386e940738cdffbbda9eb44e"
dependencies = [
"anyhow",
"app-error",
@ -2520,15 +2521,6 @@ dependencies = [
"ahash 0.7.6",
]
[[package]]
name = "hashbrown"
version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e"
dependencies = [
"ahash 0.8.3",
]
[[package]]
name = "hashbrown"
version = "0.14.0"
@ -2842,7 +2834,7 @@ dependencies = [
[[package]]
name = "infra"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=2e14dcf129cab5e1c980655971cfb5ff321b0844#2e14dcf129cab5e1c980655971cfb5ff321b0844"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=fe977fc8285addd5386e940738cdffbbda9eb44e#fe977fc8285addd5386e940738cdffbbda9eb44e"
dependencies = [
"anyhow",
"reqwest",
@ -3110,11 +3102,11 @@ checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
[[package]]
name = "lru"
version = "0.10.1"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "718e8fae447df0c7e1ba7f5189829e63fd536945c8988d61444c19039f16b670"
checksum = "1efa59af2ddfad1854ae27d75009d538d0998b4b2fd47083e743ac1a10e46c60"
dependencies = [
"hashbrown 0.13.2",
"hashbrown 0.14.0",
]
[[package]]
@ -3655,7 +3647,7 @@ version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3dfb61232e34fcb633f43d12c58f83c1df82962dcdfa565a4e866ffc17dafe12"
dependencies = [
"phf_macros 0.8.0",
"phf_macros",
"phf_shared 0.8.0",
"proc-macro-hack",
]
@ -3675,7 +3667,6 @@ version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ade2d8b8f33c7333b51bcf0428d37e217e9f32192ae4772156f65063b8ce03dc"
dependencies = [
"phf_macros 0.11.2",
"phf_shared 0.11.2",
]
@ -3743,19 +3734,6 @@ dependencies = [
"syn 1.0.109",
]
[[package]]
name = "phf_macros"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3444646e286606587e49f3bcf1679b8cef1dc2c5ecc29ddacaffc305180d464b"
dependencies = [
"phf_generator 0.11.2",
"phf_shared 0.11.2",
"proc-macro2",
"quote",
"syn 2.0.31",
]
[[package]]
name = "phf_shared"
version = "0.8.0"
@ -3959,7 +3937,7 @@ checksum = "8bdf592881d821b83d471f8af290226c8d51402259e9bb5be7f9f8bdebbb11ac"
dependencies = [
"bytes",
"heck 0.4.1",
"itertools 0.11.0",
"itertools 0.10.5",
"log",
"multimap",
"once_cell",
@ -3980,7 +3958,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "265baba7fabd416cf5078179f7d2cbeca4ce7a9041111900675ea7c4cb8a4c32"
dependencies = [
"anyhow",
"itertools 0.11.0",
"itertools 0.10.5",
"proc-macro2",
"quote",
"syn 2.0.31",
@ -4319,13 +4297,14 @@ dependencies = [
[[package]]
name = "realtime-entity"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=2e14dcf129cab5e1c980655971cfb5ff321b0844#2e14dcf129cab5e1c980655971cfb5ff321b0844"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=fe977fc8285addd5386e940738cdffbbda9eb44e#fe977fc8285addd5386e940738cdffbbda9eb44e"
dependencies = [
"anyhow",
"bincode",
"bytes",
"collab",
"collab-entity",
"database-entity",
"prost",
"prost-build",
"protoc-bin-vendored",
@ -4962,7 +4941,7 @@ dependencies = [
[[package]]
name = "shared_entity"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=2e14dcf129cab5e1c980655971cfb5ff321b0844#2e14dcf129cab5e1c980655971cfb5ff321b0844"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=fe977fc8285addd5386e940738cdffbbda9eb44e#fe977fc8285addd5386e940738cdffbbda9eb44e"
dependencies = [
"anyhow",
"app-error",

View File

@ -68,6 +68,7 @@ tokio = "1.34.0"
tokio-stream = "0.1.14"
async-trait = "0.1.74"
chrono = { version = "0.4.31", default-features = false, features = ["clock"] }
lru = "0.12.0"
[profile.dev]
opt-level = 0
@ -98,7 +99,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 = "2e14dcf129cab5e1c980655971cfb5ff321b0844" }
client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "fe977fc8285addd5386e940738cdffbbda9eb44e" }
# Please use the following script to update collab.
# Working directory: frontend
#
@ -108,11 +109,11 @@ client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "2e1
# To switch to the local path, run:
# scripts/tool/update_collab_source.sh
# ⚠️⚠️⚠️️
collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "27575c570b3a6975d2efb577367a9c56cbf5a6e1" }
collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "27575c570b3a6975d2efb577367a9c56cbf5a6e1" }
collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "27575c570b3a6975d2efb577367a9c56cbf5a6e1" }
collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "27575c570b3a6975d2efb577367a9c56cbf5a6e1" }
collab-plugins = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "27575c570b3a6975d2efb577367a9c56cbf5a6e1" }
collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "27575c570b3a6975d2efb577367a9c56cbf5a6e1" }
collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "27575c570b3a6975d2efb577367a9c56cbf5a6e1" }
collab-persistence = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "27575c570b3a6975d2efb577367a9c56cbf5a6e1" }
collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "da072600" }
collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "da072600" }
collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "da072600" }
collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "da072600" }
collab-plugins = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "da072600" }
collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "da072600" }
collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "da072600" }
collab-persistence = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "da072600" }

View File

@ -34,6 +34,7 @@ uuid.workspace = true
futures.workspace = true
tokio-stream = { workspace = true, features = ["sync"] }
scraper = "0.18.0"
lru.workspace = true
[dev-dependencies]
tempfile = "3.4.0"

View File

@ -22,9 +22,7 @@ use crate::reminder::DocumentReminderAction;
pub trait DocumentUser: Send + Sync {
fn user_id(&self) -> Result<i64, FlowyError>;
fn workspace_id(&self) -> Result<String, FlowyError>;
fn token(&self) -> Result<Option<String>, FlowyError>; // unused now.
fn collab_db(&self, uid: i64) -> Result<Weak<RocksCollabDB>, FlowyError>;
}

View File

@ -5,9 +5,10 @@ use anyhow::{anyhow, Error};
use client_api::entity::workspace_dto::{CreateWorkspaceMember, WorkspaceMemberChangeset};
use client_api::entity::{AFRole, AFWorkspace, InsertCollabParams, OAuthProvider};
use collab_entity::CollabObject;
use parking_lot::RwLock;
use flowy_error::{ErrorCode, FlowyError};
use flowy_user_deps::cloud::UserCloudService;
use flowy_user_deps::cloud::{UserCloudService, UserUpdate, UserUpdateReceiver};
use flowy_user_deps::entities::*;
use lib_infra::box_any::BoxAny;
use lib_infra::future::FutureResult;
@ -21,11 +22,15 @@ use crate::supabase::define::{USER_DEVICE_ID, USER_SIGN_IN_URL};
pub(crate) struct AFCloudUserAuthServiceImpl<T> {
server: T,
user_change_recv: RwLock<Option<tokio::sync::mpsc::Receiver<UserUpdate>>>,
}
impl<T> AFCloudUserAuthServiceImpl<T> {
pub(crate) fn new(server: T) -> Self {
Self { server }
pub(crate) fn new(server: T, user_change_recv: tokio::sync::mpsc::Receiver<UserUpdate>) -> Self {
Self {
server,
user_change_recv: RwLock::new(Some(user_change_recv)),
}
}
}
@ -212,12 +217,14 @@ where
}
fn get_user_awareness_updates(&self, _uid: i64) -> FutureResult<Vec<Vec<u8>>, Error> {
// TODO(nathan): implement the RESTful API for this
FutureResult::new(async { Ok(vec![]) })
}
fn subscribe_user_update(&self) -> Option<UserUpdateReceiver> {
self.user_change_recv.write().take()
}
fn reset_workspace(&self, _collab_object: CollabObject) -> FutureResult<(), Error> {
// TODO(nathan): implement the RESTful API for this
FutureResult::new(async { Ok(()) })
}

View File

@ -3,6 +3,7 @@ use std::sync::Arc;
use anyhow::Error;
use client_api::collab_sync::collab_msg::CollabMessage;
use client_api::entity::UserMessage;
use client_api::notify::{TokenState, TokenStateReceiver};
use client_api::ws::{
ConnectState, WSClient, WSClientConfig, WSConnectStateReceiver, WebSocketChannel,
@ -18,7 +19,7 @@ use flowy_error::{ErrorCode, FlowyError};
use flowy_folder_deps::cloud::FolderCloudService;
use flowy_server_config::af_cloud_config::AFCloudConfiguration;
use flowy_storage::FileStorageService;
use flowy_user_deps::cloud::UserCloudService;
use flowy_user_deps::cloud::{UserCloudService, UserUpdate};
use flowy_user_deps::entities::UserTokenState;
use lib_dispatch::prelude::af_spawn;
use lib_infra::future::FutureResult;
@ -119,9 +120,26 @@ impl AppFlowyServer for AFCloudServer {
info!("{} cloud sync: {}", uid, enable);
self.enable_sync.store(enable, Ordering::SeqCst);
}
fn user_service(&self) -> Arc<dyn UserCloudService> {
let server = AFServerImpl(self.get_client());
Arc::new(AFCloudUserAuthServiceImpl::new(server))
let mut user_change = self.ws_client.subscribe_user_changed();
let (tx, rx) = tokio::sync::mpsc::channel(1);
tokio::spawn(async move {
while let Ok(user_message) = user_change.recv().await {
if let UserMessage::ProfileChange(change) = user_message {
let user_update = UserUpdate {
uid: change.uid,
name: change.name,
email: change.email,
encryption_sign: "".to_string(),
};
let _ = tx.send(user_update).await;
}
}
});
Arc::new(AFCloudUserAuthServiceImpl::new(server, rx))
}
fn folder_service(&self) -> Arc<dyn FolderCloudService> {
@ -158,7 +176,7 @@ impl AppFlowyServer for AFCloudServer {
match weak_ws_client.upgrade() {
None => Ok(None),
Some(ws_client) => {
let channel = ws_client.subscribe(object_id).ok();
let channel = ws_client.subscribe_collab(object_id).ok();
let connect_state_recv = ws_client.subscribe_connect_state();
Ok(channel.map(|c| (c, connect_state_recv, ws_client.is_connected())))
},

View File

@ -43,19 +43,19 @@ use crate::AppFlowyEncryption;
pub struct SupabaseUserServiceImpl<T> {
server: T,
realtime_event_handlers: Vec<Box<dyn RealtimeEventHandler>>,
user_update_tx: Option<UserUpdateSender>,
user_update_rx: RwLock<Option<UserUpdateReceiver>>,
}
impl<T> SupabaseUserServiceImpl<T> {
pub fn new(
server: T,
realtime_event_handlers: Vec<Box<dyn RealtimeEventHandler>>,
user_update_tx: Option<UserUpdateSender>,
user_update_rx: Option<UserUpdateReceiver>,
) -> Self {
Self {
server,
realtime_event_handlers,
user_update_tx,
user_update_rx: RwLock::new(user_update_rx),
}
}
}
@ -275,7 +275,7 @@ where
}
fn subscribe_user_update(&self) -> Option<UserUpdateReceiver> {
self.user_update_tx.as_ref().map(|tx| tx.subscribe())
self.user_update_rx.write().take()
}
fn reset_workspace(&self, collab_object: CollabObject) -> FutureResult<(), Error> {
@ -531,8 +531,8 @@ impl RealtimeEventHandler for RealtimeUserHandler {
if let Ok(user_event) = serde_json::from_value::<RealtimeUserEvent>(event.new.clone()) {
let _ = self.0.send(UserUpdate {
uid: user_event.uid,
name: user_event.name,
email: user_event.email,
name: Some(user_event.name),
email: Some(user_event.email),
encryption_sign: user_event.encryption_sign,
});
}

View File

@ -137,7 +137,7 @@ impl AppFlowyServer for SupabaseServer {
fn user_service(&self) -> Arc<dyn UserCloudService> {
// handle the realtime collab update event.
let (user_update_tx, _) = tokio::sync::broadcast::channel(100);
let (user_update_tx, user_update_rx) = tokio::sync::mpsc::channel(1);
let collab_update_handler = Box::new(RealtimeCollabUpdateHandler::new(
Arc::downgrade(&self.collab_update_sender),
@ -152,7 +152,7 @@ impl AppFlowyServer for SupabaseServer {
Arc::new(SupabaseUserServiceImpl::new(
SupabaseServerServiceImpl(self.restful_postgres.clone()),
handlers,
Some(user_update_tx),
Some(user_update_rx),
))
}

View File

@ -148,13 +148,13 @@ pub trait UserCloudService: Send + Sync + 'static {
) -> FutureResult<(), Error>;
}
pub type UserUpdateReceiver = tokio::sync::broadcast::Receiver<UserUpdate>;
pub type UserUpdateSender = tokio::sync::broadcast::Sender<UserUpdate>;
pub type UserUpdateReceiver = tokio::sync::mpsc::Receiver<UserUpdate>;
pub type UserUpdateSender = tokio::sync::mpsc::Sender<UserUpdate>;
#[derive(Debug, Clone)]
pub struct UserUpdate {
pub uid: i64,
pub name: String,
pub email: String,
pub name: Option<String>,
pub email: Option<String>,
pub encryption_sign: String,
}

View File

@ -108,7 +108,7 @@ impl UserManager {
if let Ok(user_service) = user_manager.cloud_services.get_user_service() {
if let Some(mut rx) = user_service.subscribe_user_update() {
af_spawn(async move {
while let Ok(update) = rx.recv().await {
while let Some(update) = rx.recv().await {
if let Some(user_manager) = weak_user_manager.upgrade() {
if let Err(err) = user_manager.handler_user_update(update).await {
error!("handler_user_update failed: {:?}", err);
@ -526,7 +526,7 @@ impl UserManager {
// If the user profile is updated, save the new user profile
if new_user_profile.updated_at > old_user_profile.updated_at {
check_encryption_sign(old_user_profile, &new_user_profile.encryption_type.sign());
validate_encryption_sign(old_user_profile, &new_user_profile.encryption_type.sign());
// Save the new user profile
let changeset = UserTableChangeset::from_user_profile(new_user_profile);
let _ = upsert_user_profile_change(uid, self.database.get_pool(uid)?, changeset);
@ -722,7 +722,7 @@ impl UserManager {
if session.user_id == user_update.uid {
debug!("Receive user update: {:?}", user_update);
let user_profile = self.get_user_profile(user_update.uid).await?;
if !check_encryption_sign(&user_profile, &user_update.encryption_sign) {
if !validate_encryption_sign(&user_profile, &user_update.encryption_sign) {
return Ok(());
}
@ -767,7 +767,7 @@ impl UserManager {
}
}
fn check_encryption_sign(user_profile: &UserProfile, encryption_sign: &str) -> bool {
fn validate_encryption_sign(user_profile: &UserProfile, encryption_sign: &str) -> bool {
// If the local user profile's encryption sign is not equal to the user update's encryption sign,
// which means the user enable encryption in another device, we should logout the current user.
let is_valid = user_profile.encryption_type.sign() == encryption_sign;

View File

@ -120,8 +120,8 @@ impl From<UserUpdate> for UserTableChangeset {
fn from(value: UserUpdate) -> Self {
UserTableChangeset {
id: value.uid.to_string(),
name: Some(value.name),
email: Some(value.email),
name: value.name,
email: value.email,
..Default::default()
}
}