feat: Chat request implementation #14
1 changed files with 31 additions and 0 deletions
|
@ -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,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue