mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
chore: fix user awareness fetch (#5048)
* chore: fix user awareness fetch * chore: update * chore: update
This commit is contained in:
parent
38fe61ff69
commit
58fb529eaa
@ -35,6 +35,8 @@ class _NotificationDialogState extends State<NotificationDialog>
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
// Get all the past and upcoming reminders
|
||||
_reminderBloc.add(const ReminderEvent.started());
|
||||
_controller.addListener(_updateState);
|
||||
}
|
||||
|
||||
|
14
frontend/appflowy_tauri/src-tauri/Cargo.lock
generated
14
frontend/appflowy_tauri/src-tauri/Cargo.lock
generated
@ -833,7 +833,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "collab"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=38375ec#38375ec88ae0d05948ef245f094b1ec663d8e9b4"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4#bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
@ -857,7 +857,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "collab-database"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=38375ec#38375ec88ae0d05948ef245f094b1ec663d8e9b4"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4#bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
@ -887,7 +887,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "collab-document"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=38375ec#38375ec88ae0d05948ef245f094b1ec663d8e9b4"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4#bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"collab",
|
||||
@ -906,7 +906,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "collab-entity"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=38375ec#38375ec88ae0d05948ef245f094b1ec663d8e9b4"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4#bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bytes",
|
||||
@ -921,7 +921,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "collab-folder"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=38375ec#38375ec88ae0d05948ef245f094b1ec663d8e9b4"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4#bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"chrono",
|
||||
@ -959,7 +959,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "collab-plugins"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=38375ec#38375ec88ae0d05948ef245f094b1ec663d8e9b4"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4#bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-stream",
|
||||
@ -1037,7 +1037,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "collab-user"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=38375ec#38375ec88ae0d05948ef245f094b1ec663d8e9b4"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4#bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"collab",
|
||||
|
@ -97,10 +97,10 @@ client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "c77
|
||||
# To switch to the local path, run:
|
||||
# scripts/tool/update_collab_source.sh
|
||||
# ⚠️⚠️⚠️️
|
||||
collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "38375ec" }
|
||||
collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "38375ec" }
|
||||
collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "38375ec" }
|
||||
collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "38375ec" }
|
||||
collab-plugins = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "38375ec" }
|
||||
collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "38375ec" }
|
||||
collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "38375ec" }
|
||||
collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4" }
|
||||
collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4" }
|
||||
collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4" }
|
||||
collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4" }
|
||||
collab-plugins = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4" }
|
||||
collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4" }
|
||||
collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4" }
|
||||
|
14
frontend/appflowy_web/wasm-libs/Cargo.lock
generated
14
frontend/appflowy_web/wasm-libs/Cargo.lock
generated
@ -631,7 +631,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "collab"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=a7a990dfc62a766829d28d2a9bb383840d8146f4#a7a990dfc62a766829d28d2a9bb383840d8146f4"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4#bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
@ -655,7 +655,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "collab-document"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=a7a990dfc62a766829d28d2a9bb383840d8146f4#a7a990dfc62a766829d28d2a9bb383840d8146f4"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4#bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"collab",
|
||||
@ -674,7 +674,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "collab-entity"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=a7a990dfc62a766829d28d2a9bb383840d8146f4#a7a990dfc62a766829d28d2a9bb383840d8146f4"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4#bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bytes",
|
||||
@ -689,7 +689,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "collab-folder"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=a7a990dfc62a766829d28d2a9bb383840d8146f4#a7a990dfc62a766829d28d2a9bb383840d8146f4"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4#bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"chrono",
|
||||
@ -727,7 +727,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "collab-plugins"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=a7a990dfc62a766829d28d2a9bb383840d8146f4#a7a990dfc62a766829d28d2a9bb383840d8146f4"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4#bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-stream",
|
||||
@ -804,7 +804,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "collab-user"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=a7a990dfc62a766829d28d2a9bb383840d8146f4#a7a990dfc62a766829d28d2a9bb383840d8146f4"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4#bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"collab",
|
||||
@ -5073,4 +5073,4 @@ dependencies = [
|
||||
[[patch.unused]]
|
||||
name = "collab-database"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=a7a990dfc62a766829d28d2a9bb383840d8146f4#a7a990dfc62a766829d28d2a9bb383840d8146f4"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4#bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4"
|
||||
|
@ -65,10 +65,10 @@ client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "c77
|
||||
# To switch to the local path, run:
|
||||
# scripts/tool/update_collab_source.sh
|
||||
# ⚠️⚠️⚠️️
|
||||
collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "38375ec" }
|
||||
collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "38375ec" }
|
||||
collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "38375ec" }
|
||||
collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "38375ec" }
|
||||
collab-plugins = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "38375ec" }
|
||||
collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "38375ec" }
|
||||
collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "38375ec" }
|
||||
collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4" }
|
||||
collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4" }
|
||||
collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4" }
|
||||
collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4" }
|
||||
collab-plugins = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4" }
|
||||
collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4" }
|
||||
collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4" }
|
||||
|
@ -10,7 +10,7 @@ use collab_user::core::{MutexUserAwareness, UserAwareness};
|
||||
use flowy_error::{ErrorCode, FlowyError, FlowyResult};
|
||||
use flowy_user_pub::cloud::{UserCloudConfig, UserCloudServiceProvider};
|
||||
use flowy_user_pub::entities::{
|
||||
awareness_oid_from_user_uuid, AuthResponse, Authenticator, UserAuthResponse, UserProfile,
|
||||
user_awareness_object_id, AuthResponse, Authenticator, UserAuthResponse, UserProfile,
|
||||
UserWorkspace,
|
||||
};
|
||||
use flowy_user_pub::session::Session;
|
||||
@ -86,10 +86,6 @@ impl UserManager {
|
||||
.save_auth_data(&response, &new_user_profile, &new_session)
|
||||
.await?;
|
||||
|
||||
if let Err(err) = self.initialize_user_awareness(&new_session).await {
|
||||
error!("Failed to initialize user awareness: {:?}", err);
|
||||
}
|
||||
|
||||
for callback in self.user_callbacks.iter() {
|
||||
if let Err(e) = callback
|
||||
.did_sign_up(
|
||||
@ -133,20 +129,6 @@ impl UserManager {
|
||||
collab_builder.initialize(session.user_workspace.id.clone());
|
||||
}
|
||||
|
||||
async fn initialize_user_awareness(&self, new_session: &Session) -> FlowyResult<()> {
|
||||
let data = self
|
||||
.cloud_services
|
||||
.get_user_service()?
|
||||
.get_user_awareness_doc_state(new_session.user_id)
|
||||
.await?;
|
||||
trace!("Get user awareness collab: {}", data.len());
|
||||
let collab = self
|
||||
.collab_for_user_awareness(new_session, Arc::downgrade(&self.collab_db), data)
|
||||
.await?;
|
||||
MutexUserAwareness::new(UserAwareness::create(collab, None));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[instrument(level = "info", skip_all, err)]
|
||||
async fn save_auth_data(
|
||||
&self,
|
||||
@ -198,7 +180,8 @@ impl UserManager {
|
||||
|
||||
async fn collab_for_user_awareness(
|
||||
&self,
|
||||
session: &Session,
|
||||
uid: i64,
|
||||
object_id: &str,
|
||||
collab_db: Weak<CollabKVDB>,
|
||||
raw_data: Vec<u8>,
|
||||
) -> Result<Arc<MutexCollab>, FlowyError> {
|
||||
@ -206,11 +189,10 @@ impl UserManager {
|
||||
ErrorCode::Internal,
|
||||
"Unexpected error: collab builder is not available",
|
||||
))?;
|
||||
let user_awareness_id = awareness_oid_from_user_uuid(&session.user_uuid);
|
||||
let collab = collab_builder
|
||||
.build(
|
||||
session.user_id,
|
||||
&user_awareness_id.to_string(),
|
||||
uid,
|
||||
object_id,
|
||||
CollabType::UserAwareness,
|
||||
DocStateSource::FromDocState(raw_data),
|
||||
collab_db,
|
||||
|
14
frontend/rust-lib/Cargo.lock
generated
14
frontend/rust-lib/Cargo.lock
generated
@ -759,7 +759,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "collab"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=38375ec#38375ec88ae0d05948ef245f094b1ec663d8e9b4"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4#bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
@ -783,7 +783,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "collab-database"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=38375ec#38375ec88ae0d05948ef245f094b1ec663d8e9b4"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4#bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
@ -813,7 +813,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "collab-document"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=38375ec#38375ec88ae0d05948ef245f094b1ec663d8e9b4"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4#bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"collab",
|
||||
@ -832,7 +832,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "collab-entity"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=38375ec#38375ec88ae0d05948ef245f094b1ec663d8e9b4"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4#bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bytes",
|
||||
@ -847,7 +847,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "collab-folder"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=38375ec#38375ec88ae0d05948ef245f094b1ec663d8e9b4"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4#bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"chrono",
|
||||
@ -885,7 +885,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "collab-plugins"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=38375ec#38375ec88ae0d05948ef245f094b1ec663d8e9b4"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4#bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-stream",
|
||||
@ -963,7 +963,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "collab-user"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=38375ec#38375ec88ae0d05948ef245f094b1ec663d8e9b4"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4#bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"collab",
|
||||
|
@ -121,10 +121,10 @@ client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "c77
|
||||
# To switch to the local path, run:
|
||||
# scripts/tool/update_collab_source.sh
|
||||
# ⚠️⚠️⚠️️
|
||||
collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "38375ec" }
|
||||
collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "38375ec" }
|
||||
collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "38375ec" }
|
||||
collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "38375ec" }
|
||||
collab-plugins = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "38375ec" }
|
||||
collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "38375ec" }
|
||||
collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "38375ec" }
|
||||
collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4" }
|
||||
collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4" }
|
||||
collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4" }
|
||||
collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4" }
|
||||
collab-plugins = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4" }
|
||||
collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4" }
|
||||
collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "bb25e76d08d1fc99d5044907aa6fe1e8eabd41d4" }
|
||||
|
@ -21,7 +21,7 @@ use collab_plugins::local_storage::CollabPersistenceConfig;
|
||||
|
||||
use lib_infra::{if_native, if_wasm};
|
||||
use parking_lot::{Mutex, RwLock};
|
||||
use tracing::trace;
|
||||
use tracing::{instrument, trace};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum CollabPluginProviderType {
|
||||
@ -198,6 +198,10 @@ impl AppFlowyCollabBuilder {
|
||||
/// - `collab_db`: A weak reference to the [CollabKVDB].
|
||||
///
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
#[instrument(
|
||||
level = "trace",
|
||||
skip(self, collab_db, collab_doc_state, persistence_config, build_config)
|
||||
)]
|
||||
pub fn build_with_config(
|
||||
&self,
|
||||
uid: i64,
|
||||
@ -240,14 +244,13 @@ impl AppFlowyCollabBuilder {
|
||||
let arc_collab = Arc::new(collab);
|
||||
|
||||
{
|
||||
let collab_object = self.collab_object(uid, object_id, object_type)?;
|
||||
let collab_object = self.collab_object(uid, object_id, object_type.clone())?;
|
||||
if build_config.sync_enable {
|
||||
let provider_type = self.plugin_provider.read().provider_type();
|
||||
let span = tracing::span!(tracing::Level::TRACE, "collab_builder", object_id = %object_id);
|
||||
let _enter = span.enter();
|
||||
match provider_type {
|
||||
CollabPluginProviderType::AppFlowyCloud => {
|
||||
trace!("init appflowy cloud collab plugins");
|
||||
let local_collab = Arc::downgrade(&arc_collab);
|
||||
let plugins =
|
||||
self
|
||||
@ -295,7 +298,7 @@ impl AppFlowyCollabBuilder {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
arc_collab.lock().initialize();
|
||||
|
||||
trace!("collab initialized: {}", object_id);
|
||||
trace!("collab initialized: {}:{}", object_type, object_id);
|
||||
Ok(arc_collab)
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
use crate::util::unzip_history_user_db;
|
||||
use assert_json_diff::assert_json_include;
|
||||
use collab_database::rows::database_row_document_id_from_row_id;
|
||||
use collab_entity::CollabType;
|
||||
use event_integration::user_event::user_localhost_af_cloud;
|
||||
use event_integration::{document_data_from_document_doc_state, EventIntegrationTest};
|
||||
use flowy_core::DEFAULT_NAME;
|
||||
@ -284,13 +283,6 @@ async fn assert_040_local_2_import_content(test: &EventIntegrationTest, view_id:
|
||||
let data = test.get_document_data(&doc_1.id).await;
|
||||
assert_json_include!(actual: json!(data), expected: expected_doc_1_json());
|
||||
|
||||
// Check doc 1 remote content
|
||||
let doc_1_doc_state = test
|
||||
.get_collab_doc_state(&doc_1.id, CollabType::Document)
|
||||
.await
|
||||
.unwrap();
|
||||
assert_json_include!(actual:document_data_from_document_doc_state(&doc_1.id, doc_1_doc_state), expected: expected_doc_1_json());
|
||||
|
||||
// Check doc 2 local content
|
||||
let doc_2 = local_2_getting_started_child_views[1].clone();
|
||||
assert_eq!(doc_2.name, "Doc2");
|
||||
|
@ -22,6 +22,7 @@ async fn user_update_with_reminder() {
|
||||
object_id: "".to_string(),
|
||||
meta,
|
||||
};
|
||||
|
||||
let _ = EventBuilder::new(sdk.clone())
|
||||
.event(CreateReminder)
|
||||
.payload(payload)
|
||||
|
@ -27,7 +27,7 @@ impl CollabInteract for CollabInteractImpl {
|
||||
.handle_reminder_action(DocumentReminderAction::Add { reminder })
|
||||
.await;
|
||||
},
|
||||
Err(e) => tracing::error!("Failed to convert reminder: {:?}", e),
|
||||
Err(e) => tracing::error!("Failed to add reminder: {:?}", e),
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
@ -56,7 +56,7 @@ impl CollabInteract for CollabInteractImpl {
|
||||
.handle_reminder_action(DocumentReminderAction::Update { reminder })
|
||||
.await;
|
||||
},
|
||||
Err(e) => tracing::error!("Failed to convert reminder: {:?}", e),
|
||||
Err(e) => tracing::error!("Failed to update reminder: {:?}", e),
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
@ -1,6 +1,5 @@
|
||||
use collab_entity::reminder::Reminder;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::json;
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub enum DocumentReminderAction {
|
||||
@ -18,6 +17,8 @@ impl TryFrom<Reminder> for DocumentReminder {
|
||||
type Error = serde_json::Error;
|
||||
|
||||
fn try_from(value: Reminder) -> Result<Self, Self::Error> {
|
||||
serde_json::from_value(json!(value.meta.into_inner()))
|
||||
Ok(Self {
|
||||
document_id: value.object_id,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -5,9 +5,12 @@ use anyhow::anyhow;
|
||||
use client_api::entity::workspace_dto::{
|
||||
CreateWorkspaceMember, CreateWorkspaceParam, PatchWorkspaceParam, WorkspaceMemberChangeset,
|
||||
};
|
||||
use client_api::entity::{AFRole, AFWorkspace, AuthProvider, CollabParams, CreateCollabParams};
|
||||
use client_api::entity::{
|
||||
AFRole, AFWorkspace, AuthProvider, CollabParams, CreateCollabParams, QueryCollab,
|
||||
QueryCollabParams,
|
||||
};
|
||||
use client_api::{Client, ClientConfiguration};
|
||||
use collab_entity::CollabObject;
|
||||
use collab_entity::{CollabObject, CollabType};
|
||||
use parking_lot::RwLock;
|
||||
|
||||
use flowy_error::{ErrorCode, FlowyError, FlowyResult};
|
||||
@ -238,8 +241,27 @@ where
|
||||
})
|
||||
}
|
||||
|
||||
fn get_user_awareness_doc_state(&self, _uid: i64) -> FutureResult<Vec<u8>, FlowyError> {
|
||||
FutureResult::new(async { Ok(vec![]) })
|
||||
fn get_user_awareness_doc_state(
|
||||
&self,
|
||||
_uid: i64,
|
||||
workspace_id: &str,
|
||||
object_id: &str,
|
||||
) -> FutureResult<Vec<u8>, FlowyError> {
|
||||
let workspace_id = workspace_id.to_string();
|
||||
let object_id = object_id.to_string();
|
||||
let try_get_client = self.server.try_get_client();
|
||||
FutureResult::new(async {
|
||||
let params = QueryCollabParams {
|
||||
workspace_id,
|
||||
inner: QueryCollab {
|
||||
object_id,
|
||||
collab_type: CollabType::UserAwareness,
|
||||
},
|
||||
};
|
||||
|
||||
let resp = try_get_client?.get_collab(params).await?;
|
||||
Ok(resp.doc_state.to_vec())
|
||||
})
|
||||
}
|
||||
|
||||
fn subscribe_user_update(&self) -> Option<UserUpdateReceiver> {
|
||||
|
@ -148,8 +148,14 @@ impl UserCloudService for LocalServerUserAuthServiceImpl {
|
||||
FutureResult::new(async { Ok(vec![]) })
|
||||
}
|
||||
|
||||
fn get_user_awareness_doc_state(&self, _uid: i64) -> FutureResult<Vec<u8>, FlowyError> {
|
||||
FutureResult::new(async { Ok(vec![]) })
|
||||
fn get_user_awareness_doc_state(
|
||||
&self,
|
||||
_uid: i64,
|
||||
_workspace_id: &str,
|
||||
_object_id: &str,
|
||||
) -> FutureResult<Vec<u8>, FlowyError> {
|
||||
// must return record not found error
|
||||
FutureResult::new(async { Err(FlowyError::record_not_found()) })
|
||||
}
|
||||
|
||||
fn reset_workspace(&self, _collab_object: CollabObject) -> FutureResult<(), FlowyError> {
|
||||
|
@ -249,16 +249,21 @@ where
|
||||
})
|
||||
}
|
||||
|
||||
fn get_user_awareness_doc_state(&self, uid: i64) -> FutureResult<Vec<u8>, FlowyError> {
|
||||
fn get_user_awareness_doc_state(
|
||||
&self,
|
||||
_uid: i64,
|
||||
_workspace_id: &str,
|
||||
object_id: &str,
|
||||
) -> FutureResult<Vec<u8>, FlowyError> {
|
||||
let try_get_postgrest = self.server.try_get_weak_postgrest();
|
||||
let awareness_id = uid.to_string();
|
||||
let (tx, rx) = channel();
|
||||
let object_id = object_id.to_string();
|
||||
af_spawn(async move {
|
||||
tx.send(
|
||||
async move {
|
||||
let postgrest = try_get_postgrest?;
|
||||
let action =
|
||||
FetchObjectUpdateAction::new(awareness_id, CollabType::UserAwareness, postgrest);
|
||||
FetchObjectUpdateAction::new(object_id, CollabType::UserAwareness, postgrest);
|
||||
action.run_with_fix_interval(3, 3).await
|
||||
}
|
||||
.await,
|
||||
|
@ -212,7 +212,12 @@ pub trait UserCloudService: Send + Sync + 'static {
|
||||
FutureResult::new(async { Ok(vec![]) })
|
||||
}
|
||||
|
||||
fn get_user_awareness_doc_state(&self, uid: i64) -> FutureResult<Vec<u8>, FlowyError>;
|
||||
fn get_user_awareness_doc_state(
|
||||
&self,
|
||||
uid: i64,
|
||||
workspace_id: &str,
|
||||
object_id: &str,
|
||||
) -> FutureResult<Vec<u8>, FlowyError>;
|
||||
|
||||
fn receive_realtime_event(&self, _json: Value) {}
|
||||
|
||||
|
@ -396,6 +396,10 @@ pub struct WorkspaceMember {
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
pub fn awareness_oid_from_user_uuid(user_uuid: &Uuid) -> Uuid {
|
||||
Uuid::new_v5(user_uuid, b"user_awareness")
|
||||
/// represent the user awareness object id for the workspace.
|
||||
pub fn user_awareness_object_id(user_uuid: &Uuid, workspace_id: &str) -> Uuid {
|
||||
Uuid::new_v5(
|
||||
user_uuid,
|
||||
format!("user_awareness:{}", workspace_id).as_bytes(),
|
||||
)
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ use lib_infra::box_any::BoxAny;
|
||||
use serde_json::Value;
|
||||
use std::sync::Weak;
|
||||
use std::{convert::TryInto, sync::Arc};
|
||||
use tracing::event;
|
||||
use tracing::{event, trace};
|
||||
|
||||
use crate::entities::*;
|
||||
use crate::notification::{send_notification, UserNotification};
|
||||
@ -562,6 +562,8 @@ pub async fn get_all_reminder_event_handler(
|
||||
.into_iter()
|
||||
.map(ReminderPB::from)
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
trace!("number of reminders: {}", reminders.len());
|
||||
data_result_ok(reminders.into())
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ use flowy_folder_pub::entities::{AppFlowyData, ImportData};
|
||||
use flowy_folder_pub::folder_builder::{ParentChildViews, ViewBuilder};
|
||||
use flowy_sqlite::kv::StorePreferences;
|
||||
use flowy_user_pub::cloud::{UserCloudService, UserCollabParams};
|
||||
use flowy_user_pub::entities::{awareness_oid_from_user_uuid, Authenticator};
|
||||
use flowy_user_pub::entities::{user_awareness_object_id, Authenticator};
|
||||
use flowy_user_pub::session::Session;
|
||||
use parking_lot::{Mutex, RwLock};
|
||||
use std::collections::{HashMap, HashSet};
|
||||
@ -128,8 +128,13 @@ pub(crate) fn import_appflowy_data_folder(
|
||||
all_imported_object_ids.retain(|id| id != &imported_session.user_workspace.id);
|
||||
all_imported_object_ids
|
||||
.retain(|id| id != &imported_session.user_workspace.workspace_database_object_id);
|
||||
all_imported_object_ids
|
||||
.retain(|id| id != &awareness_oid_from_user_uuid(&imported_session.user_uuid).to_string());
|
||||
all_imported_object_ids.retain(|id| {
|
||||
id != &user_awareness_object_id(
|
||||
&imported_session.user_uuid,
|
||||
&imported_session.user_workspace.id,
|
||||
)
|
||||
.to_string()
|
||||
});
|
||||
|
||||
// import database view tracker
|
||||
migrate_database_view_tracker(
|
||||
|
@ -13,7 +13,7 @@ use flowy_user_pub::entities::*;
|
||||
use flowy_user_pub::workspace_service::UserWorkspaceService;
|
||||
use serde_json::Value;
|
||||
use std::string::ToString;
|
||||
use std::sync::atomic::{AtomicI64, Ordering};
|
||||
use std::sync::atomic::{AtomicBool, AtomicI64, Ordering};
|
||||
use std::sync::{Arc, Weak};
|
||||
use tokio::sync::{Mutex, RwLock};
|
||||
use tokio_stream::StreamExt;
|
||||
@ -37,7 +37,6 @@ use crate::services::data_import::importer::import_data;
|
||||
use crate::services::data_import::ImportContext;
|
||||
|
||||
use crate::services::sqlite_sql::user_sql::{select_user_profile, UserTable, UserTableChangeset};
|
||||
use crate::user_manager::manager_user_awareness::UserAwarenessDataSource;
|
||||
use crate::user_manager::manager_user_encryption::validate_encryption_sign;
|
||||
use crate::user_manager::manager_user_workspace::save_user_workspaces;
|
||||
use crate::user_manager::user_login_state::UserAuthProcess;
|
||||
@ -55,6 +54,7 @@ pub struct UserManager {
|
||||
auth_process: Mutex<Option<UserAuthProcess>>,
|
||||
pub(crate) authenticate_user: Arc<AuthenticateUser>,
|
||||
refresh_user_profile_since: AtomicI64,
|
||||
pub(crate) is_loading_awareness: Arc<AtomicBool>,
|
||||
}
|
||||
|
||||
impl UserManager {
|
||||
@ -80,6 +80,7 @@ impl UserManager {
|
||||
authenticate_user,
|
||||
refresh_user_profile_since,
|
||||
user_workspace_service,
|
||||
is_loading_awareness: Arc::new(AtomicBool::new(false)),
|
||||
});
|
||||
|
||||
let weak_user_manager = Arc::downgrade(&user_manager);
|
||||
@ -252,9 +253,7 @@ impl UserManager {
|
||||
self.authenticate_user.vacuum_database_if_need();
|
||||
let cloud_config = get_cloud_config(session.user_id, &self.store_preferences);
|
||||
// Init the user awareness
|
||||
self
|
||||
.initialize_user_awareness(&session, UserAwarenessDataSource::Local)
|
||||
.await;
|
||||
self.initialize_user_awareness(&session).await;
|
||||
|
||||
user_status_callback
|
||||
.did_init(
|
||||
@ -324,10 +323,7 @@ impl UserManager {
|
||||
.save_auth_data(&response, &authenticator, &session)
|
||||
.await?;
|
||||
|
||||
let _ = self
|
||||
.initialize_user_awareness(&session, UserAwarenessDataSource::Remote)
|
||||
.await;
|
||||
|
||||
let _ = self.initialize_user_awareness(&session).await;
|
||||
self
|
||||
.user_status_callback
|
||||
.read()
|
||||
@ -412,12 +408,6 @@ impl UserManager {
|
||||
) -> FlowyResult<()> {
|
||||
let new_session = Session::from(&response);
|
||||
self.prepare_user(&new_session).await;
|
||||
|
||||
let user_awareness_source = if response.is_new_user {
|
||||
UserAwarenessDataSource::Local
|
||||
} else {
|
||||
UserAwarenessDataSource::Remote
|
||||
};
|
||||
self
|
||||
.save_auth_data(&response, authenticator, &new_session)
|
||||
.await?;
|
||||
@ -433,10 +423,6 @@ impl UserManager {
|
||||
)
|
||||
.await?;
|
||||
|
||||
self
|
||||
.initialize_user_awareness(&new_session, user_awareness_source)
|
||||
.await;
|
||||
|
||||
if response.is_new_user {
|
||||
if let Some(old_user) = migration_user {
|
||||
event!(
|
||||
|
@ -1,16 +1,17 @@
|
||||
use std::sync::atomic::Ordering;
|
||||
use std::sync::{Arc, Weak};
|
||||
|
||||
use anyhow::Context;
|
||||
use collab::core::collab::{DocStateSource, MutexCollab};
|
||||
use collab_entity::reminder::Reminder;
|
||||
use collab_entity::CollabType;
|
||||
use collab_integrate::collab_builder::CollabBuilderConfig;
|
||||
use collab_integrate::collab_builder::{AppFlowyCollabBuilder, CollabBuilderConfig};
|
||||
use collab_user::core::{MutexUserAwareness, UserAwareness};
|
||||
use tracing::{error, instrument, trace};
|
||||
use tracing::{error, info, instrument, trace};
|
||||
|
||||
use collab_integrate::CollabKVDB;
|
||||
use flowy_error::{ErrorCode, FlowyError, FlowyResult};
|
||||
use flowy_user_pub::entities::awareness_oid_from_user_uuid;
|
||||
use flowy_user_pub::entities::user_awareness_object_id;
|
||||
|
||||
use crate::entities::ReminderPB;
|
||||
use crate::user_manager::UserManager;
|
||||
@ -99,12 +100,8 @@ impl UserManager {
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn initialize_user_awareness(
|
||||
&self,
|
||||
session: &Session,
|
||||
source: UserAwarenessDataSource,
|
||||
) {
|
||||
match self.try_initial_user_awareness(session, source).await {
|
||||
pub async fn initialize_user_awareness(&self, session: &Session) {
|
||||
match self.try_initial_user_awareness(session).await {
|
||||
Ok(_) => trace!("User awareness initialized"),
|
||||
Err(e) => error!("Failed to initialize user awareness: {:?}", e),
|
||||
}
|
||||
@ -123,35 +120,77 @@ impl UserManager {
|
||||
/// # Returns
|
||||
/// - Returns `Ok(())` if the user's awareness is successfully initialized.
|
||||
/// - May return errors of type `FlowyError` if any issues arise during the initialization.
|
||||
#[instrument(level = "info", skip(self, session, source), err)]
|
||||
async fn try_initial_user_awareness(
|
||||
&self,
|
||||
session: &Session,
|
||||
source: UserAwarenessDataSource,
|
||||
) -> FlowyResult<()> {
|
||||
trace!("Initializing user awareness from {:?}", source);
|
||||
#[instrument(level = "info", skip(self, session), err)]
|
||||
async fn try_initial_user_awareness(&self, session: &Session) -> FlowyResult<()> {
|
||||
if self.is_loading_awareness.load(Ordering::SeqCst) {
|
||||
return Ok(());
|
||||
}
|
||||
self.is_loading_awareness.store(true, Ordering::SeqCst);
|
||||
|
||||
let object_id =
|
||||
user_awareness_object_id(&session.user_uuid, &session.user_workspace.id).to_string();
|
||||
trace!("Initializing user awareness {}", object_id);
|
||||
let collab_db = self.get_collab_db(session.user_id)?;
|
||||
let user_awareness = match source {
|
||||
UserAwarenessDataSource::Local => {
|
||||
let collab = self
|
||||
.collab_for_user_awareness(session, collab_db, vec![])
|
||||
let weak_cloud_services = Arc::downgrade(&self.cloud_services);
|
||||
let weak_user_awareness = Arc::downgrade(&self.user_awareness);
|
||||
let weak_builder = self.collab_builder.clone();
|
||||
let weak_is_loading_awareness = Arc::downgrade(&self.is_loading_awareness);
|
||||
let session = session.clone();
|
||||
tokio::spawn(async move {
|
||||
if let (Some(cloud_services), Some(user_awareness)) =
|
||||
(weak_cloud_services.upgrade(), weak_user_awareness.upgrade())
|
||||
{
|
||||
let result = cloud_services
|
||||
.get_user_service()?
|
||||
.get_user_awareness_doc_state(session.user_id, &session.user_workspace.id, &object_id)
|
||||
.await;
|
||||
|
||||
if let Some(is_loading_awareness) = weak_is_loading_awareness.upgrade() {
|
||||
is_loading_awareness.store(false, Ordering::SeqCst);
|
||||
}
|
||||
|
||||
let awareness = match result {
|
||||
Ok(data) => {
|
||||
trace!("Get user awareness collab from remote: {}", data.len());
|
||||
let collab = Self::collab_for_user_awareness(
|
||||
&weak_builder,
|
||||
session.user_id,
|
||||
&object_id,
|
||||
collab_db,
|
||||
DocStateSource::FromDocState(data),
|
||||
)
|
||||
.await?;
|
||||
MutexUserAwareness::new(UserAwareness::create(collab, None))
|
||||
},
|
||||
UserAwarenessDataSource::Remote => {
|
||||
let data = self
|
||||
.cloud_services
|
||||
.get_user_service()?
|
||||
.get_user_awareness_doc_state(session.user_id)
|
||||
.await?;
|
||||
trace!("Get user awareness collab: {}", data.len());
|
||||
let collab = self
|
||||
.collab_for_user_awareness(session, collab_db, data)
|
||||
Err(err) => {
|
||||
if err.is_record_not_found() {
|
||||
info!("User awareness not found, creating new");
|
||||
let collab = Self::collab_for_user_awareness(
|
||||
&weak_builder,
|
||||
session.user_id,
|
||||
&object_id,
|
||||
collab_db,
|
||||
DocStateSource::FromDisk,
|
||||
)
|
||||
.await?;
|
||||
MutexUserAwareness::new(UserAwareness::create(collab, None))
|
||||
} else {
|
||||
error!("Failed to fetch user awareness: {:?}", err);
|
||||
return Err(err);
|
||||
}
|
||||
},
|
||||
};
|
||||
self.user_awareness.lock().await.replace(user_awareness);
|
||||
|
||||
user_awareness.lock().await.replace(awareness);
|
||||
Ok(())
|
||||
} else {
|
||||
if let Some(is_loading_awareness) = weak_is_loading_awareness.upgrade() {
|
||||
is_loading_awareness.store(false, Ordering::SeqCst);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
});
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -161,22 +200,22 @@ impl UserManager {
|
||||
/// using a collaboration builder. This instance is specifically geared towards handling
|
||||
/// user awareness.
|
||||
async fn collab_for_user_awareness(
|
||||
&self,
|
||||
session: &Session,
|
||||
collab_builder: &Weak<AppFlowyCollabBuilder>,
|
||||
uid: i64,
|
||||
object_id: &str,
|
||||
collab_db: Weak<CollabKVDB>,
|
||||
doc_state: Vec<u8>,
|
||||
doc_state: DocStateSource,
|
||||
) -> Result<Arc<MutexCollab>, FlowyError> {
|
||||
let collab_builder = self.collab_builder.upgrade().ok_or(FlowyError::new(
|
||||
let collab_builder = collab_builder.upgrade().ok_or(FlowyError::new(
|
||||
ErrorCode::Internal,
|
||||
"Unexpected error: collab builder is not available",
|
||||
))?;
|
||||
let user_awareness_id = awareness_oid_from_user_uuid(&session.user_uuid);
|
||||
let collab = collab_builder
|
||||
.build(
|
||||
session.user_id,
|
||||
&user_awareness_id.to_string(),
|
||||
uid,
|
||||
object_id,
|
||||
CollabType::UserAwareness,
|
||||
DocStateSource::FromDocState(doc_state),
|
||||
doc_state,
|
||||
collab_db,
|
||||
CollabBuilderConfig::default().sync_enable(true),
|
||||
)
|
||||
@ -204,9 +243,7 @@ impl UserManager {
|
||||
match &*user_awareness {
|
||||
None => {
|
||||
if let Ok(session) = self.get_session() {
|
||||
self
|
||||
.initialize_user_awareness(&session, UserAwarenessDataSource::Remote)
|
||||
.await;
|
||||
self.initialize_user_awareness(&session).await;
|
||||
}
|
||||
default_value
|
||||
},
|
||||
@ -214,12 +251,3 @@ impl UserManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Indicate using which data source to initialize the user awareness
|
||||
/// If the user is not a new user, the local data source is used. Otherwise, the remote data source is used.
|
||||
/// When using the remote data source, the user awareness will be initialized from the remote server.
|
||||
#[derive(Debug)]
|
||||
pub enum UserAwarenessDataSource {
|
||||
Local,
|
||||
Remote,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user