Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d5fde35651
|
||
|
|
34c47ac529 | ||
|
|
e5ae5e1828 |
@@ -1,4 +1,5 @@
|
|||||||
pub mod config;
|
pub mod config;
|
||||||
pub mod contact;
|
pub mod contact;
|
||||||
|
pub mod message;
|
||||||
pub mod token;
|
pub mod token;
|
||||||
pub mod user;
|
pub mod user;
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
||||||
|
pub struct Message {
|
||||||
|
pub id: uuid::Uuid,
|
||||||
|
pub content: String,
|
||||||
|
pub user_id: uuid::Uuid,
|
||||||
|
}
|
||||||
+36
-4
@@ -28,6 +28,14 @@ pub struct ServiceUser {
|
|||||||
pub last_login: Option<time::OffsetDateTime>,
|
pub last_login: Option<time::OffsetDateTime>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
||||||
|
pub struct Organization {
|
||||||
|
pub id: uuid::Uuid,
|
||||||
|
pub name: String,
|
||||||
|
#[serde(with = "time::serde::rfc3339::option")]
|
||||||
|
pub created: Option<time::OffsetDateTime>,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
||||||
pub struct UserLoginHistory {
|
pub struct UserLoginHistory {
|
||||||
pub id: uuid::Uuid,
|
pub id: uuid::Uuid,
|
||||||
@@ -51,12 +59,14 @@ pub struct UserProfile {
|
|||||||
pub username: String,
|
pub username: String,
|
||||||
pub firstname: String,
|
pub firstname: String,
|
||||||
pub lastname: String,
|
pub lastname: String,
|
||||||
|
#[serde(with = "time::serde::rfc3339::option")]
|
||||||
pub created: Option<time::OffsetDateTime>,
|
pub created: Option<time::OffsetDateTime>,
|
||||||
|
#[serde(with = "time::serde::rfc3339::option")]
|
||||||
pub last_login: Option<time::OffsetDateTime>,
|
pub last_login: Option<time::OffsetDateTime>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn init_user_profile(usr: &User) -> UserProfile {
|
pub fn init_user_profile(usr: &User) -> UserProfile {
|
||||||
let usr_profile = UserProfile {
|
UserProfile {
|
||||||
user_id: usr.id,
|
user_id: usr.id,
|
||||||
phone_number: usr.phone_number.clone(),
|
phone_number: usr.phone_number.clone(),
|
||||||
username: usr.username.clone(),
|
username: usr.username.clone(),
|
||||||
@@ -64,7 +74,29 @@ pub fn init_user_profile(usr: &User) -> UserProfile {
|
|||||||
lastname: usr.lastname.clone(),
|
lastname: usr.lastname.clone(),
|
||||||
created: usr.created,
|
created: usr.created,
|
||||||
last_login: usr.last_login,
|
last_login: usr.last_login,
|
||||||
};
|
}
|
||||||
|
}
|
||||||
usr_profile
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
#[test]
|
||||||
|
fn test_init_user_profile() {
|
||||||
|
let usr = super::User {
|
||||||
|
id: uuid::Uuid::new_v4(),
|
||||||
|
phone_number: String::from("+12308438462"),
|
||||||
|
username: String::from("Cowboy99"),
|
||||||
|
password: String::from("238n7cyr2q89d3xhe2"),
|
||||||
|
firstname: String::from("BillyBob"),
|
||||||
|
lastname: String::from("Jones"),
|
||||||
|
created: Some(time::OffsetDateTime::now_utc()),
|
||||||
|
last_login: Some(time::OffsetDateTime::now_utc()),
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
|
||||||
|
let profile = super::init_user_profile(&usr);
|
||||||
|
assert_eq!(
|
||||||
|
usr.phone_number, profile.phone_number,
|
||||||
|
"Phone numbers are not equal"
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user