flowy_server.rs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. use flowy_user::{
  2. entities::{SignInParams, SignUpParams, UserDetail},
  3. errors::{ErrorBuilder, UserError, UserErrorCode},
  4. prelude::UserServer,
  5. sql_tables::UserTable,
  6. };
  7. pub type ArcFlowyServer = std::sync::Arc<dyn FlowyServer>;
  8. pub trait FlowyServer: UserServer {}
  9. pub struct FlowyServerMocker {}
  10. impl FlowyServer for FlowyServerMocker {}
  11. impl UserServer for FlowyServerMocker {
  12. fn sign_up(&self, params: SignUpParams) -> Result<UserTable, UserError> {
  13. let user_id = params.email.clone();
  14. Ok(UserTable::new(
  15. user_id,
  16. params.name,
  17. params.email,
  18. params.password,
  19. ))
  20. }
  21. fn sign_in(&self, params: SignInParams) -> Result<UserTable, UserError> {
  22. let user_id = params.email.clone();
  23. Ok(UserTable::new(
  24. user_id,
  25. "".to_owned(),
  26. params.email,
  27. params.password,
  28. ))
  29. }
  30. fn get_user_info(&self, _user_id: &str) -> Result<UserDetail, UserError> {
  31. Err(ErrorBuilder::new(UserErrorCode::Unknown).build())
  32. }
  33. fn sign_out(&self, _user_id: &str) -> Result<(), UserError> {
  34. Err(ErrorBuilder::new(UserErrorCode::Unknown).build())
  35. }
  36. }