Delete notifications when deleting comments (#499)
* Implement find_for_comment for notifications * Delete notifications when deleting a comment This should tackle #463 * Apply rustfmt * Implement `find_for_mention` and remove order by from `find_for_comment` There is no need to order the notifications * Delete notifications for mentions * Fix notifications for comments and mentions
This commit is contained in:
committed by
Baptiste Gelez
parent
f0d6b9d1e8
commit
c7ee779f51
+25
-19
@@ -59,7 +59,7 @@ fn get_rocket_config() -> Result<RocketConfig, RocketError> {
|
||||
pub struct LogoConfig {
|
||||
pub main: String,
|
||||
pub favicon: String,
|
||||
pub other: Vec<Icon> //url, size, type
|
||||
pub other: Vec<Icon>, //url, size, type
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
@@ -82,14 +82,12 @@ impl Icon {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
impl Default for LogoConfig {
|
||||
fn default() -> Self {
|
||||
let to_icon = |(src, sizes, image_type): &(&str, Option<&str>, Option<&str>)| Icon {
|
||||
src: str::to_owned(src),
|
||||
sizes: sizes.map(str::to_owned),
|
||||
image_type: image_type.map(str::to_owned)
|
||||
image_type: image_type.map(str::to_owned),
|
||||
};
|
||||
let icons = [
|
||||
(
|
||||
@@ -132,29 +130,34 @@ impl Default for LogoConfig {
|
||||
Some("512x512"),
|
||||
Some("image/png"),
|
||||
),
|
||||
(
|
||||
"icons/trwnh/feather/plumeFeather.svg",
|
||||
None,
|
||||
None,
|
||||
)
|
||||
].iter().map(to_icon).collect();
|
||||
("icons/trwnh/feather/plumeFeather.svg", None, None),
|
||||
]
|
||||
.iter()
|
||||
.map(to_icon)
|
||||
.collect();
|
||||
|
||||
let custom_main = var("PLUME_LOGO").ok();
|
||||
let custom_favicon = var("PLUME_LOGO_FAVICON").ok().or_else(|| custom_main.clone());
|
||||
let custom_favicon = var("PLUME_LOGO_FAVICON")
|
||||
.ok()
|
||||
.or_else(|| custom_main.clone());
|
||||
let other = if let Some(main) = custom_main.clone() {
|
||||
let ext = |path: &str| match path.rsplitn(2, '.').next() {
|
||||
Some("png") => Some("image/png".to_owned()),
|
||||
Some("jpg")| Some("jpeg") => Some("image/jpeg".to_owned()),
|
||||
Some("jpg") | Some("jpeg") => Some("image/jpeg".to_owned()),
|
||||
Some("svg") => Some("image/svg+xml".to_owned()),
|
||||
Some("webp") => Some("image/webp".to_owned()),
|
||||
_ => None,
|
||||
};
|
||||
let mut custom_icons = env::vars()
|
||||
.filter_map(|(var, val)| if var.starts_with("PLUME_LOGO_") {
|
||||
Some((var[11..].to_owned(), val))
|
||||
} else { None })
|
||||
.filter_map(|(var, val)| var.parse::<u64>().ok().map(|var| (var,val)))
|
||||
.map(|(dim,src)| Icon {
|
||||
.filter_map(|(var, val)| {
|
||||
if var.starts_with("PLUME_LOGO_") {
|
||||
Some((var[11..].to_owned(), val))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.filter_map(|(var, val)| var.parse::<u64>().ok().map(|var| (var, val)))
|
||||
.map(|(dim, src)| Icon {
|
||||
image_type: ext(&src),
|
||||
src,
|
||||
sizes: Some(format!("{}x{}", dim, dim)),
|
||||
@@ -171,8 +174,11 @@ impl Default for LogoConfig {
|
||||
};
|
||||
|
||||
LogoConfig {
|
||||
main: custom_main.unwrap_or_else(|| "icons/trwnh/feather/plumeFeather256.png".to_owned()),
|
||||
favicon: custom_favicon.unwrap_or_else(|| "icons/trwnh/feather-filled/plumeFeatherFilled64.png".to_owned()),
|
||||
main: custom_main
|
||||
.unwrap_or_else(|| "icons/trwnh/feather/plumeFeather256.png".to_owned()),
|
||||
favicon: custom_favicon.unwrap_or_else(|| {
|
||||
"icons/trwnh/feather-filled/plumeFeatherFilled64.png".to_owned()
|
||||
}),
|
||||
other,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user