feat: Chat request implementation #14
1 changed files with 11 additions and 0 deletions
|
@ -28,6 +28,8 @@ pub trait UserTableExt {
|
||||||
async fn users_exists_in_database(&self) -> ApiResult<bool>;
|
async fn users_exists_in_database(&self) -> ApiResult<bool>;
|
||||||
/// Register new user
|
/// Register new user
|
||||||
async fn register_user(&self, public_key: &PublicKey, is_admin: bool) -> ApiResult<()>;
|
async fn register_user(&self, public_key: &PublicKey, is_admin: bool) -> ApiResult<()>;
|
||||||
|
/// Returns user by its public key
|
||||||
|
async fn get_user_by_pubk(&self, public_key: &PublicKey) -> ApiResult<Option<UserModel>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl UserTableExt for DatabaseConnection {
|
impl UserTableExt for DatabaseConnection {
|
||||||
|
@ -57,4 +59,13 @@ impl UserTableExt for DatabaseConnection {
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[logcall]
|
||||||
|
async fn get_user_by_pubk(&self, public_key: &PublicKey) -> ApiResult<Option<UserModel>> {
|
||||||
|
UserEntity::find()
|
||||||
|
.filter(UserColumn::PublicKey.eq(public_key.to_string()))
|
||||||
|
.one(self)
|
||||||
|
.await
|
||||||
|
.map_err(ApiError::SeaOrm)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue