Add td_api::supergroup::is_slow_mode_enabled.

GitOrigin-RevId: cdbf1140507fe85dcb54cfc8831436d46762f27d
This commit is contained in:
levlam 2019-11-15 15:46:12 +03:00
parent 6d08f29fe9
commit e12f7ac3e0
4 changed files with 26 additions and 12 deletions

View File

@ -451,12 +451,13 @@ basicGroupFullInfo description:string creator_user_id:int32 members:vector<chatM
//@has_linked_chat True, if the channel has a discussion group, or the supergroup is a discussion group for a channel
//@has_location True, if the supergroup has a chat location
//@sign_messages True, if messages sent to the channel should contain information about the sender. This field is only applicable to channels
//@is_slow_mode_enabled True, if the slow mode is enabled in the supergroup
//@is_channel True, if the supergroup is a channel
//@is_verified True, if the supergroup or channel is verified
//@restriction_reason If non-empty, contains the reason why access to this supergroup or channel must be restricted. Format of the string is "{type}: {description}".
//-{type} Contains the type of the restriction and at least one of the suffixes "-all", "-ios", "-android", or "-wp", which describe the platforms on which access should be restricted. (For example, "terms-ios-android". {description} contains a human-readable description of the restriction, which can be shown to the user)
//@is_scam True, if many users reported this supergroup as a scam
supergroup id:int32 username:string date:int32 status:ChatMemberStatus member_count:int32 has_linked_chat:Bool has_location:Bool sign_messages:Bool is_channel:Bool is_verified:Bool restriction_reason:string is_scam:Bool = Supergroup;
supergroup id:int32 username:string date:int32 status:ChatMemberStatus member_count:int32 has_linked_chat:Bool has_location:Bool sign_messages:Bool is_slow_mode_enabled:Bool is_channel:Bool is_verified:Bool restriction_reason:string is_scam:Bool = Supergroup;
//@description Contains full information about a supergroup or channel
//@param_description Supergroup or channel description

Binary file not shown.

View File

@ -3122,6 +3122,7 @@ void ContactsManager::Channel::store(StorerT &storer) const {
STORE_FLAG(has_cache_version);
STORE_FLAG(has_linked_channel);
STORE_FLAG(has_location);
STORE_FLAG(is_slow_mode_enabled);
END_STORE_FLAGS();
store(status, storer);
@ -3184,6 +3185,7 @@ void ContactsManager::Channel::parse(ParserT &parser) {
PARSE_FLAG(has_cache_version);
PARSE_FLAG(has_linked_channel);
PARSE_FLAG(has_location);
PARSE_FLAG(is_slow_mode_enabled);
END_PARSE_FLAGS();
if (use_new_rights) {
@ -11945,6 +11947,7 @@ void ContactsManager::on_chat_update(telegram_api::channel &channel, const char
bool has_linked_channel = (channel.flags_ & CHANNEL_FLAG_HAS_LINKED_CHAT) != 0;
bool has_location = (channel.flags_ & CHANNEL_FLAG_HAS_LOCATION) != 0;
bool sign_messages = (channel.flags_ & CHANNEL_FLAG_SIGN_MESSAGES) != 0;
bool is_slow_mode_enabled = (channel.flags_ & CHANNEL_FLAG_IS_SLOW_MODE_ENABLED) != 0;
bool is_megagroup = (channel.flags_ & CHANNEL_FLAG_IS_MEGAGROUP) != 0;
bool is_verified = (channel.flags_ & CHANNEL_FLAG_IS_VERIFIED) != 0;
string restriction_reason = std::move(channel.restriction_reason_);
@ -11962,6 +11965,9 @@ void ContactsManager::on_chat_update(telegram_api::channel &channel, const char
if (is_megagroup) {
LOG_IF(ERROR, sign_messages) << "Need to sign messages in the supergroup " << channel_id << " from " << source;
sign_messages = true;
} else {
LOG_IF(ERROR, is_slow_mode_enabled) << "Slow mode enabled in the " << channel_id << " from " << source;
is_slow_mode_enabled = false;
}
DialogParticipantStatus status = [&]() {
@ -12036,11 +12042,13 @@ void ContactsManager::on_chat_update(telegram_api::channel &channel, const char
}
if (c->has_linked_channel != has_linked_channel || c->has_location != has_location ||
c->sign_messages != sign_messages || c->is_megagroup != is_megagroup || c->is_verified != is_verified ||
c->restriction_reason != restriction_reason || c->is_scam != is_scam) {
c->sign_messages != sign_messages || c->is_slow_mode_enabled != is_slow_mode_enabled ||
c->is_megagroup != is_megagroup || c->is_verified != is_verified || c->restriction_reason != restriction_reason ||
c->is_scam != is_scam) {
c->has_linked_channel = has_linked_channel;
c->has_location = has_location;
c->sign_messages = sign_messages;
c->is_slow_mode_enabled = is_slow_mode_enabled;
c->is_megagroup = is_megagroup;
c->is_verified = is_verified;
c->restriction_reason = std::move(restriction_reason);
@ -12097,6 +12105,7 @@ void ContactsManager::on_chat_update(telegram_api::channelForbidden &channel, co
bool has_linked_channel = false;
bool has_location = false;
bool sign_messages = false;
bool is_slow_mode_enabled = false;
bool is_megagroup = (channel.flags_ & CHANNEL_FLAG_IS_MEGAGROUP) != 0;
bool is_verified = false;
string restriction_reason;
@ -12119,11 +12128,13 @@ void ContactsManager::on_chat_update(telegram_api::channelForbidden &channel, co
}
if (c->has_linked_channel != has_linked_channel || c->has_location != has_location ||
c->sign_messages != sign_messages || c->is_megagroup != is_megagroup || c->is_verified != is_verified ||
c->restriction_reason != restriction_reason || c->is_scam != is_scam) {
c->sign_messages != sign_messages || c->is_slow_mode_enabled != is_slow_mode_enabled ||
c->is_megagroup != is_megagroup || c->is_verified != is_verified || c->restriction_reason != restriction_reason ||
c->is_scam != is_scam) {
c->has_linked_channel = has_linked_channel;
c->has_location = has_location;
c->sign_messages = sign_messages;
c->is_slow_mode_enabled = is_slow_mode_enabled;
c->is_megagroup = is_megagroup;
c->is_verified = is_verified;
c->restriction_reason = std::move(restriction_reason);
@ -12324,7 +12335,7 @@ int32 ContactsManager::get_supergroup_id_object(ChannelId channel_id, const char
send_closure(G()->td(), &Td::send_update,
td_api::make_object<td_api::updateSupergroup>(td_api::make_object<td_api::supergroup>(
channel_id.get(), string(), 0, DialogParticipantStatus::Banned(0).get_chat_member_status_object(),
0, false, false, false, true, false, "", false)));
0, false, false, false, false, true, false, "", false)));
}
return channel_id.get();
}
@ -12337,10 +12348,10 @@ tl_object_ptr<td_api::supergroup> ContactsManager::get_supergroup_object(Channel
if (c == nullptr) {
return nullptr;
}
return make_tl_object<td_api::supergroup>(channel_id.get(), c->username, c->date,
get_channel_status(c).get_chat_member_status_object(), c->participant_count,
c->has_linked_channel, c->has_location, c->sign_messages, !c->is_megagroup,
c->is_verified, c->restriction_reason, c->is_scam);
return td_api::make_object<td_api::supergroup>(
channel_id.get(), c->username, c->date, get_channel_status(c).get_chat_member_status_object(),
c->participant_count, c->has_linked_channel, c->has_location, c->sign_messages, c->is_slow_mode_enabled,
!c->is_megagroup, c->is_verified, c->restriction_reason, c->is_scam);
}
tl_object_ptr<td_api::supergroupFullInfo> ContactsManager::get_supergroup_full_info_object(ChannelId channel_id) const {
@ -12350,7 +12361,7 @@ tl_object_ptr<td_api::supergroupFullInfo> ContactsManager::get_supergroup_full_i
tl_object_ptr<td_api::supergroupFullInfo> ContactsManager::get_supergroup_full_info_object(
const ChannelFull *channel_full) const {
CHECK(channel_full != nullptr);
return make_tl_object<td_api::supergroupFullInfo>(
return td_api::make_object<td_api::supergroupFullInfo>(
channel_full->description, channel_full->participant_count, channel_full->administrator_count,
channel_full->restricted_count, channel_full->banned_count, DialogId(channel_full->linked_channel_id).get(),
channel_full->can_get_participants, channel_full->can_set_username, channel_full->can_set_sticker_set,

View File

@ -694,12 +694,13 @@ class ContactsManager : public Actor {
int32 date = 0;
int32 participant_count = 0;
static constexpr uint32 CACHE_VERSION = 3;
static constexpr uint32 CACHE_VERSION = 4;
uint32 cache_version = 0;
bool has_linked_channel = false;
bool has_location = false;
bool sign_messages = false;
bool is_slow_mode_enabled = false;
bool is_megagroup = false;
bool is_verified = false;
@ -903,6 +904,7 @@ class ContactsManager : public Actor {
static constexpr int32 CHANNEL_FLAG_IS_SCAM = 1 << 19;
static constexpr int32 CHANNEL_FLAG_HAS_LINKED_CHAT = 1 << 20;
static constexpr int32 CHANNEL_FLAG_HAS_LOCATION = 1 << 21;
static constexpr int32 CHANNEL_FLAG_IS_SLOW_MODE_ENABLED = 1 << 22;
static constexpr int32 CHANNEL_FULL_FLAG_HAS_PARTICIPANT_COUNT = 1 << 0;
static constexpr int32 CHANNEL_FULL_FLAG_HAS_ADMINISTRATOR_COUNT = 1 << 1;