Split DialogPhoto to Small and Big.
GitOrigin-RevId: 4c5800b4fb80c5f870577f93e9afdebf6b2b16b3
This commit is contained in:
parent
9675331eaa
commit
e6cc07a244
@ -42,7 +42,8 @@ FileType PhotoSizeSource::get_file_type() const {
|
||||
switch (get_type()) {
|
||||
case PhotoSizeSource::Type::Thumbnail:
|
||||
return thumbnail().file_type;
|
||||
case PhotoSizeSource::Type::DialogPhoto:
|
||||
case PhotoSizeSource::Type::DialogPhotoSmall:
|
||||
case PhotoSizeSource::Type::DialogPhotoBig:
|
||||
return FileType::ProfilePhoto;
|
||||
case PhotoSizeSource::Type::StickerSetThumbnail:
|
||||
return FileType::Thumbnail;
|
||||
@ -61,10 +62,10 @@ bool operator==(const PhotoSizeSource &lhs, const PhotoSizeSource &rhs) {
|
||||
case PhotoSizeSource::Type::Thumbnail:
|
||||
return lhs.thumbnail().file_type == rhs.thumbnail().file_type &&
|
||||
lhs.thumbnail().thumbnail_type == rhs.thumbnail().thumbnail_type;
|
||||
case PhotoSizeSource::Type::DialogPhoto:
|
||||
case PhotoSizeSource::Type::DialogPhotoSmall:
|
||||
case PhotoSizeSource::Type::DialogPhotoBig:
|
||||
return lhs.dialog_photo().dialog_id == rhs.dialog_photo().dialog_id &&
|
||||
lhs.dialog_photo().dialog_access_hash == rhs.dialog_photo().dialog_access_hash &&
|
||||
lhs.dialog_photo().is_big == rhs.dialog_photo().is_big;
|
||||
lhs.dialog_photo().dialog_access_hash == rhs.dialog_photo().dialog_access_hash;
|
||||
case PhotoSizeSource::Type::StickerSetThumbnail:
|
||||
return lhs.sticker_set_thumbnail().sticker_set_id == rhs.sticker_set_thumbnail().sticker_set_id &&
|
||||
lhs.sticker_set_thumbnail().sticker_set_access_hash == rhs.sticker_set_thumbnail().sticker_set_access_hash;
|
||||
|
@ -17,7 +17,7 @@
|
||||
namespace td {
|
||||
|
||||
struct PhotoSizeSource {
|
||||
enum class Type : int32 { Legacy, Thumbnail, DialogPhoto, StickerSetThumbnail };
|
||||
enum class Type : int32 { Legacy, Thumbnail, DialogPhotoSmall, DialogPhotoBig, StickerSetThumbnail };
|
||||
|
||||
// for legacy photos with secret
|
||||
struct Legacy {
|
||||
@ -41,15 +41,22 @@ struct PhotoSizeSource {
|
||||
// for dialog photos
|
||||
struct DialogPhoto {
|
||||
DialogPhoto() = default;
|
||||
DialogPhoto(DialogId dialog_id, int64 dialog_access_hash, bool is_big)
|
||||
: dialog_id(dialog_id), dialog_access_hash(dialog_access_hash), is_big(is_big) {
|
||||
DialogPhoto(DialogId dialog_id, int64 dialog_access_hash)
|
||||
: dialog_id(dialog_id), dialog_access_hash(dialog_access_hash) {
|
||||
}
|
||||
|
||||
tl_object_ptr<telegram_api::InputPeer> get_input_peer() const;
|
||||
|
||||
DialogId dialog_id;
|
||||
int64 dialog_access_hash = 0;
|
||||
bool is_big = false;
|
||||
};
|
||||
|
||||
struct DialogPhotoSmall : public DialogPhoto {
|
||||
using DialogPhoto::DialogPhoto;
|
||||
};
|
||||
|
||||
struct DialogPhotoBig : public DialogPhoto {
|
||||
using DialogPhoto::DialogPhoto;
|
||||
};
|
||||
|
||||
// for sticker set thumbnails
|
||||
@ -72,8 +79,12 @@ struct PhotoSizeSource {
|
||||
}
|
||||
PhotoSizeSource(FileType file_type, int32 thumbnail_type) : variant(Thumbnail(file_type, thumbnail_type)) {
|
||||
}
|
||||
PhotoSizeSource(DialogId dialog_id, int64 dialog_access_hash, bool is_big)
|
||||
: variant(DialogPhoto(dialog_id, dialog_access_hash, is_big)) {
|
||||
PhotoSizeSource(DialogId dialog_id, int64 dialog_access_hash, bool is_big) {
|
||||
if (is_big) {
|
||||
variant = DialogPhotoBig(dialog_id, dialog_access_hash);
|
||||
} else {
|
||||
variant = DialogPhotoSmall(dialog_id, dialog_access_hash);
|
||||
}
|
||||
}
|
||||
PhotoSizeSource(int64 sticker_set_id, int64 sticker_set_access_hash)
|
||||
: variant(StickerSetThumbnail(sticker_set_id, sticker_set_access_hash)) {
|
||||
@ -98,7 +109,11 @@ struct PhotoSizeSource {
|
||||
return variant.get<Thumbnail>();
|
||||
}
|
||||
const DialogPhoto &dialog_photo() const {
|
||||
return variant.get<DialogPhoto>();
|
||||
if (variant.get_offset() == 2) {
|
||||
return variant.get<DialogPhotoSmall>();
|
||||
} else {
|
||||
return variant.get<DialogPhotoBig>();
|
||||
}
|
||||
}
|
||||
const StickerSetThumbnail &sticker_set_thumbnail() const {
|
||||
return variant.get<StickerSetThumbnail>();
|
||||
@ -110,7 +125,7 @@ struct PhotoSizeSource {
|
||||
void parse(ParserT &parser);
|
||||
|
||||
private:
|
||||
Variant<Legacy, Thumbnail, DialogPhoto, StickerSetThumbnail> variant;
|
||||
Variant<Legacy, Thumbnail, DialogPhotoSmall, DialogPhotoBig, StickerSetThumbnail> variant;
|
||||
};
|
||||
|
||||
bool operator==(const PhotoSizeSource &lhs, const PhotoSizeSource &rhs);
|
||||
|
@ -53,14 +53,12 @@ template <class StorerT>
|
||||
void store(const PhotoSizeSource::DialogPhoto &source, StorerT &storer) {
|
||||
store(source.dialog_id, storer);
|
||||
store(source.dialog_access_hash, storer);
|
||||
store(source.is_big, storer);
|
||||
}
|
||||
|
||||
template <class ParserT>
|
||||
void parse(PhotoSizeSource::DialogPhoto &source, ParserT &parser) {
|
||||
parse(source.dialog_id, parser);
|
||||
parse(source.dialog_access_hash, parser);
|
||||
parse(source.is_big, parser);
|
||||
|
||||
switch (source.dialog_id.get_type()) {
|
||||
case DialogType::SecretChat:
|
||||
@ -72,6 +70,26 @@ void parse(PhotoSizeSource::DialogPhoto &source, ParserT &parser) {
|
||||
}
|
||||
}
|
||||
|
||||
template <class StorerT>
|
||||
void store(const PhotoSizeSource::DialogPhotoSmall &source, StorerT &storer) {
|
||||
store(static_cast<const PhotoSizeSource::DialogPhoto &>(source), storer);
|
||||
}
|
||||
|
||||
template <class ParserT>
|
||||
void parse(PhotoSizeSource::DialogPhotoSmall &source, ParserT &parser) {
|
||||
parse(static_cast<PhotoSizeSource::DialogPhoto &>(source), parser);
|
||||
}
|
||||
|
||||
template <class StorerT>
|
||||
void store(const PhotoSizeSource::DialogPhotoBig &source, StorerT &storer) {
|
||||
store(static_cast<const PhotoSizeSource::DialogPhoto &>(source), storer);
|
||||
}
|
||||
|
||||
template <class ParserT>
|
||||
void parse(PhotoSizeSource::DialogPhotoBig &source, ParserT &parser) {
|
||||
parse(static_cast<PhotoSizeSource::DialogPhoto &>(source), parser);
|
||||
}
|
||||
|
||||
template <class StorerT>
|
||||
void PhotoSizeSource::store(StorerT &storer) const {
|
||||
td::store(variant, storer);
|
||||
|
@ -413,10 +413,12 @@ class FullRemoteFileLocation {
|
||||
break;
|
||||
}
|
||||
}
|
||||
case PhotoSizeSource::Type::DialogPhoto: {
|
||||
case PhotoSizeSource::Type::DialogPhotoSmall:
|
||||
case PhotoSizeSource::Type::DialogPhotoBig: {
|
||||
auto &dialog_photo = photo().source_.dialog_photo();
|
||||
bool is_big = photo().source_.get_type() == PhotoSizeSource::Type::DialogPhotoBig;
|
||||
return make_tl_object<telegram_api::inputPeerPhotoFileLocation>(
|
||||
dialog_photo.is_big * telegram_api::inputPeerPhotoFileLocation::Flags::BIG_MASK, dialog_photo.is_big,
|
||||
is_big * telegram_api::inputPeerPhotoFileLocation::Flags::BIG_MASK, false /*ignored*/,
|
||||
dialog_photo.get_input_peer(), photo().volume_id_, photo().local_id_);
|
||||
}
|
||||
case PhotoSizeSource::Type::StickerSetThumbnail: {
|
||||
|
@ -167,7 +167,8 @@ void FullRemoteFileLocation::parse(ParserT &parser) {
|
||||
parser.set_error("Invalid FileType in PhotoRemoteFileLocation Thumbnail");
|
||||
}
|
||||
break;
|
||||
case PhotoSizeSource::Type::DialogPhoto:
|
||||
case PhotoSizeSource::Type::DialogPhotoSmall:
|
||||
case PhotoSizeSource::Type::DialogPhotoBig:
|
||||
if (file_type_ != FileType::ProfilePhoto) {
|
||||
parser.set_error("Invalid FileType in PhotoRemoteFileLocation DialogPhoto");
|
||||
}
|
||||
|
Reference in New Issue
Block a user