From 527c88ca88ee2885fa49da9ed48ff65351efb6e8 Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 24 Jul 2019 05:33:46 +0300 Subject: [PATCH] Adjust new chat member status for Bot API backward compatibility. GitOrigin-RevId: 04bbe38639bde8c7ab0b8bc527b8df833d496c81 --- td/telegram/ContactsManager.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index 0ba73140..4d16e7ca 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -4394,9 +4394,20 @@ void ContactsManager::change_channel_participant_status_impl(ChannelId channel_i DialogParticipantStatus status, DialogParticipantStatus old_status, Promise &&promise) { - if (td_->auth_manager_->is_bot() && status.is_restricted() && status.is_member() && !old_status.is_member()) { - // allow bots to restrict left chat members without trying to add them - status.set_is_member(false); + if (td_->auth_manager_->is_bot()) { + if (status.is_restricted() && status.is_member() && !old_status.is_member()) { + // allow bots to restrict left chat members without trying to add them + status.set_is_member(false); + } + + auto new_until_date = status.get_until_date(); + if (new_until_date >= 1840000000 && status.is_restricted()) { + status = DialogParticipantStatus::Restricted( + status.is_member(), new_until_date - 300000000, status.can_send_messages(), status.can_send_media(), + status.can_send_stickers(), status.can_send_animations(), status.can_send_games(), + status.can_use_inline_bots(), status.can_add_web_page_previews(), old_status.can_send_polls(), + old_status.can_change_info_and_settings(), old_status.can_invite_users(), old_status.can_pin_messages()); + } } if (old_status == status) { return promise.set_value(Unit());