diff --git a/Telegram/SourceFiles/api/api_chat_participants.cpp b/Telegram/SourceFiles/api/api_chat_participants.cpp index 0e163528a1ac54..bfc2ccfface381 100644 --- a/Telegram/SourceFiles/api/api_chat_participants.cpp +++ b/Telegram/SourceFiles/api/api_chat_participants.cpp @@ -222,6 +222,7 @@ void ApplyBotsList( Data::PeerUpdate::Flag::FullInfo); } +#if 0 // mtp [[nodiscard]] ChatParticipants::Channels ParseSimilar( not_null session, const MTPmessages_Chats &chats) { @@ -250,6 +251,34 @@ void ApplyBotsList( const MTPmessages_Chats &chats) { return ParseSimilar(&channel->session(), chats); } +#endif + +[[nodiscard]] ChatParticipants::Channels ParseSimilar( + not_null session, + const TLchats &chats) { + auto result = ChatParticipants::Channels(); + const auto &data = chats.data(); + const auto &list = data.vchat_ids().v; + result.list.reserve(list.size()); + for (const auto chatId : list) { + const auto peer = session->data().peer(peerFromTdbChat(chatId)); + if (const auto channel = peer->asChannel()) { + result.list.push_back(channel); + } + } + if (session->premiumPossible()) { + result.more = std::max( + int(data.vtotal_count().v) - int(data.vchat_ids().v.size()), + 0); + } + return result; +} + +[[nodiscard]] ChatParticipants::Channels ParseSimilar( + not_null channel, + const TLchats &chats) { + return ParseSimilar(&channel->session(), chats); +} } // namespace @@ -614,7 +643,11 @@ void ChatParticipants::add( done(true); } }).fail([=](const Error &error) { - ShowAddParticipantsError(error.message, peer, { 1, user }); + ShowAddParticipantsError( + show, + error.message, + peer, + user); if (done) { done(false); } @@ -666,7 +699,11 @@ void ChatParticipants::add( callback(true); } }).fail([=](const Error &error) { - ShowAddParticipantsError(error.message, peer, users); + ShowAddParticipantsError( + show, + error.message, + peer, + { .users = users }); if (callback) { callback(false); } @@ -966,12 +1003,17 @@ void ChatParticipants::loadSimilarChannels(not_null channel) { return; } } +#if 0 // mtp using Flag = MTPchannels_GetChannelRecommendations::Flag; _similar[channel].requestId = _api.request( MTPchannels_GetChannelRecommendations( MTP_flags(Flag::f_channel), channel->inputChannel) ).done([=](const MTPmessages_Chats &result) { +#endif + _similar[channel].requestId = _api.request(TLgetChatSimilarChats( + peerToTdbChat(channel->id) + )).done([=](const TLchats &result) { auto &similar = _similar[channel]; similar.requestId = 0; auto parsed = ParseSimilar(channel, result); @@ -1009,6 +1051,15 @@ void ChatParticipants::loadRecommendations() { if (_recommendationsLoaded.current() || _recommendations.requestId) { return; } + _recommendations.requestId = _api.request(TLgetRecommendedChats( + )).done([=](const TLchats &result) { + _recommendations.requestId = 0; + auto parsed = ParseSimilar(_session, result); + _recommendations.channels = std::move(parsed); + _recommendations.channels.more = 0; + _recommendationsLoaded = true; + }).send(); +#if 0 // mtp _recommendations.requestId = _api.request( MTPchannels_GetChannelRecommendations( MTP_flags(0), @@ -1020,6 +1071,7 @@ void ChatParticipants::loadRecommendations() { _recommendations.channels.more = 0; _recommendationsLoaded = true; }).send(); +#endif } const ChatParticipants::Channels &ChatParticipants::recommendations() const {