Skip to content

Commit

Permalink
Allow accessing photo from chat (Lonami#202)
Browse files Browse the repository at this point in the history
  • Loading branch information
tingfeng-key authored Nov 2, 2023
1 parent a869e03 commit 47cb50e
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions lib/grammers-client/src/types/chat/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,34 @@ impl Chat {
},
}
}

// get an chat photo downloadable
pub fn photo_downloadable(&self, big: bool) -> Option<crate::types::Downloadable> {
let peer = self.pack().to_input_peer();
match self {
Self::User(user) => user.photo().map(|x| {
crate::types::Downloadable::UserProfilePhoto(crate::types::UserProfilePhoto {
big,
peer,
photo: x.clone(),
})
}),
Self::Group(group) => group.photo().map(|x| {
crate::types::Downloadable::ChatPhoto(crate::types::ChatPhoto {
big,
peer,
photo: x.clone(),
})
}),
Self::Channel(channel) => channel.photo().map(|x| {
crate::types::Downloadable::ChatPhoto(crate::types::ChatPhoto {
big,
peer,
photo: x.clone(),
})
}),
}
}
}

impl From<Chat> for PackedChat {
Expand Down

0 comments on commit 47cb50e

Please sign in to comment.