diff --git a/native/mtproto-rs/src/media/index.rs b/native/mtproto-rs/src/media/index.rs index 58f6fef8a..7edc0851f 100644 --- a/native/mtproto-rs/src/media/index.rs +++ b/native/mtproto-rs/src/media/index.rs @@ -341,6 +341,14 @@ pub fn media_ref_peer_photo( ), None => (None, None), }; + let small_location = MediaLocation::PeerPhoto { + peer_kind, + peer_id, + access_hash, + photo_id, + big: false, + dc_id, + }; MediaRef { file_size: None, kind: if has_video { @@ -348,11 +356,11 @@ pub fn media_ref_peer_photo( } else { "photo".into() }, - cache_key, + cache_key: cache_key.clone(), thumb_cache_key, thumb_location, - display_cache_key: None, - display_location: None, + display_cache_key: Some(format!("{}:small", cache_key)), + display_location: Some(small_location), sticker_set_id: None, sticker_set_access_hash: None, source_url: None, diff --git a/native/mtproto-rs/src/media/location.rs b/native/mtproto-rs/src/media/location.rs index 237c47a4c..8334add6c 100644 --- a/native/mtproto-rs/src/media/location.rs +++ b/native/mtproto-rs/src/media/location.rs @@ -73,14 +73,17 @@ pub fn fill_zero_peer_photo_hashes( peers: &HashMap, ) { for ((chat_id, _), item) in media.iter_mut() { - let MediaLocation::PeerPhoto { access_hash, .. } = &mut item.location else { - continue; - }; - if *access_hash != 0 { - continue; - } if let Some(peer) = crate::peers::usable_cached_peer(peers, *chat_id) { - *access_hash = peer.access_hash; + if let MediaLocation::PeerPhoto { access_hash, .. } = &mut item.location { + if *access_hash == 0 { + *access_hash = peer.access_hash; + } + } + if let Some(MediaLocation::PeerPhoto { access_hash, .. }) = &mut item.display_location { + if *access_hash == 0 { + *access_hash = peer.access_hash; + } + } } } } @@ -245,7 +248,7 @@ pub(crate) fn location_is_getfile_thumb(loc: &MediaLocation) -> bool { MediaLocation::Photo { thumb_size, .. } | MediaLocation::Document { thumb_size, .. } => { is_getfile_thumb_size(thumb_size) } - MediaLocation::PeerPhoto { .. } => false, + MediaLocation::PeerPhoto { big, .. } => !*big, } }