Fix block user route, send correct user struct.
Add route for fetching members. Cargo fmt on accident.
This commit is contained in:
@@ -14,7 +14,7 @@ use validator::Validate;
|
||||
#[derive(Serialize, Deserialize, FromFormValue)]
|
||||
pub enum Sort {
|
||||
Latest,
|
||||
Oldest
|
||||
Oldest,
|
||||
}
|
||||
|
||||
#[derive(Validate, Serialize, Deserialize, FromForm)]
|
||||
@@ -25,7 +25,7 @@ pub struct Options {
|
||||
before: Option<String>,
|
||||
#[validate(length(min = 26, max = 26))]
|
||||
after: Option<String>,
|
||||
sort: Option<Sort>
|
||||
sort: Option<Sort>,
|
||||
}
|
||||
|
||||
#[get("/<target>/messages?<options..>")]
|
||||
@@ -54,7 +54,11 @@ pub async fn req(user: User, target: Ref, options: Form<Options>) -> Result<Json
|
||||
query.insert("_id", doc! { "$gt": after });
|
||||
}
|
||||
|
||||
let sort = if let Sort::Latest = options.sort.as_ref().unwrap_or_else(|| &Sort::Latest) { -1 } else { 1 };
|
||||
let sort = if let Sort::Latest = options.sort.as_ref().unwrap_or_else(|| &Sort::Latest) {
|
||||
-1
|
||||
} else {
|
||||
1
|
||||
};
|
||||
let mut cursor = get_collection("messages")
|
||||
.find(
|
||||
query,
|
||||
|
||||
Reference in New Issue
Block a user