Skip to content

Commit 9cca005

Browse files
committed
Fix order in auctions list hashing.
1 parent c486314 commit 9cca005

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

Telegram/SourceFiles/data/components/gift_auctions.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,17 @@ ActiveAuctions GiftAuctions::collectActive() const {
333333
}
334334

335335
uint64 GiftAuctions::countActiveHash() const {
336+
// The server hashes the auctions in a fixed order, so we have to sort
337+
// them by (date, version) before hashing, just like the Android client
338+
// does in GiftAuctionController::calculateUserAuctionsHash. Otherwise
339+
// the server will never answer with starGiftActiveAuctionsNotModified.
340+
auto list = collectActive().list;
341+
ranges::sort(list, ranges::less(), [](const auto &active) {
342+
return (uint64(uint32(active->my.date)) << 32)
343+
| uint32(active->version);
344+
});
336345
auto result = Api::HashInit();
337-
for (const auto &active : collectActive().list) {
346+
for (const auto &active : list) {
338347
Api::HashUpdate(result, active->version);
339348
Api::HashUpdate(result, active->my.date);
340349
}

0 commit comments

Comments
 (0)