2023-05-21 18:53:59 +08:00
|
|
|
use std::sync::Arc;
|
|
|
|
|
2023-08-12 17:36:31 +08:00
|
|
|
use collab_plugins::cloud_storage::{CollabObject, RemoteCollabStorage};
|
2023-08-17 23:46:39 +08:00
|
|
|
use parking_lot::RwLock;
|
2023-07-05 20:57:09 +08:00
|
|
|
|
2023-07-29 09:46:24 +08:00
|
|
|
use flowy_database_deps::cloud::DatabaseCloudService;
|
|
|
|
use flowy_document_deps::cloud::DocumentCloudService;
|
|
|
|
use flowy_folder_deps::cloud::FolderCloudService;
|
|
|
|
use flowy_user_deps::cloud::UserService;
|
2023-05-21 18:53:59 +08:00
|
|
|
|
|
|
|
pub mod local_server;
|
|
|
|
mod request;
|
|
|
|
mod response;
|
|
|
|
pub mod self_host;
|
|
|
|
pub mod supabase;
|
2023-07-05 20:57:09 +08:00
|
|
|
pub mod util;
|
2023-05-21 18:53:59 +08:00
|
|
|
|
2023-08-17 23:46:39 +08:00
|
|
|
pub trait AppFlowyEncryption: Send + Sync + 'static {
|
|
|
|
fn get_secret(&self) -> Option<String>;
|
|
|
|
fn set_secret(&self, secret: String);
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<T> AppFlowyEncryption for Arc<T>
|
|
|
|
where
|
|
|
|
T: AppFlowyEncryption,
|
|
|
|
{
|
|
|
|
fn get_secret(&self) -> Option<String> {
|
|
|
|
(**self).get_secret()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_secret(&self, secret: String) {
|
|
|
|
(**self).set_secret(secret)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-21 18:53:59 +08:00
|
|
|
pub trait AppFlowyServer: Send + Sync + 'static {
|
2023-08-17 23:46:39 +08:00
|
|
|
fn set_enable_sync(&self, _enable: bool) {}
|
2023-07-29 09:46:24 +08:00
|
|
|
fn user_service(&self) -> Arc<dyn UserService>;
|
2023-05-23 23:55:21 +08:00
|
|
|
fn folder_service(&self) -> Arc<dyn FolderCloudService>;
|
2023-07-05 20:57:09 +08:00
|
|
|
fn database_service(&self) -> Arc<dyn DatabaseCloudService>;
|
|
|
|
fn document_service(&self) -> Arc<dyn DocumentCloudService>;
|
2023-08-12 17:36:31 +08:00
|
|
|
fn collab_storage(&self, collab_object: &CollabObject) -> Option<Arc<dyn RemoteCollabStorage>>;
|
2023-05-21 18:53:59 +08:00
|
|
|
}
|
2023-08-17 23:46:39 +08:00
|
|
|
|
|
|
|
pub struct EncryptionImpl {
|
|
|
|
secret: RwLock<Option<String>>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl EncryptionImpl {
|
|
|
|
pub fn new(secret: Option<String>) -> Self {
|
|
|
|
Self {
|
|
|
|
secret: RwLock::new(secret),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl AppFlowyEncryption for EncryptionImpl {
|
|
|
|
fn get_secret(&self) -> Option<String> {
|
|
|
|
self.secret.read().clone()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_secret(&self, secret: String) {
|
|
|
|
*self.secret.write() = Some(secret);
|
|
|
|
}
|
|
|
|
}
|