Add getInactiveSupergroupChats method.
GitOrigin-RevId: 45b15965e50ab5d153a0de4e575fab6ac22eed11
This commit is contained in:
parent
ce7530c495
commit
71ddd7c7e3
@ -3171,6 +3171,9 @@ checkCreatedPublicChatsLimit type:PublicChatType = Ok;
|
||||
//@description Returns a list of basic group and supergroup chats, which can be used as a discussion group for a channel. Basic group chats need to be first upgraded to supergroups before they can be set as a discussion group
|
||||
getSuitableDiscussionChats = Chats;
|
||||
|
||||
//@description Returns a list of recently inactive supergroups and channels. Can be used when user reaches limit on the number of joined supergroups and channels and receives CHANNELS_TOO_MUCH error
|
||||
getInactiveSupergroupChats = Chats;
|
||||
|
||||
|
||||
//@description Returns a list of common group chats with a given user. Chats are sorted by their type and creation date @user_id User identifier @offset_chat_id Chat identifier starting from which to return chats; use 0 for the first request @limit Maximum number of chats to be returned; up to 100
|
||||
getGroupsInCommon user_id:int32 offset_chat_id:int53 limit:int32 = Chats;
|
||||
|
Binary file not shown.
@ -2117,6 +2117,37 @@ class GetGroupsForDiscussionQuery : public Td::ResultHandler {
|
||||
}
|
||||
};
|
||||
|
||||
class GetInactiveChannelsQuery : public Td::ResultHandler {
|
||||
Promise<Unit> promise_;
|
||||
|
||||
public:
|
||||
explicit GetInactiveChannelsQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
|
||||
}
|
||||
|
||||
void send() {
|
||||
send_query(G()->net_query_creator().create(create_storer(telegram_api::channels_getInactiveChannels())));
|
||||
}
|
||||
|
||||
void on_result(uint64 id, BufferSlice packet) override {
|
||||
auto result_ptr = fetch_result<telegram_api::channels_getInactiveChannels>(packet);
|
||||
if (result_ptr.is_error()) {
|
||||
return on_error(id, result_ptr.move_as_error());
|
||||
}
|
||||
|
||||
auto result = result_ptr.move_as_ok();
|
||||
LOG(INFO) << "Receive result for GetInactiveChannelsQuery " << to_string(result);
|
||||
// TODO use result->dates_
|
||||
td->contacts_manager_->on_get_users(std::move(result->users_), "GetInactiveChannelsQuery");
|
||||
td->contacts_manager_->on_get_inactive_channels(std::move(result->chats_));
|
||||
|
||||
promise_.set_value(Unit());
|
||||
}
|
||||
|
||||
void on_error(uint64 id, Status status) override {
|
||||
promise_.set_error(std::move(status));
|
||||
}
|
||||
};
|
||||
|
||||
class GetUsersQuery : public Td::ResultHandler {
|
||||
Promise<Unit> promise_;
|
||||
|
||||
@ -6003,6 +6034,25 @@ void ContactsManager::update_dialogs_for_discussion(DialogId dialog_id, bool is_
|
||||
}
|
||||
}
|
||||
|
||||
vector<DialogId> ContactsManager::get_inactive_channels(Promise<Unit> &&promise) {
|
||||
if (inactive_channels_inited_) {
|
||||
promise.set_value(Unit());
|
||||
return transform(inactive_channels_, [&](ChannelId channel_id) {
|
||||
DialogId dialog_id{channel_id};
|
||||
td_->messages_manager_->force_create_dialog(dialog_id, "get_inactive_channels");
|
||||
return dialog_id;
|
||||
});
|
||||
}
|
||||
|
||||
td_->create_handler<GetInactiveChannelsQuery>(std::move(promise))->send();
|
||||
return {};
|
||||
}
|
||||
|
||||
void ContactsManager::on_get_inactive_channels(vector<tl_object_ptr<telegram_api::Chat>> &&chats) {
|
||||
inactive_channels_inited_ = true;
|
||||
inactive_channels_ = get_channel_ids(std::move(chats), "on_get_inactive_channels");
|
||||
}
|
||||
|
||||
void ContactsManager::on_imported_contacts(int64 random_id, vector<UserId> imported_contact_user_ids,
|
||||
vector<int32> unimported_contact_invites) {
|
||||
LOG(INFO) << "Contacts import with random_id " << random_id
|
||||
|
@ -229,6 +229,8 @@ class ContactsManager : public Actor {
|
||||
|
||||
void on_get_dialogs_for_discussion(vector<tl_object_ptr<telegram_api::Chat>> &&chats);
|
||||
|
||||
void on_get_inactive_channels(vector<tl_object_ptr<telegram_api::Chat>> &&chats);
|
||||
|
||||
UserId get_my_id() const;
|
||||
|
||||
void set_my_online_status(bool is_online, bool send_update, bool is_local);
|
||||
@ -376,6 +378,8 @@ class ContactsManager : public Actor {
|
||||
|
||||
vector<DialogId> get_dialogs_for_discussion(Promise<Unit> &&promise);
|
||||
|
||||
vector<DialogId> get_inactive_channels(Promise<Unit> &&promise);
|
||||
|
||||
bool is_user_contact(UserId user_id) const;
|
||||
|
||||
bool is_user_blocked(UserId user_id);
|
||||
@ -1346,6 +1350,9 @@ class ContactsManager : public Actor {
|
||||
bool dialogs_for_discussion_inited_ = false;
|
||||
vector<DialogId> dialogs_for_discussion_;
|
||||
|
||||
bool inactive_channels_inited_ = false;
|
||||
vector<ChannelId> inactive_channels_;
|
||||
|
||||
std::unordered_map<UserId, vector<Promise<Unit>>, UserIdHash> load_user_from_database_queries_;
|
||||
std::unordered_set<UserId, UserIdHash> loaded_from_database_users_;
|
||||
std::unordered_set<UserId, UserIdHash> unavailable_user_fulls_;
|
||||
|
@ -1068,6 +1068,22 @@ class GetSuitableDiscussionChatsRequest : public RequestActor<> {
|
||||
}
|
||||
};
|
||||
|
||||
class GetInactiveSupergroupChatsRequest : public RequestActor<> {
|
||||
vector<DialogId> dialog_ids_;
|
||||
|
||||
void do_run(Promise<Unit> &&promise) override {
|
||||
dialog_ids_ = td->contacts_manager_->get_inactive_channels(std::move(promise));
|
||||
}
|
||||
|
||||
void do_send_result() override {
|
||||
send_result(MessagesManager::get_chats_object(dialog_ids_));
|
||||
}
|
||||
|
||||
public:
|
||||
GetInactiveSupergroupChatsRequest(ActorShared<Td> td, uint64 request_id) : RequestActor(std::move(td), request_id) {
|
||||
}
|
||||
};
|
||||
|
||||
class GetMessageRequest : public RequestOnceActor {
|
||||
FullMessageId full_message_id_;
|
||||
|
||||
@ -5567,6 +5583,11 @@ void Td::on_request(uint64 id, const td_api::getSuitableDiscussionChats &request
|
||||
CREATE_NO_ARGS_REQUEST(GetSuitableDiscussionChatsRequest);
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::getInactiveSupergroupChats &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_NO_ARGS_REQUEST(GetInactiveSupergroupChatsRequest);
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::addRecentlyFoundChat &request) {
|
||||
CHECK_IS_USER();
|
||||
answer_ok_query(id, messages_manager_->add_recently_found_dialog(DialogId(request.chat_id_)));
|
||||
|
@ -532,6 +532,8 @@ class Td final : public NetQueryCallback {
|
||||
|
||||
void on_request(uint64 id, const td_api::getSuitableDiscussionChats &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::getInactiveSupergroupChats &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::openChat &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::closeChat &request);
|
||||
|
@ -3330,6 +3330,8 @@ class CliClient final : public Actor {
|
||||
td_api::make_object<td_api::publicChatTypeIsLocationBased>()));
|
||||
} else if (op == "gsdc") {
|
||||
send_request(td_api::make_object<td_api::getSuitableDiscussionChats>());
|
||||
} else if (op == "gisc") {
|
||||
send_request(td_api::make_object<td_api::getInactiveSupergroupChats>());
|
||||
} else if (op == "cpc") {
|
||||
string user_id;
|
||||
string force;
|
||||
|
Reference in New Issue
Block a user