feat: Chat request implementation #14

Manually merged
awiteb merged 55 commits from awiteb/chat-request-and-response into master 2024-07-18 14:21:39 +02:00 AGit
Showing only changes of commit 033a21f733 - Show all commits

View file

@ -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)
}
} }