From 8b5a55c79800eb03b67bebb4e0b8e405df698428 Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 2 Jul 2021 21:30:27 +0300 Subject: [PATCH] Update member restrictions before returning it in getChatMember. --- td/telegram/ContactsManager.cpp | 4 +++- td/telegram/ContactsManager.h | 5 ++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index def3b3b76..f8adf2dfb 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -11808,7 +11808,7 @@ void ContactsManager::add_channel_participant_to_cache(ChannelId channel_id, } const DialogParticipant *ContactsManager::get_channel_participant_from_cache(ChannelId channel_id, - DialogId participant_dialog_id) const { + DialogId participant_dialog_id) { auto channel_participants_it = channel_participants_.find(channel_id); if (channel_participants_it == channel_participants_.end()) { return nullptr; @@ -11818,6 +11818,7 @@ const DialogParticipant *ContactsManager::get_channel_participant_from_cache(Cha CHECK(!participants.empty()); auto it = participants.find(participant_dialog_id); if (it != participants.end()) { + it->second.participant_.status.update_restrictions(); it->second.last_access_date_ = G()->unix_time(); return &it->second.participant_; } @@ -14918,6 +14919,7 @@ DialogParticipant ContactsManager::get_channel_participant(ChannelId channel_id, auto it = received_channel_participant_.find(random_id); CHECK(it != received_channel_participant_.end()); auto result = std::move(it->second); + result.status.update_restrictions(); received_channel_participant_.erase(it); promise.set_value(Unit()); return result; diff --git a/td/telegram/ContactsManager.h b/td/telegram/ContactsManager.h index 69e8eb179..902c577ef 100644 --- a/td/telegram/ContactsManager.h +++ b/td/telegram/ContactsManager.h @@ -1492,8 +1492,7 @@ class ContactsManager : public Actor { void add_channel_participant_to_cache(ChannelId channel_id, const DialogParticipant &dialog_participant, bool allow_replace); - const DialogParticipant *get_channel_participant_from_cache(ChannelId channel_id, - DialogId participant_dialog_id) const; + const DialogParticipant *get_channel_participant_from_cache(ChannelId channel_id, DialogId participant_dialog_id); void change_channel_participant_status_impl(ChannelId channel_id, DialogId participant_dialog_id, DialogParticipantStatus status, DialogParticipantStatus old_status, @@ -1657,7 +1656,7 @@ class ContactsManager : public Actor { struct ChannelParticipantInfo { DialogParticipant participant_; - mutable int32 last_access_date_ = 0; + int32 last_access_date_ = 0; }; struct ChannelParticipants { std::unordered_map participants_;