removed identicon avatars
This commit is contained in:
parent
03eb2c9da9
commit
72aba16667
5 changed files with 2 additions and 318 deletions
|
|
@ -10,7 +10,6 @@ rocket_dyn_templates = { version = "=0.1.0-rc.3", features = ["tera"] }
|
|||
infer = { version = "0.13", default-features = false }
|
||||
erased-serde = "0.3"
|
||||
url = { workspace = true }
|
||||
identicon-rs = "4.0"
|
||||
futures = "0.3"
|
||||
base64 = "0.21.0"
|
||||
rocket_cors = "0.6.0-alpha2"
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ impl Default for CacheControl {
|
|||
// 60 secs * 60 minutes
|
||||
duration_secs: 60 * 60,
|
||||
types: vec![ContentType::CSS, ContentType::JavaScript],
|
||||
routes: vec!["/logo", "/avatar/"],
|
||||
routes: vec!["/logo"],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
use super::prelude::*;
|
||||
use avatar::*;
|
||||
use home::*;
|
||||
use logo::*;
|
||||
use logout::*;
|
||||
|
||||
pub mod avatar;
|
||||
pub mod home;
|
||||
pub mod logo;
|
||||
pub mod logout;
|
||||
|
|
@ -12,7 +10,6 @@ pub mod logout;
|
|||
pub fn routes() -> Vec<Route> {
|
||||
routes![
|
||||
get_logo,
|
||||
user_avatar,
|
||||
homepage,
|
||||
homepage_user,
|
||||
homepage_redirect,
|
||||
|
|
|
|||
|
|
@ -1,34 +0,0 @@
|
|||
use crate::routes::prelude::*;
|
||||
use rocket::get;
|
||||
use users::User;
|
||||
|
||||
#[get("/avatar/<user_id>?<size>")]
|
||||
pub async fn user_avatar(
|
||||
mut db: Connection<Database>,
|
||||
_user: JwtUser,
|
||||
user_id: RocketUserID,
|
||||
size: Option<u32>,
|
||||
) -> Result<FileFromBytes> {
|
||||
// Verify existence of user
|
||||
User::get_by_login(&mut *db, user_id.0.as_ref())
|
||||
.await?
|
||||
.ok_or_else(|| Error::not_found(user_id.0.to_string()))?;
|
||||
|
||||
// Generate avatar
|
||||
let avatar = task::spawn_blocking(move || {
|
||||
let mut avatar = identicon_rs::Identicon::new(user_id.0);
|
||||
|
||||
// Set optional size
|
||||
if let Some(size) = size {
|
||||
avatar.set_scale(size)?;
|
||||
}
|
||||
|
||||
avatar.export_png_data()
|
||||
})
|
||||
.await?;
|
||||
|
||||
// HTTP response
|
||||
avatar
|
||||
.map(FileFromBytes::from)
|
||||
.map_err(Error::internal_server_error)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue