From 55bd922fedf4bcf71cb67fb34c013328a0bc28df Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 13 Nov 2023 00:11:08 +0300 Subject: [PATCH] Use less error-prone timeout time for channel unban. --- td/telegram/ContactsManager.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index 9e730639e..c1e7c608c 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -12264,10 +12264,13 @@ void ContactsManager::update_channel(Channel *c, ChannelId channel_id, bool from if (c->is_status_changed) { c->status.update_restrictions(); auto until_date = c->status.get_until_date(); - int32 left_time = 0; + double left_time = 0; if (until_date > 0) { - left_time = until_date - G()->unix_time() + 1; - CHECK(left_time > 0); + left_time = until_date - G()->server_time() + 2; + if (left_time <= 0) { + c->status.update_restrictions(); + CHECK(c->status.get_until_date() == 0); + } } if (left_time > 0 && left_time < 366 * 86400) { channel_unban_timeout_.set_timeout_in(channel_id.get(), left_time);