mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
7f44b181bd
* chore: update client-api rev * chore: update collab rev id * feat: add sign_in_request and import shared entity * feat: added to userworkspace from af_workspace * chore: add script to update the client-api rev id * chore: update client-api rev * feat: add workspaces api * feat: added check user * chore: config * chore: update client_api version * chore: ws connect * chore: ws connect * chore: update crate versions * chore: rename event * chore: update client-appi * chore: set appflowy cloud env * chore: add env template * chore: update env name * docs: update docs * fix: check_user * feat: impl sign_in_with_url * feat: add file storage placeholders * chore: update client-api * chore: disable test * feat: impl workspace add and remove * chore: sign up test * feat: select cover image on upload (#3488) * fix: close popover after item selection in settings view (#3362) * fix: close popover after item selection in settings view * fix: add missing await before closing popover * fix: find popover container by context instead of passing controllers around * fix: add requested changes * feat: close text direction settings popups after selection * fix: clean up * fix: restore theme value dropdown as StatefulWidget * feat: openai and stabilityai integration (#3439) * chore: create trait * test: add tests * chore: remove log * chore: disable log * chore: checklist ux flow redesign (#3418) * chore: ux flow redesign * chore: remove unused imports * fix: allow creation of tasks of the same name * chore: apply code suggestions from Mathias * fix: add padding below field title text field (#3440) * Fixed Issue no #3426 * Reversed the pubspec.lock mistaken update * FIXED PADDING * Fixed Padding issue on calender field edit popup * chore: rename package name (#3501) * fix: right icon size sam as left one (#3494) * feat: enable removing user icon (#3487) * feat: enable removing user icon * fix: generate to true * fix: review comments * fix: more review comments * fix: integration test and final changes * fix: made cursor grab and background color when hovering on Appearance Options Buttons (#3498) * chore: calendar UI polish (#3484) * chore: update calendar theming * feat: add event popup editor * chore: new event button redesign and add card shadows * chore: unscheduled events button * chore: event title text field * fix: focus node double dispose * chore: show popover when create new event * test: integrate some tests for integration testing purposes * fix: some fixes and more integration tests * chore: add more space between font item and font menu * feat: add reset font button in toolbar * feat: only show text direction toolbar item when RTL is enabled * fix: unable to change RTL of heading block * test: add integration test for ltr/rtl mode * chore: update inlang project settings (#3441) * feat: using script to update the collab source. (#3508) * chore: add script * chore: update script * chore: update bytes version * chore: submit lock file * chore: update test * chore: update test * chore: bump version * chore: update * ci: fix * ci: fix * chore: update commit id * chore: update commit id * chore: update commit id * fix: is cloud enable --------- Co-authored-by: Fu Zi Xiang <speed2exe@live.com.sg> Co-authored-by: Mathias Mogensen <42929161+Xazin@users.noreply.github.com> Co-authored-by: Vincenzo De Petris <37916223+vincendep@users.noreply.github.com> Co-authored-by: Richard Shiue <71320345+richardshiue@users.noreply.github.com> Co-authored-by: Aryan More <61151896+aryan-more@users.noreply.github.com> Co-authored-by: Lucas.Xu <lucas.xu@appflowy.io> Co-authored-by: Lakhan Baheti <94619783+1akhanBaheti@users.noreply.github.com> Co-authored-by: Nitin-Poojary <70025277+Nitin-Poojary@users.noreply.github.com> Co-authored-by: Jannes Blobel <72493222+jannesblobel@users.noreply.github.com>
162 lines
5.4 KiB
Rust
162 lines
5.4 KiB
Rust
use std::collections::HashMap;
|
|
use std::sync::Arc;
|
|
|
|
use collab::core::collab::MutexCollab;
|
|
use collab::core::origin::CollabOrigin;
|
|
use collab_plugins::cloud_storage::RemoteCollabStorage;
|
|
use uuid::Uuid;
|
|
|
|
use flowy_database_deps::cloud::DatabaseCloudService;
|
|
use flowy_error::FlowyError;
|
|
use flowy_folder_deps::cloud::{Folder, FolderCloudService};
|
|
use flowy_server::supabase::api::{
|
|
RESTfulPostgresServer, SupabaseCollabStorageImpl, SupabaseDatabaseServiceImpl,
|
|
SupabaseFolderServiceImpl, SupabaseServerServiceImpl, SupabaseUserServiceImpl,
|
|
};
|
|
use flowy_server::supabase::define::{USER_DEVICE_ID, USER_EMAIL, USER_UUID};
|
|
use flowy_server::supabase::file_storage::core::SupabaseFileStorage;
|
|
use flowy_server::{AppFlowyEncryption, EncryptionImpl};
|
|
use flowy_server_config::supabase_config::SupabaseConfiguration;
|
|
use flowy_storage::{FileStoragePlan, FileStorageService, StorageObject};
|
|
use flowy_user_deps::cloud::UserCloudService;
|
|
use lib_infra::future::FutureResult;
|
|
|
|
use crate::setup_log;
|
|
|
|
pub fn get_supabase_ci_config() -> Option<SupabaseConfiguration> {
|
|
dotenv::from_filename("./.env.ci").ok()?;
|
|
setup_log();
|
|
SupabaseConfiguration::from_env().ok()
|
|
}
|
|
|
|
#[allow(dead_code)]
|
|
pub fn get_supabase_dev_config() -> Option<SupabaseConfiguration> {
|
|
dotenv::from_filename("./.env.dev").ok()?;
|
|
setup_log();
|
|
SupabaseConfiguration::from_env().ok()
|
|
}
|
|
|
|
pub fn collab_service() -> Arc<dyn RemoteCollabStorage> {
|
|
let (server, encryption_impl) = supabase_server_service(None);
|
|
Arc::new(SupabaseCollabStorageImpl::new(
|
|
server,
|
|
None,
|
|
Arc::downgrade(&encryption_impl),
|
|
))
|
|
}
|
|
|
|
pub fn database_service() -> Arc<dyn DatabaseCloudService> {
|
|
let (server, _encryption_impl) = supabase_server_service(None);
|
|
Arc::new(SupabaseDatabaseServiceImpl::new(server))
|
|
}
|
|
|
|
pub fn user_auth_service() -> Arc<dyn UserCloudService> {
|
|
let (server, _encryption_impl) = supabase_server_service(None);
|
|
Arc::new(SupabaseUserServiceImpl::new(server, vec![], None))
|
|
}
|
|
|
|
pub fn folder_service() -> Arc<dyn FolderCloudService> {
|
|
let (server, _encryption_impl) = supabase_server_service(None);
|
|
Arc::new(SupabaseFolderServiceImpl::new(server))
|
|
}
|
|
|
|
pub fn file_storage_service() -> Arc<dyn FileStorageService> {
|
|
let encryption_impl: Arc<dyn AppFlowyEncryption> = Arc::new(EncryptionImpl::new(None));
|
|
let config = SupabaseConfiguration::from_env().unwrap();
|
|
Arc::new(
|
|
SupabaseFileStorage::new(
|
|
&config,
|
|
Arc::downgrade(&encryption_impl),
|
|
Arc::new(TestFileStoragePlan),
|
|
)
|
|
.unwrap(),
|
|
)
|
|
}
|
|
|
|
#[allow(dead_code)]
|
|
pub fn encryption_folder_service(
|
|
secret: Option<String>,
|
|
) -> (Arc<dyn FolderCloudService>, Arc<dyn AppFlowyEncryption>) {
|
|
let (server, encryption_impl) = supabase_server_service(secret);
|
|
let service = Arc::new(SupabaseFolderServiceImpl::new(server));
|
|
(service, encryption_impl)
|
|
}
|
|
|
|
#[allow(dead_code)]
|
|
pub fn encryption_collab_service(
|
|
secret: Option<String>,
|
|
) -> (Arc<dyn RemoteCollabStorage>, Arc<dyn AppFlowyEncryption>) {
|
|
let (server, encryption_impl) = supabase_server_service(secret);
|
|
let service = Arc::new(SupabaseCollabStorageImpl::new(
|
|
server,
|
|
None,
|
|
Arc::downgrade(&encryption_impl),
|
|
));
|
|
(service, encryption_impl)
|
|
}
|
|
|
|
#[allow(dead_code)]
|
|
pub async fn print_encryption_folder(folder_id: &str, encryption_secret: Option<String>) {
|
|
let (cloud_service, _encryption) = encryption_folder_service(encryption_secret);
|
|
let folder_data = cloud_service.get_folder_data(folder_id).await.unwrap();
|
|
let json = serde_json::to_value(folder_data).unwrap();
|
|
println!("{}", serde_json::to_string_pretty(&json).unwrap());
|
|
}
|
|
|
|
#[allow(dead_code)]
|
|
pub async fn print_encryption_folder_snapshot(folder_id: &str, encryption_secret: Option<String>) {
|
|
let (cloud_service, _encryption) = encryption_collab_service(encryption_secret);
|
|
let snapshot = cloud_service
|
|
.get_snapshots(folder_id, 1)
|
|
.await
|
|
.pop()
|
|
.unwrap();
|
|
let collab = Arc::new(
|
|
MutexCollab::new_with_raw_data(CollabOrigin::Empty, folder_id, vec![snapshot.blob], vec![])
|
|
.unwrap(),
|
|
);
|
|
let folder_data = Folder::open(collab, None).get_folder_data().unwrap();
|
|
let json = serde_json::to_value(folder_data).unwrap();
|
|
println!("{}", serde_json::to_string_pretty(&json).unwrap());
|
|
}
|
|
|
|
pub fn supabase_server_service(
|
|
encryption_secret: Option<String>,
|
|
) -> (SupabaseServerServiceImpl, Arc<dyn AppFlowyEncryption>) {
|
|
let config = SupabaseConfiguration::from_env().unwrap();
|
|
let encryption_impl: Arc<dyn AppFlowyEncryption> =
|
|
Arc::new(EncryptionImpl::new(encryption_secret));
|
|
let encryption = Arc::downgrade(&encryption_impl);
|
|
let server = Arc::new(RESTfulPostgresServer::new(config, encryption));
|
|
(SupabaseServerServiceImpl::new(server), encryption_impl)
|
|
}
|
|
|
|
pub fn third_party_sign_up_param(uuid: String) -> HashMap<String, String> {
|
|
let mut params = HashMap::new();
|
|
params.insert(USER_UUID.to_string(), uuid);
|
|
params.insert(
|
|
USER_EMAIL.to_string(),
|
|
format!("{}@test.com", Uuid::new_v4()),
|
|
);
|
|
params.insert(USER_DEVICE_ID.to_string(), Uuid::new_v4().to_string());
|
|
params
|
|
}
|
|
|
|
pub struct TestFileStoragePlan;
|
|
|
|
impl FileStoragePlan for TestFileStoragePlan {
|
|
fn storage_size(&self) -> FutureResult<u64, FlowyError> {
|
|
// 1 GB
|
|
FutureResult::new(async { Ok(1024 * 1024 * 1024) })
|
|
}
|
|
|
|
fn maximum_file_size(&self) -> FutureResult<u64, FlowyError> {
|
|
// 5 MB
|
|
FutureResult::new(async { Ok(5 * 1024 * 1024) })
|
|
}
|
|
|
|
fn check_upload_object(&self, _object: &StorageObject) -> FutureResult<(), FlowyError> {
|
|
FutureResult::new(async { Ok(()) })
|
|
}
|
|
}
|