Fetch profile route, push badges and status.

This commit is contained in:
Paul
2021-04-02 21:55:02 +01:00
parent 3797878d20
commit 78c42fd412
8 changed files with 56 additions and 6 deletions

View File

@@ -25,6 +25,20 @@ pub struct Relationship {
pub status: RelationshipStatus,
}
/*
pub enum Badge {
Developer = 1
}
*/
#[derive(Serialize, Deserialize, Debug)]
#[serde(tag = "type")]
pub enum UserStatus {
Text {
text: String
}
}
#[derive(Serialize, Deserialize, Debug)]
pub struct User {
#[serde(rename = "_id")]
@@ -33,6 +47,13 @@ pub struct User {
#[serde(skip_serializing_if = "Option::is_none")]
pub relations: Option<Vec<Relationship>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub badges: Option<i32>,
#[serde(skip_serializing_if = "Option::is_none")]
pub status: Option<Vec<UserStatus>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub profile: Option<String>,
// ? This should never be pushed to the collection.
#[serde(skip_serializing_if = "Option::is_none")]
pub relationship: Option<RelationshipStatus>,
@@ -65,6 +86,7 @@ impl User {
self.online = Some(is_online(&self.id));
}
self.profile = None;
self
}
@@ -73,7 +95,7 @@ impl User {
if username == "revolt" && username == "admin" {
return Ok(true)
}
if get_collection("users")
.find_one(
doc! {