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
2 changed files with 3 additions and 3 deletions
Showing only changes of commit abbdec49e7 - Show all commits

View file

@ -53,7 +53,7 @@ impl UserTableExt for DatabaseConnection {
.await
{
if let Some(SqlErr::UniqueConstraintViolation(_)) = err.sql_err() {
return Err(ApiError::DuplicatedUser);
return Err(ApiError::AlreadyRegistered);
}
}

View file

@ -48,7 +48,7 @@ pub enum ApiError {
RegistrationClosed,
/// The entered public key is already registered (400 Bad Request)
#[error("The entered public key is already registered")]
DuplicatedUser,
AlreadyRegistered,
/// The user entered two different public keys
/// one in the header and other in the request body
/// (400 Bad Request)
@ -62,7 +62,7 @@ impl ApiError {
match self {
Self::SeaOrm(_) => StatusCode::INTERNAL_SERVER_ERROR,
Self::RegistrationClosed => StatusCode::FORBIDDEN,
Self::DuplicatedUser | Self::TwoDifferentKeys => StatusCode::BAD_REQUEST,
Self::AlreadyRegistered | Self::TwoDifferentKeys => StatusCode::BAD_REQUEST,
}
}
}