2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Track stars-per-message for users and channels.

This commit is contained in:
John Preston
2025-02-13 14:12:19 +04:00
parent f2aa3afbbb
commit 45c7829cd8
10 changed files with 239 additions and 102 deletions

View File

@@ -859,6 +859,21 @@ void ChannelData::growSlowmodeLastMessage(TimeId when) {
session().changes().peerUpdated(this, UpdateFlag::Slowmode);
}
int ChannelData::starsPerMessage() const {
if (const auto info = mgInfo.get()) {
return info->starsPerMessage;
}
return 0;
}
void ChannelData::setStarsPerMessage(int stars) {
if (!mgInfo || starsPerMessage() == stars) {
return;
}
mgInfo->starsPerMessage = stars;
session().changes().peerUpdated(this, UpdateFlag::StarsPerMessage);
}
int ChannelData::peerGiftsCount() const {
return _peerGiftsCount;
}
@@ -1209,6 +1224,8 @@ void ApplyChannelUpdate(
} else {
channel->setLinkedChat(nullptr);
}
channel->setStarsPerMessage(
update.vsend_paid_messages_stars().value_or_empty());
if (const auto history = channel->owner().historyLoaded(channel)) {
if (const auto available = update.vavailable_min_id()) {
history->clearUpTill(available->v);