| 161 | } |
| 162 | |
| 163 | [[nodiscard]] MTPPhotoSize FindDocumentThumbnail(const MTPDdocument &data) { |
| 164 | const auto area = [](const MTPPhotoSize &size) { |
| 165 | static constexpr auto kInvalid = 0; |
| 166 | return size.match([](const MTPDphotoSizeEmpty &) { |
| 167 | return kInvalid; |
| 168 | }, [](const MTPDphotoStrippedSize &) { |
| 169 | return kInvalid; |
| 170 | }, [](const MTPDphotoPathSize &) { |
| 171 | return kInvalid; |
| 172 | }, [](const auto &data) { |
| 173 | return (data.vw().v * data.vh().v); |
| 174 | }); |
| 175 | }; |
| 176 | const auto thumbs = data.vthumbs(); |
| 177 | if (!thumbs) { |
| 178 | return MTP_photoSizeEmpty(MTP_string()); |
| 179 | } |
| 180 | const auto &list = thumbs->v; |
| 181 | const auto i = ranges::max_element(list, std::less<>(), area); |
| 182 | return (i != list.end() && area(*i) > 0) |
| 183 | ? (*i) |
| 184 | : MTPPhotoSize(MTP_photoSizeEmpty(MTP_string())); |
| 185 | } |
| 186 | |
| 187 | [[nodiscard]] std::optional<MTPVideoSize> FindDocumentVideoThumbnail( |
| 188 | const MTPDdocument &data) { |
no test coverage detected