Include DM users in payload; fix permission query. + cargo fmt
This commit is contained in:
@@ -16,9 +16,5 @@ pub async fn req(user: User, target: Ref) -> Result<JsonValue> {
|
||||
Err(Error::LabelMe)?
|
||||
}
|
||||
|
||||
Ok(json!(
|
||||
target
|
||||
.from(&user)
|
||||
.with(perm)
|
||||
))
|
||||
Ok(json!(target.from(&user).with(perm)))
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
use md5;
|
||||
use mongodb::bson::doc;
|
||||
use mongodb::options::FindOneOptions;
|
||||
use rocket::response::Redirect;
|
||||
use mongodb::bson::doc;
|
||||
use urlencoding;
|
||||
use md5;
|
||||
|
||||
use crate::database::*;
|
||||
use crate::util::result::{Error, Result};
|
||||
use crate::util::variables::PUBLIC_URL;
|
||||
use crate::database::*;
|
||||
|
||||
#[get("/<target>/avatar")]
|
||||
pub async fn req(target: Ref) -> Result<Redirect> {
|
||||
@@ -17,32 +17,33 @@ pub async fn req(target: Ref) -> Result<Redirect> {
|
||||
},
|
||||
FindOneOptions::builder()
|
||||
.projection(doc! { "email": 1 })
|
||||
.build()
|
||||
.build(),
|
||||
)
|
||||
.await
|
||||
.map_err(|_| Error::DatabaseError { operation: "find_one", with: "user" })?
|
||||
.map_err(|_| Error::DatabaseError {
|
||||
operation: "find_one",
|
||||
with: "user",
|
||||
})?
|
||||
.ok_or_else(|| Error::UnknownUser)?;
|
||||
|
||||
|
||||
let email = doc
|
||||
.get_str("email")
|
||||
.map_err(|_| Error::DatabaseError { operation: "get_str(email)", with: "user" })?
|
||||
.map_err(|_| Error::DatabaseError {
|
||||
operation: "get_str(email)",
|
||||
with: "user",
|
||||
})?
|
||||
.to_lowercase();
|
||||
|
||||
let url = format!(
|
||||
"https://www.gravatar.com/avatar/{:x}?s=128&d={}",
|
||||
md5::compute(email),
|
||||
urlencoding::encode(
|
||||
&format!(
|
||||
"{}/users/{}/default_avatar",
|
||||
*PUBLIC_URL,
|
||||
&target.id
|
||||
)
|
||||
)
|
||||
);
|
||||
let url = format!(
|
||||
"https://www.gravatar.com/avatar/{:x}?s=128&d={}",
|
||||
md5::compute(email),
|
||||
urlencoding::encode(&format!(
|
||||
"{}/users/{}/default_avatar",
|
||||
*PUBLIC_URL, &target.id
|
||||
))
|
||||
);
|
||||
|
||||
dbg!(&url);
|
||||
dbg!(&url);
|
||||
|
||||
Ok(
|
||||
Redirect::to(url)
|
||||
)
|
||||
Ok(Redirect::to(url))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user