Merge branch 'main' into 3-otel
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "revolt-autumn"
|
||||
version = "0.9.4"
|
||||
version = "0.12.0"
|
||||
edition = "2021"
|
||||
license = "AGPL-3.0-or-later"
|
||||
publish = false
|
||||
@@ -17,6 +17,7 @@ jxl-oxide = "0.8.1"
|
||||
kamadak-exif = "0.5.4"
|
||||
# revolt_little_exif = "0.5.1"
|
||||
image = { version = "0.25.2" } # avif encode requires dav1d system library: features = ["avif-native"]
|
||||
thumbhash = "0.1.0"
|
||||
|
||||
# File processing
|
||||
revolt_clamav-client = { version = "0.1.5" }
|
||||
@@ -40,18 +41,16 @@ serde = { version = "1.0", features = ["derive"] }
|
||||
tokio = { version = "1.0", features = ["full"] }
|
||||
|
||||
# Core crates
|
||||
revolt-files = { version = "0.9.4", path = "../../core/files" }
|
||||
revolt-config = { version = "0.9.4", path = "../../core/config" }
|
||||
revolt-database = { version = "0.9.4", path = "../../core/database", features = [
|
||||
revolt-files = { version = "0.12.0", path = "../../core/files" }
|
||||
revolt-config = { version = "0.12.0", path = "../../core/config" }
|
||||
revolt-database = { version = "0.12.0", path = "../../core/database", features = [
|
||||
"axum-impl",
|
||||
] }
|
||||
revolt-result = { version = "0.9.4", path = "../../core/result", features = [
|
||||
revolt-result = { version = "0.12.0", path = "../../core/result", features = [
|
||||
"utoipa",
|
||||
"axum",
|
||||
] }
|
||||
revolt-ratelimits = { version = "0.9.4", path = "../../core/ratelimits", features = [
|
||||
"axum",
|
||||
] }
|
||||
revolt-ratelimits = { version = "0.12.0", path = "../../core/ratelimits", features = ["axum"] }
|
||||
|
||||
# Axum / web server
|
||||
tempfile = "3.12.0"
|
||||
|
||||
@@ -345,7 +345,7 @@ async fn fetch_preview(
|
||||
|
||||
let hash = file.as_hash(&db).await?;
|
||||
|
||||
let is_animated = hash.content_type == "image/gif"; // TODO: extract this data from files
|
||||
let is_animated = matches!(hash.metadata, Metadata::Image { animated: true, .. });
|
||||
|
||||
// Process GIFs if avatar or icon
|
||||
if !matches!(hash.metadata, Metadata::Image { .. })
|
||||
|
||||
@@ -15,7 +15,12 @@ pub async fn strip_metadata(
|
||||
mime: &str,
|
||||
) -> Result<(Vec<u8>, Metadata)> {
|
||||
match &metadata {
|
||||
Metadata::Image { width, height } => match mime {
|
||||
Metadata::Image {
|
||||
width,
|
||||
height,
|
||||
thumbhash,
|
||||
animated,
|
||||
} => match mime {
|
||||
// // little_exif does not appear to parse JPEGs correctly? had 2/2 files fail
|
||||
// "image/jpeg" | "image/png" => {
|
||||
// // use little_exif to strip metadata except for orientation and colour profile
|
||||
@@ -85,7 +90,15 @@ pub async fn strip_metadata(
|
||||
_ => (*width, *height),
|
||||
};
|
||||
|
||||
Ok((bytes, Metadata::Image { width, height }))
|
||||
Ok((
|
||||
bytes,
|
||||
Metadata::Image {
|
||||
width,
|
||||
height,
|
||||
thumbhash: thumbhash.clone(),
|
||||
animated: *animated,
|
||||
},
|
||||
))
|
||||
}
|
||||
// TODO: JXLs store EXIF data but we don't have the ability to write them
|
||||
"image/jxl" => Ok((buf, metadata)),
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
use std::io::Cursor;
|
||||
|
||||
use image::{GenericImageView, ImageError, ImageReader};
|
||||
use revolt_database::Metadata;
|
||||
use revolt_files::{image_size, video_size};
|
||||
use revolt_files::{image_size, is_animated, video_size};
|
||||
use tempfile::NamedTempFile;
|
||||
|
||||
/// Intersection of what infer can detect and what image-rs supports
|
||||
@@ -25,6 +26,17 @@ pub fn generate_metadata(f: &NamedTempFile, mime_type: &str) -> Metadata {
|
||||
.map(|(width, height)| Metadata::Image {
|
||||
width: width as isize,
|
||||
height: height as isize,
|
||||
thumbhash: ImageReader::open(f)
|
||||
.and_then(|r| r.with_guessed_format())
|
||||
.map_err(ImageError::from)
|
||||
.and_then(|r| r.decode())
|
||||
.map(|img| img.thumbnail(100, 100))
|
||||
.map(|img| (img.dimensions(), img.to_rgba8().into_raw()))
|
||||
.map(|((width, height), rgba)| {
|
||||
thumbhash::rgba_to_thumb_hash(width as usize, height as usize, &rgba)
|
||||
})
|
||||
.ok(),
|
||||
animated: is_animated(f, mime_type).unwrap_or(false),
|
||||
})
|
||||
.unwrap_or_default()
|
||||
} else if mime_type.starts_with("video/") {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "revolt-gifbox"
|
||||
version = "0.9.4"
|
||||
version = "0.12.0"
|
||||
edition = "2021"
|
||||
license = "AGPL-3.0-or-later"
|
||||
publish = false
|
||||
@@ -17,19 +17,19 @@ tokio = { version = "1.0", features = ["full"] }
|
||||
reqwest = { version = "0.12", features = ["json"] }
|
||||
|
||||
# Core crates
|
||||
revolt-config = { version = "0.9.4", path = "../../core/config" }
|
||||
revolt-models = { version = "0.9.4", path = "../../core/models" }
|
||||
revolt-result = { version = "0.9.4", path = "../../core/result", features = [
|
||||
revolt-config = { version = "0.12.0", path = "../../core/config" }
|
||||
revolt-models = { version = "0.12.0", path = "../../core/models" }
|
||||
revolt-result = { version = "0.12.0", path = "../../core/result", features = [
|
||||
"utoipa",
|
||||
"axum",
|
||||
] }
|
||||
revolt-coalesced = { version = "0.9.4", path = "../../core/coalesced", features = [
|
||||
revolt-coalesced = { version = "0.12.0", path = "../../core/coalesced", features = [
|
||||
"queue",
|
||||
] }
|
||||
revolt-database = { version = "0.9.4", path = "../../core/database", features = [
|
||||
revolt-database = { version = "0.12.0", path = "../../core/database", features = [
|
||||
"axum-impl",
|
||||
] }
|
||||
revolt-ratelimits = { version = "0.9.4", path = "../../core/ratelimits", features = [
|
||||
revolt-ratelimits = { version = "0.12.0", path = "../../core/ratelimits", features = [
|
||||
"axum",
|
||||
] }
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "revolt-january"
|
||||
version = "0.9.4"
|
||||
version = "0.12.0"
|
||||
edition = "2021"
|
||||
license = "AGPL-3.0-or-later"
|
||||
publish = false
|
||||
@@ -33,13 +33,13 @@ tracing = "0.1"
|
||||
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
|
||||
|
||||
# Core crates
|
||||
revolt-config = { version = "0.9.4", path = "../../core/config" }
|
||||
revolt-models = { version = "0.9.4", path = "../../core/models" }
|
||||
revolt-result = { version = "0.9.4", path = "../../core/result", features = [
|
||||
revolt-config = { version = "0.12.0", path = "../../core/config" }
|
||||
revolt-models = { version = "0.12.0", path = "../../core/models" }
|
||||
revolt-result = { version = "0.12.0", path = "../../core/result", features = [
|
||||
"utoipa",
|
||||
"axum",
|
||||
] }
|
||||
revolt-files = { version = "0.9.4", path = "../../core/files" }
|
||||
revolt-files = { version = "0.12.0", path = "../../core/files" }
|
||||
|
||||
# Axum / web server
|
||||
axum = { version = "0.7.5" }
|
||||
|
||||
Reference in New Issue
Block a user