fix: media thumbnail calculation and appservice detection
This commit is contained in:
parent
3ea7d162db
commit
46d8f36a2c
5 changed files with 29 additions and 13 deletions
|
@ -226,16 +226,17 @@ impl Media {
|
|||
}
|
||||
|
||||
let thumbnail = if crop {
|
||||
image.resize_to_fill(width, height, FilterType::Triangle)
|
||||
image.resize_to_fill(width, height, FilterType::CatmullRom)
|
||||
} else {
|
||||
let (exact_width, exact_height) = {
|
||||
// Copied from image::dynimage::resize_dimensions
|
||||
let ratio = u64::from(original_width) * u64::from(height);
|
||||
let nratio = u64::from(width) * u64::from(original_height);
|
||||
|
||||
let use_width = nratio > ratio;
|
||||
let use_width = nratio <= ratio;
|
||||
let intermediate = if use_width {
|
||||
u64::from(original_height) * u64::from(width) / u64::from(width)
|
||||
u64::from(original_height) * u64::from(width)
|
||||
/ u64::from(original_width)
|
||||
} else {
|
||||
u64::from(original_width) * u64::from(height)
|
||||
/ u64::from(original_height)
|
||||
|
@ -261,7 +262,7 @@ impl Media {
|
|||
}
|
||||
};
|
||||
|
||||
image.thumbnail_exact(exact_width, exact_height)
|
||||
image.thumbnail_exact(dbg!(exact_width), dbg!(exact_height))
|
||||
};
|
||||
|
||||
let mut thumbnail_bytes = Vec::new();
|
||||
|
|
|
@ -1193,6 +1193,9 @@ impl Rooms {
|
|||
.state_key
|
||||
.as_ref()
|
||||
.map_or(false, |state_key| users.is_match(&state_key))
|
||||
|| db.rooms.room_members(&room_id).any(|userid| {
|
||||
userid.map_or(false, |userid| users.is_match(userid.as_str()))
|
||||
})
|
||||
};
|
||||
let matching_aliases = |aliases: &Regex| {
|
||||
self.room_aliases(&room_id)
|
||||
|
@ -1201,9 +1204,9 @@ impl Rooms {
|
|||
};
|
||||
|
||||
if bridge_user_id.map_or(false, user_is_joined)
|
||||
|| users.iter().any(matching_users)
|
||||
|| aliases.iter().any(matching_aliases)
|
||||
|| rooms.map_or(false, |rooms| rooms.contains(&room_id.as_str().into()))
|
||||
|| users.iter().any(matching_users)
|
||||
{
|
||||
db.sending.send_pdu_appservice(&appservice.0, &pdu_id)?;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue