chore (backend-rs): reduce identicon size
This commit is contained in:
parent
2c35a3885c
commit
a5f950b468
2 changed files with 15 additions and 4 deletions
|
@ -28,7 +28,11 @@ pub enum Error {
|
|||
|
||||
impl Follow {
|
||||
#[allow(dead_code)] // TODO: remove this line
|
||||
fn new(follower: UserLike, followee: UserLike, request_id: Option<String>) -> Result<Self, Error> {
|
||||
fn new(
|
||||
follower: UserLike,
|
||||
followee: UserLike,
|
||||
request_id: Option<String>,
|
||||
) -> Result<Self, Error> {
|
||||
Ok(Self {
|
||||
id: request_id.unwrap_or_else(|| {
|
||||
format!("{}/follows/{}/{}", CONFIG.url, follower.id, followee.id)
|
||||
|
@ -61,7 +65,11 @@ impl Follow {
|
|||
}
|
||||
|
||||
#[macros::ts_export]
|
||||
pub fn render_follow(follower: UserLike, followee: UserLike, request_id: Option<String>) -> Result<Follow, Error> {
|
||||
pub fn render_follow(
|
||||
follower: UserLike,
|
||||
followee: UserLike,
|
||||
request_id: Option<String>,
|
||||
) -> Result<Follow, Error> {
|
||||
Follow::new(follower, followee, request_id)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use identicon_rs::{error::IdenticonError, Identicon};
|
||||
use crate::database::cache;
|
||||
use identicon_rs::{error::IdenticonError, Identicon};
|
||||
|
||||
#[macros::errors]
|
||||
pub enum Error {
|
||||
|
@ -14,7 +14,10 @@ pub async fn generate(id: &str) -> Result<Vec<u8>, Error> {
|
|||
if let Some(icon) = cache::get_one::<Vec<u8>>(cache::Category::RandomIcon, id).await? {
|
||||
Ok(icon)
|
||||
} else {
|
||||
let icon = Identicon::new(id).set_border(35).export_png_data()?;
|
||||
let icon = Identicon::new(id)
|
||||
.set_border(16)
|
||||
.set_scale(96)?
|
||||
.export_png_data()?;
|
||||
cache::set_one(cache::Category::RandomIcon, id, &icon, 10 * 60).await?;
|
||||
Ok(icon)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue