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

Show slowmode error messages.

This commit is contained in:
John Preston
2019-07-17 12:37:42 +02:00
parent 01d0479335
commit 04bf24288a
16 changed files with 210 additions and 68 deletions

View File

@@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_photo.h"
#include "data/data_folder.h"
#include "data/data_session.h"
#include "base/unixtime.h"
#include "lang/lang_keys.h"
#include "observer_peer.h"
#include "apiwrap.h"
@@ -701,6 +702,26 @@ bool PeerData::canRevokeFullHistory() const {
&& (Global::RevokePrivateTimeLimit() == 0x7FFFFFFF);
}
bool PeerData::slowmodeApplied() const {
if (const auto channel = asChannel()) {
return !channel->amCreator()
&& !channel->hasAdminRights()
&& (channel->flags() & MTPDchannel::Flag::f_slowmode_enabled);
}
return false;
}
int PeerData::slowmodeSecondsLeft() const {
if (const auto channel = asChannel()) {
if (const auto last = channel->slowmodeLastMessage()) {
const auto seconds = channel->slowmodeSeconds();
const auto now = base::unixtime::now();
return std::max(seconds - (now - last), 0);
}
}
return 0;
}
namespace Data {
std::vector<ChatRestrictions> ListOfRestrictions() {