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 b02e2d8b4d - Show all commits

View file

@ -14,7 +14,11 @@
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://gnu.org/licenses/agpl-3.0>. // along with this program. If not, see <https://gnu.org/licenses/agpl-3.0>.
use std::str::FromStr;
use chrono::{DateTime, Utc};
use oxidetalis_core::{cipher::K256Secret, types::PublicKey}; use oxidetalis_core::{cipher::K256Secret, types::PublicKey};
use oxidetalis_entities::prelude::*;
use salvo::oapi::ToSchema; use salvo::oapi::ToSchema;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@ -25,3 +29,30 @@ pub struct RegisterUserBody {
/// The public key of the user /// The public key of the user
pub public_key: PublicKey, pub public_key: PublicKey,
} }
#[derive(Serialize, Deserialize, Clone, Debug, ToSchema, derive_new::new)]
#[salvo(schema(name = WhiteListedUser, example = json!(WhiteListedUser::default())))]
pub struct WhiteListedUser {
/// User's public key
pub public_key: PublicKey,
/// When the user was whitelisted
pub whitelisted_at: DateTime<Utc>,
}
impl Default for WhiteListedUser {
fn default() -> Self {
WhiteListedUser::new(
PublicKey::from_str("bYhbrm61ov8GLZfskUYbsCLJTfaacMsuTBYgBABEH9dy").expect("is valid"),
Utc::now(),
)
}
}
impl From<WhitelistModel> for WhiteListedUser {
fn from(user: WhitelistModel) -> Self {
Self {
public_key: PublicKey::from_str(&user.target).expect("Is valid public key"),
whitelisted_at: user.whitelisted_at,
}
}
}