mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-08-04 14:57:27 +00:00

* feat: implement encrypt and decrypt * feat: encrypt and decrypt * feat: update user profile with encrypt * chore: store encryption sign * fix: login in setting menu * chore: show encryption account name * chore: fix test * ci: fix warnings * test: enable supabase test * chore: fix test and rename column * fix: update user profile after set the secret * fix: encryption with wrong secret * fix: don't save user data if the return value of did_sign_up is err * chore: encrypt snapshot data * chore: refactor snapshots interface * ci: add tests * chore: update collab rev
60 lines
1.6 KiB
Rust
60 lines
1.6 KiB
Rust
use std::sync::Arc;
|
|
|
|
use anyhow::Error;
|
|
|
|
use flowy_folder_deps::cloud::{
|
|
gen_workspace_id, FolderCloudService, FolderData, FolderSnapshot, Workspace,
|
|
};
|
|
use lib_infra::future::FutureResult;
|
|
use lib_infra::util::timestamp;
|
|
|
|
use crate::local_server::LocalServerDB;
|
|
|
|
pub(crate) struct LocalServerFolderCloudServiceImpl {
|
|
pub db: Arc<dyn LocalServerDB>,
|
|
}
|
|
|
|
impl FolderCloudService for LocalServerFolderCloudServiceImpl {
|
|
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(),
|
|
})
|
|
})
|
|
}
|
|
|
|
fn get_folder_data(&self, _workspace_id: &str) -> FutureResult<Option<FolderData>, Error> {
|
|
FutureResult::new(async move { Ok(None) })
|
|
}
|
|
|
|
fn get_folder_snapshots(
|
|
&self,
|
|
_workspace_id: &str,
|
|
_limit: usize,
|
|
) -> FutureResult<Vec<FolderSnapshot>, Error> {
|
|
FutureResult::new(async move { Ok(vec![]) })
|
|
}
|
|
|
|
fn get_folder_updates(&self, workspace_id: &str, uid: i64) -> FutureResult<Vec<Vec<u8>>, Error> {
|
|
let weak_db = Arc::downgrade(&self.db);
|
|
let workspace_id = workspace_id.to_string();
|
|
FutureResult::new(async move {
|
|
match weak_db.upgrade() {
|
|
None => Ok(vec![]),
|
|
Some(db) => {
|
|
let updates = db.get_collab_updates(uid, &workspace_id)?;
|
|
Ok(updates)
|
|
},
|
|
}
|
|
})
|
|
}
|
|
|
|
fn service_name(&self) -> String {
|
|
"Local".to_string()
|
|
}
|
|
}
|