Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions native/mtproto-rs/src/media/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,18 +341,26 @@ 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 {
"video_avatar".into()
} 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,
Expand Down
19 changes: 11 additions & 8 deletions native/mtproto-rs/src/media/location.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,17 @@ pub fn fill_zero_peer_photo_hashes(
peers: &HashMap<i64, crate::peers::CachedPeer>,
) {
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;
}
}
}
}
}
Expand Down Expand Up @@ -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,
}
}

Expand Down