mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-19 07:37:11 +02:00
Drop old sticker set cover locations.
This commit is contained in:
parent
8e3dc76dd7
commit
9510ba07f7
4 changed files with 47 additions and 37 deletions
|
@ -324,12 +324,10 @@ PeerData *readPeer(
|
|||
}
|
||||
if (apply) {
|
||||
using LocationType = StorageFileLocation::Type;
|
||||
const auto location = (userpic->valid() && userpic->isLegacy())
|
||||
? userpic->convertToModern(
|
||||
LocationType::PeerPhoto,
|
||||
result->id.value,
|
||||
userpicAccessHash)
|
||||
: *userpic;
|
||||
const auto location = userpic->convertToModernPeerPhoto(
|
||||
result->id.value,
|
||||
userpicAccessHash,
|
||||
photoId);
|
||||
result->setUserpic(photoId, location);
|
||||
}
|
||||
return result;
|
||||
|
@ -342,7 +340,7 @@ QString peekUserPhone(int streamAppVersion, QDataStream &stream) {
|
|||
DEBUG_LOG(("peekUserPhone.id: %1").arg(peerId.value));
|
||||
if (!peerId
|
||||
|| !peerIsUser(peerId)
|
||||
|| !readStorageImageLocation(streamAppVersion, stream)) {
|
||||
|| !readImageLocation(streamAppVersion, stream)) {
|
||||
return QString();
|
||||
}
|
||||
|
||||
|
|
|
@ -1683,10 +1683,8 @@ void Account::readStickerSets(
|
|||
if (!thumbnail || !CheckStreamStatus(stickers.stream)) {
|
||||
return failed();
|
||||
} else if (thumbnail->valid() && thumbnail->isLegacy()) {
|
||||
setThumbnail = thumbnail->convertToModern(
|
||||
LocationType::StickerSetThumb,
|
||||
setId,
|
||||
setAccess);
|
||||
// No thumb_version information in legacy location.
|
||||
return failed();
|
||||
} else {
|
||||
setThumbnail = *thumbnail;
|
||||
}
|
||||
|
|
|
@ -177,18 +177,25 @@ StorageFileLocation::StorageFileLocation(
|
|||
});
|
||||
}
|
||||
|
||||
StorageFileLocation StorageFileLocation::convertToModern(
|
||||
Type type,
|
||||
StorageFileLocation StorageFileLocation::convertToModernPeerPhoto(
|
||||
uint64 id,
|
||||
uint64 accessHash) const {
|
||||
Expects(_type == Type::Legacy);
|
||||
Expects(type == Type::PeerPhoto || type == Type::StickerSetThumb);
|
||||
uint64 accessHash,
|
||||
uint64 photoId) const {
|
||||
if (_type != Type::Legacy && _type != Type::PeerPhoto) {
|
||||
return *this;
|
||||
} else if (!photoId) {
|
||||
return StorageFileLocation();
|
||||
}
|
||||
|
||||
auto result = *this;
|
||||
result._type = type;
|
||||
result._type = Type::PeerPhoto;
|
||||
result._id = id;
|
||||
result._accessHash = accessHash;
|
||||
result._sizeLetter = (type == Type::PeerPhoto) ? uint8('a') : uint8(0);
|
||||
result._sizeLetter = uint8('a');
|
||||
result._volumeId = photoId;
|
||||
result._localId = 0;
|
||||
result._inMessagePeerId = 0;
|
||||
result._inMessageId = 0;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -310,7 +317,7 @@ int StorageFileLocation::serializeSize() const {
|
|||
}
|
||||
|
||||
std::optional<StorageFileLocation> StorageFileLocation::FromSerialized(
|
||||
const QByteArray &serialized) {
|
||||
const QByteArray &serialized) {
|
||||
if (serialized.isEmpty()) {
|
||||
return StorageFileLocation();
|
||||
}
|
||||
|
@ -386,6 +393,11 @@ std::optional<StorageFileLocation> StorageFileLocation::FromSerialized(
|
|||
: peerFromChannel(ChannelId(-field2)))
|
||||
: PeerId();
|
||||
}
|
||||
if (result._type == Type::StickerSetThumb && result._volumeId != 0) {
|
||||
// Legacy field values that cannot be converted to modern.
|
||||
// No information about thumb_version, which is required.
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
return (stream.status() == QDataStream::Ok && result.valid())
|
||||
? std::make_optional(result)
|
||||
|
@ -882,15 +894,17 @@ std::optional<DownloadLocation> DownloadLocation::FromSerialized(
|
|||
return std::nullopt;
|
||||
}
|
||||
|
||||
DownloadLocation DownloadLocation::convertToModern(
|
||||
StorageFileLocation::Type type,
|
||||
DownloadLocation DownloadLocation::convertToModernPeerPhoto(
|
||||
uint64 id,
|
||||
uint64 accessHash) const {
|
||||
uint64 accessHash,
|
||||
uint64 photoId) const {
|
||||
if (!v::is<StorageFileLocation>(data)) {
|
||||
return *this;
|
||||
}
|
||||
auto &file = v::get<StorageFileLocation>(data);
|
||||
return DownloadLocation{ file.convertToModern(type, id, accessHash) };
|
||||
return DownloadLocation{
|
||||
file.convertToModernPeerPhoto(id, accessHash, photoId)
|
||||
};
|
||||
}
|
||||
|
||||
Storage::Cache::Key DownloadLocation::cacheKey() const {
|
||||
|
|
|
@ -70,10 +70,10 @@ public:
|
|||
UserId self,
|
||||
const MTPInputFileLocation &tl);
|
||||
|
||||
[[nodiscard]] StorageFileLocation convertToModern(
|
||||
Type type,
|
||||
[[nodiscard]] StorageFileLocation convertToModernPeerPhoto(
|
||||
uint64 id,
|
||||
uint64 accessHash) const;
|
||||
uint64 accessHash,
|
||||
uint64 photoId) const;
|
||||
|
||||
[[nodiscard]] int32 dcId() const;
|
||||
[[nodiscard]] uint64 objectId() const;
|
||||
|
@ -157,12 +157,12 @@ public:
|
|||
[[nodiscard]] static std::optional<StorageImageLocation> FromSerialized(
|
||||
const QByteArray &serialized);
|
||||
|
||||
[[nodiscard]] StorageImageLocation convertToModern(
|
||||
StorageFileLocation::Type type,
|
||||
[[nodiscard]] StorageImageLocation convertToModernPeerPhoto(
|
||||
uint64 id,
|
||||
uint64 accessHash) const {
|
||||
uint64 accessHash,
|
||||
uint64 photoId) const {
|
||||
return StorageImageLocation(
|
||||
_file.convertToModern(type, id, accessHash),
|
||||
_file.convertToModernPeerPhoto(id, accessHash, photoId),
|
||||
_width,
|
||||
_height);
|
||||
}
|
||||
|
@ -461,10 +461,10 @@ public:
|
|||
[[nodiscard]] static std::optional<DownloadLocation> FromSerialized(
|
||||
const QByteArray &serialized);
|
||||
|
||||
[[nodiscard]] DownloadLocation convertToModern(
|
||||
StorageFileLocation::Type type,
|
||||
[[nodiscard]] DownloadLocation convertToModernPeerPhoto(
|
||||
uint64 id,
|
||||
uint64 accessHash) const;
|
||||
uint64 accessHash,
|
||||
uint64 photoId) const;
|
||||
|
||||
[[nodiscard]] Storage::Cache::Key cacheKey() const;
|
||||
[[nodiscard]] Storage::Cache::Key bigFileBaseCacheKey() const;
|
||||
|
@ -524,12 +524,12 @@ public:
|
|||
[[nodiscard]] static std::optional<ImageLocation> FromSerialized(
|
||||
const QByteArray &serialized);
|
||||
|
||||
[[nodiscard]] ImageLocation convertToModern(
|
||||
StorageFileLocation::Type type,
|
||||
[[nodiscard]] ImageLocation convertToModernPeerPhoto(
|
||||
uint64 id,
|
||||
uint64 accessHash) const {
|
||||
uint64 accessHash,
|
||||
uint64 photoId) const {
|
||||
return ImageLocation(
|
||||
_file.convertToModern(type, id, accessHash),
|
||||
_file.convertToModernPeerPhoto(id, accessHash, photoId),
|
||||
_width,
|
||||
_height);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue