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

Handle ttl_period locally.

This commit is contained in:
John Preston
2021-02-02 20:38:30 +04:00
parent 046a3906c4
commit 6a6e355af4
13 changed files with 282 additions and 69 deletions

View File

@@ -945,6 +945,35 @@ void PeerData::setLoadedStatus(LoadedStatus status) {
_loadedStatus = status;
}
TimeId PeerData::messagesTTL() const {
return (_ttlMyPeriod && _ttlPeerPeriod)
? std::min(_ttlMyPeriod, _ttlPeerPeriod)
: std::max(_ttlMyPeriod, _ttlPeerPeriod);
}
void PeerData::setMessagesTTL(
TimeId myPeriod,
TimeId peerPeriod,
bool oneSide) {
_ttlMyPeriod = myPeriod;
_ttlPeerPeriod = peerPeriod;
_ttlOneSide = oneSide;
}
void PeerData::applyMessagesTTL(const MTPPeerHistoryTTL &ttl) {
ttl.match([&](const MTPDpeerHistoryTTL &data) {
setMessagesTTL(
data.vttl_period().v,
data.vttl_period().v,
false);
}, [&](const MTPDpeerHistoryTTLPM &data) {
setMessagesTTL(
data.vmy_ttl_period().value_or_empty(),
data.vpeer_ttl_period().value_or_empty(),
data.is_my_oneside());
});
}
namespace Data {
std::vector<ChatRestrictions> ListOfRestrictions() {