mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-14 00:26:51 +08:00
fix: user id is now string, we need to get default on local
This commit is contained in:
@@ -16,6 +16,7 @@ pub fn invoke_handler() -> impl Fn(tauri::Invoke) + Send + Sync + 'static {
|
||||
get_workspaces,
|
||||
get_workspace,
|
||||
create_user,
|
||||
get_user,
|
||||
create_doc,
|
||||
get_doc,
|
||||
put_blob,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use cloud_database::{CreateUser, User};
|
||||
use ipc_types::document::CreateDocumentParameter;
|
||||
use ipc_types::{document::CreateDocumentParameter, user::GetUserParameters};
|
||||
|
||||
use crate::state::AppState;
|
||||
|
||||
@@ -18,7 +18,7 @@ pub async fn create_user<'s>(
|
||||
.metadata_db
|
||||
.create_user(parameters.clone())
|
||||
.await;
|
||||
match new_user_result{
|
||||
match new_user_result {
|
||||
Ok(new_user_option) => match new_user_option {
|
||||
Some((new_user, new_workspace)) => {
|
||||
// a new private workspace is created, we have to create a yDoc for it
|
||||
@@ -38,3 +38,16 @@ pub async fn create_user<'s>(
|
||||
Err(error_message) => Err(error_message.to_string()),
|
||||
}
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
/// get the only one user in local sqlite
|
||||
pub async fn get_user<'s>(
|
||||
state: tauri::State<'s, AppState>,
|
||||
parameters: GetUserParameters,
|
||||
) -> Result<User, String> {
|
||||
let db = &state.0.lock().await.metadata_db;
|
||||
match db.get_user_by_email(¶meters.email).await.ok().unwrap() {
|
||||
Some(user) => Ok(user),
|
||||
None => Err("User not found".to_string()),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,14 @@ use cloud_database::{CreateUser, User};
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
|
||||
pub struct GetUserParameters {
|
||||
pub email: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
|
||||
pub enum IUserParameters {
|
||||
CreateUser(CreateUser),
|
||||
User(User),
|
||||
GetUserParameters(GetUserParameters),
|
||||
}
|
||||
|
||||
@@ -14,8 +14,7 @@ pub struct CreateWorkspace {
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
|
||||
pub struct GetWorkspaces {
|
||||
// TODO: make all id string, on Octobase side, and rewrite all related tests
|
||||
pub user_id: i32,
|
||||
pub user_id: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
|
||||
|
||||
Reference in New Issue
Block a user