2023-07-29 09:46:24 +08:00
|
|
|
use anyhow::Error;
|
2023-10-02 17:22:22 +08:00
|
|
|
use client_api::entity::QueryCollabParams;
|
|
|
|
|
use client_api::error::ErrorCode::RecordNotFound;
|
2023-09-13 22:11:51 +08:00
|
|
|
use collab_define::CollabType;
|
2023-07-29 09:46:24 +08:00
|
|
|
|
|
|
|
|
use flowy_database_deps::cloud::{
|
2023-07-14 13:37:13 +08:00
|
|
|
CollabObjectUpdate, CollabObjectUpdateByOid, DatabaseCloudService, DatabaseSnapshot,
|
|
|
|
|
};
|
2023-07-05 20:57:09 +08:00
|
|
|
use lib_infra::future::FutureResult;
|
|
|
|
|
|
2023-09-17 17:14:34 +08:00
|
|
|
use crate::af_cloud::AFServer;
|
2023-07-05 20:57:09 +08:00
|
|
|
|
2023-09-17 17:14:34 +08:00
|
|
|
pub(crate) struct AFCloudDatabaseCloudServiceImpl<T>(pub T);
|
|
|
|
|
|
|
|
|
|
impl<T> DatabaseCloudService for AFCloudDatabaseCloudServiceImpl<T>
|
|
|
|
|
where
|
|
|
|
|
T: AFServer,
|
|
|
|
|
{
|
2023-07-29 09:46:24 +08:00
|
|
|
fn get_collab_update(
|
|
|
|
|
&self,
|
2023-10-02 17:22:22 +08:00
|
|
|
object_id: &str,
|
|
|
|
|
collab_type: CollabType,
|
2023-07-29 09:46:24 +08:00
|
|
|
) -> FutureResult<CollabObjectUpdate, Error> {
|
2023-10-02 17:22:22 +08:00
|
|
|
let object_id = object_id.to_string();
|
|
|
|
|
let try_get_client = self.0.try_get_client();
|
|
|
|
|
FutureResult::new(async move {
|
|
|
|
|
let params = QueryCollabParams {
|
|
|
|
|
object_id,
|
|
|
|
|
collab_type,
|
|
|
|
|
};
|
|
|
|
|
match try_get_client?.get_collab(params).await {
|
|
|
|
|
Ok(data) => Ok(vec![data]),
|
|
|
|
|
Err(err) => {
|
|
|
|
|
if err.code == RecordNotFound {
|
|
|
|
|
Ok(vec![])
|
|
|
|
|
} else {
|
|
|
|
|
Err(Error::new(err))
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
})
|
2023-07-05 20:57:09 +08:00
|
|
|
}
|
|
|
|
|
|
2023-07-14 13:37:13 +08:00
|
|
|
fn batch_get_collab_updates(
|
2023-07-05 20:57:09 +08:00
|
|
|
&self,
|
2023-07-14 13:37:13 +08:00
|
|
|
_object_ids: Vec<String>,
|
2023-07-29 09:46:24 +08:00
|
|
|
_object_ty: CollabType,
|
|
|
|
|
) -> FutureResult<CollabObjectUpdateByOid, Error> {
|
2023-07-14 13:37:13 +08:00
|
|
|
FutureResult::new(async move { Ok(CollabObjectUpdateByOid::default()) })
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-17 23:46:39 +08:00
|
|
|
fn get_collab_snapshots(
|
2023-07-14 13:37:13 +08:00
|
|
|
&self,
|
|
|
|
|
_object_id: &str,
|
2023-08-17 23:46:39 +08:00
|
|
|
_limit: usize,
|
|
|
|
|
) -> FutureResult<Vec<DatabaseSnapshot>, Error> {
|
|
|
|
|
FutureResult::new(async move { Ok(vec![]) })
|
2023-07-05 20:57:09 +08:00
|
|
|
}
|
|
|
|
|
}
|