mirror of
https://github.com/chatmail/core.git
synced 2026-05-02 12:56:30 +03:00
fix: Don't recode images in Viewtype::File messages (#5617)
This commit is contained in:
15
src/blob.rs
15
src/blob.rs
@@ -1191,6 +1191,21 @@ mod tests {
|
|||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
send_image_check_mediaquality(
|
||||||
|
Viewtype::File,
|
||||||
|
Some("1"),
|
||||||
|
bytes,
|
||||||
|
"png",
|
||||||
|
false, // no Exif
|
||||||
|
1920,
|
||||||
|
1080,
|
||||||
|
0,
|
||||||
|
1920,
|
||||||
|
1080,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
// This will be sent as Image, see [`BlobObject::maybe_sticker`] for explanation.
|
// This will be sent as Image, see [`BlobObject::maybe_sticker`] for explanation.
|
||||||
send_image_check_mediaquality(
|
send_image_check_mediaquality(
|
||||||
Viewtype::Sticker,
|
Viewtype::Sticker,
|
||||||
|
|||||||
@@ -2619,6 +2619,7 @@ async fn prepare_msg_blob(context: &Context, msg: &mut Message) -> Result<()> {
|
|||||||
.get_blob(Param::File, context, !msg.is_increation())
|
.get_blob(Param::File, context, !msg.is_increation())
|
||||||
.await?
|
.await?
|
||||||
.with_context(|| format!("attachment missing for message of type #{}", msg.viewtype))?;
|
.with_context(|| format!("attachment missing for message of type #{}", msg.viewtype))?;
|
||||||
|
let send_as_is = msg.viewtype == Viewtype::File;
|
||||||
|
|
||||||
if msg.viewtype == Viewtype::File || msg.viewtype == Viewtype::Image {
|
if msg.viewtype == Viewtype::File || msg.viewtype == Viewtype::Image {
|
||||||
// Correct the type, take care not to correct already very special
|
// Correct the type, take care not to correct already very special
|
||||||
@@ -2645,8 +2646,9 @@ async fn prepare_msg_blob(context: &Context, msg: &mut Message) -> Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let mut maybe_sticker = msg.viewtype == Viewtype::Sticker;
|
let mut maybe_sticker = msg.viewtype == Viewtype::Sticker;
|
||||||
if msg.viewtype == Viewtype::Image
|
if !send_as_is
|
||||||
|| maybe_sticker && !msg.param.exists(Param::ForceSticker)
|
&& (msg.viewtype == Viewtype::Image
|
||||||
|
|| maybe_sticker && !msg.param.exists(Param::ForceSticker))
|
||||||
{
|
{
|
||||||
blob.recode_to_image_size(context, &mut maybe_sticker)
|
blob.recode_to_image_size(context, &mut maybe_sticker)
|
||||||
.await?;
|
.await?;
|
||||||
|
|||||||
Reference in New Issue
Block a user