mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
feat: migrate user data to cloud (#3078)
* refactor: weak passed-in params in handler * refactor: rename struct * chore: update tables * chore: update schema * chore: add permission * chore: update tables * chore: support transaction mode * chore: workspace database id * chore: add user workspace * feat: return list of workspaces * chore: add user to workspace * feat: separate database row table * refactor: update schema * chore: partition table * chore: use transaction * refactor: dir * refactor: collab db ref * fix: collab db lock * chore: rename files * chore: add tables descriptions * chore: update readme * docs: update documentation * chore: rename crate * chore: update ref * chore: update tests * chore: update tests * refactor: crate deps * chore: update crate ref * chore: remove unused deps * chore: remove unused deps * chore: update collab crate refs * chore: replace client with transaction in pooler * refactor: return error type * refactor: use anyhow error in deps * feat: supabase postgrest user signin (wip) * fix: Cargo.toml source git deps, changed Error to anyhow::Error * fix: uuid serialization * chore: fix conflict * chore: extend the response * feat: add implementation place holders * feat: impl get_user_workspaces * feat: impl get_user_profile * test: create workspace * fix: postgrest: field names and alias * chore: implement folder restful api * chore: implement collab storate with restful api * feat: added placeholders for impl: update_user_profile, check_user * feat: impl: update_user_profile * feat: impl: check_user * fix: use UidResponse, add more debug info for serde serialization error * fix: get_user_profile: use Optional<UserProfileResponse> * chore: imple init sync * chore: support soft delete * feat: postgresql: add migration test * feat: postgresql migration test: added UID display and colored output * feat: postgresql migration test: workspace role * feat: postgresql migration test: create shared common utils * feat: postgresql migration test: fixed shebang * chore: add flush_collab_update pg function * chore: implement datbaase and document restful api * chore: migrate to use restful api * chore: update table schema * chore: fix tests * chore: remove unused code * chore: format code * chore: remove unused env * fix: tauri build * fix: tauri build --------- Co-authored-by: Fu Zi Xiang <speed2exe@live.com.sg>
This commit is contained in:
@ -19,8 +19,9 @@ use flowy_folder2::entities::*;
|
||||
use flowy_folder2::event_map::FolderEvent;
|
||||
use flowy_notification::entities::SubscribeObject;
|
||||
use flowy_notification::{register_notification_sender, NotificationSender};
|
||||
use flowy_server::supabase::define::{USER_EMAIL, USER_UUID};
|
||||
use flowy_user::entities::{AuthTypePB, ThirdPartyAuthPB, UserProfilePB};
|
||||
use flowy_user::errors::FlowyError;
|
||||
use flowy_user::errors::{FlowyError, FlowyResult};
|
||||
use flowy_user::event_map::UserEvent::*;
|
||||
|
||||
use crate::event_builder::EventBuilder;
|
||||
@ -42,8 +43,10 @@ pub struct FlowyCoreTest {
|
||||
impl Default for FlowyCoreTest {
|
||||
fn default() -> Self {
|
||||
let temp_dir = temp_dir();
|
||||
let config = AppFlowyCoreConfig::new(temp_dir.to_str().unwrap(), nanoid!(6))
|
||||
.log_filter("debug", vec!["flowy_test".to_string()]);
|
||||
let config = AppFlowyCoreConfig::new(temp_dir.to_str().unwrap(), nanoid!(6)).log_filter(
|
||||
"info",
|
||||
vec!["flowy_test".to_string(), "lib_dispatch".to_string()],
|
||||
);
|
||||
|
||||
let inner = std::thread::spawn(|| AppFlowyCore::new(config))
|
||||
.join()
|
||||
@ -108,9 +111,17 @@ impl FlowyCoreTest {
|
||||
self.sign_up_as_guest().await.user_profile
|
||||
}
|
||||
|
||||
pub async fn sign_up_with_uuid(&self, uuid: &str) -> UserProfilePB {
|
||||
pub async fn third_party_sign_up_with_uuid(
|
||||
&self,
|
||||
uuid: &str,
|
||||
email: Option<String>,
|
||||
) -> FlowyResult<UserProfilePB> {
|
||||
let mut map = HashMap::new();
|
||||
map.insert("uuid".to_string(), uuid.to_string());
|
||||
map.insert(USER_UUID.to_string(), uuid.to_string());
|
||||
map.insert(
|
||||
USER_EMAIL.to_string(),
|
||||
email.unwrap_or_else(|| format!("{}@appflowy.io", nanoid!(10))),
|
||||
);
|
||||
let payload = ThirdPartyAuthPB {
|
||||
map,
|
||||
auth_type: AuthTypePB::Supabase,
|
||||
@ -121,11 +132,11 @@ impl FlowyCoreTest {
|
||||
.payload(payload)
|
||||
.async_send()
|
||||
.await
|
||||
.parse::<UserProfilePB>();
|
||||
.try_parse::<UserProfilePB>()?;
|
||||
|
||||
let user_path = PathBuf::from(&self.config.storage_path).join(user_profile.id.to_string());
|
||||
*self.cleaner.write() = Some(Cleaner::new(user_path));
|
||||
user_profile
|
||||
Ok(user_profile)
|
||||
}
|
||||
|
||||
// Must sign up/ sign in first
|
||||
@ -702,16 +713,18 @@ impl TestNotificationSender {
|
||||
Self::default()
|
||||
}
|
||||
|
||||
pub fn subscribe<T>(&self, id: &str) -> tokio::sync::mpsc::Receiver<T>
|
||||
pub fn subscribe<T>(&self, id: &str, ty: impl Into<i32> + Send) -> tokio::sync::mpsc::Receiver<T>
|
||||
where
|
||||
T: TryFrom<Bytes, Error = ProtobufError> + Send + 'static,
|
||||
{
|
||||
let id = id.to_string();
|
||||
let (tx, rx) = tokio::sync::mpsc::channel::<T>(10);
|
||||
let mut receiver = self.sender.subscribe();
|
||||
let ty = ty.into();
|
||||
tokio::spawn(async move {
|
||||
// DatabaseNotification::DidUpdateDatabaseSnapshotState
|
||||
while let Ok(value) = receiver.recv().await {
|
||||
if value.id == id {
|
||||
if value.id == id && value.ty == ty {
|
||||
if let Some(payload) = value.payload {
|
||||
if let Ok(object) = T::try_from(Bytes::from(payload)) {
|
||||
let _ = tx.send(object).await;
|
||||
|
Reference in New Issue
Block a user