Send updateAddChatMembersPrivacyForbidden after successful request response.
This commit is contained in:
parent
23341647ba
commit
a49e63985d
@ -2780,8 +2780,19 @@ class InviteToChannelQuery final : public Td::ResultHandler {
|
|||||||
auto ptr = result_ptr.move_as_ok();
|
auto ptr = result_ptr.move_as_ok();
|
||||||
LOG(INFO) << "Receive result for InviteToChannelQuery: " << to_string(ptr);
|
LOG(INFO) << "Receive result for InviteToChannelQuery: " << to_string(ptr);
|
||||||
td_->contacts_manager_->invalidate_channel_full(channel_id_, false, "InviteToChannelQuery");
|
td_->contacts_manager_->invalidate_channel_full(channel_id_, false, "InviteToChannelQuery");
|
||||||
td_->updates_manager_->process_group_invite_privacy_forbidden_updates(DialogId(channel_id_), ptr);
|
auto user_ids = td_->updates_manager_->extract_group_invite_privacy_forbidden_updates(ptr);
|
||||||
td_->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_));
|
auto promise = PromiseCreator::lambda([dialog_id = DialogId(channel_id_), user_ids = std::move(user_ids),
|
||||||
|
promise = std::move(promise_)](Result<Unit> &&result) mutable {
|
||||||
|
if (result.is_error()) {
|
||||||
|
return promise.set_error(result.move_as_error());
|
||||||
|
}
|
||||||
|
promise.set_value(Unit());
|
||||||
|
if (!user_ids.empty()) {
|
||||||
|
send_closure(G()->contacts_manager(), &ContactsManager::send_update_add_chat_members_privacy_forbidden,
|
||||||
|
dialog_id, std::move(user_ids), "InviteToChannelQuery");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
td_->updates_manager_->on_get_updates(std::move(ptr), std::move(promise));
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_error(Status status) final {
|
void on_error(Status status) final {
|
||||||
@ -8213,6 +8224,7 @@ void ContactsManager::delete_dialog(DialogId dialog_id, Promise<Unit> &&promise)
|
|||||||
|
|
||||||
void ContactsManager::send_update_add_chat_members_privacy_forbidden(DialogId dialog_id, vector<UserId> user_ids,
|
void ContactsManager::send_update_add_chat_members_privacy_forbidden(DialogId dialog_id, vector<UserId> user_ids,
|
||||||
const char *source) {
|
const char *source) {
|
||||||
|
td_->messages_manager_->force_create_dialog(dialog_id, "send_update_add_chat_members_privacy_forbidden");
|
||||||
send_closure(G()->td(), &Td::send_update,
|
send_closure(G()->td(), &Td::send_update,
|
||||||
td_api::make_object<td_api::updateAddChatMembersPrivacyForbidden>(
|
td_api::make_object<td_api::updateAddChatMembersPrivacyForbidden>(
|
||||||
dialog_id.get(), get_user_ids_object(user_ids, source)));
|
dialog_id.get(), get_user_ids_object(user_ids, source)));
|
||||||
|
@ -33822,13 +33822,24 @@ void MessagesManager::on_create_new_dialog_success(int64 random_id, tl_object_pt
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (pending_created_dialogs_.count(dialog_id) == 0) {
|
if (pending_created_dialogs_.count(dialog_id) == 0) {
|
||||||
pending_created_dialogs_.emplace(dialog_id, std::move(promise));
|
auto user_ids = td_->updates_manager_->extract_group_invite_privacy_forbidden_updates(updates);
|
||||||
|
auto new_promise = PromiseCreator::lambda(
|
||||||
|
[dialog_id, user_ids = std::move(user_ids), promise = std::move(promise)](Result<Unit> &&result) mutable {
|
||||||
|
if (result.is_error()) {
|
||||||
|
return promise.set_error(result.move_as_error());
|
||||||
|
}
|
||||||
|
promise.set_value(Unit());
|
||||||
|
if (!user_ids.empty()) {
|
||||||
|
send_closure(G()->contacts_manager(), &ContactsManager::send_update_add_chat_members_privacy_forbidden,
|
||||||
|
dialog_id, std::move(user_ids), "on_create_new_dialog_success");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
pending_created_dialogs_.emplace(dialog_id, std::move(new_promise));
|
||||||
} else {
|
} else {
|
||||||
LOG(ERROR) << "Receive twice " << dialog_id << " as result of chat creation";
|
LOG(ERROR) << "Receive twice " << dialog_id << " as result of chat creation";
|
||||||
return on_create_new_dialog_fail(random_id, Status::Error(500, "Chat was created earlier"), std::move(promise));
|
return on_create_new_dialog_fail(random_id, Status::Error(500, "Chat was created earlier"), std::move(promise));
|
||||||
}
|
}
|
||||||
|
|
||||||
td_->updates_manager_->process_group_invite_privacy_forbidden_updates(dialog_id, updates);
|
|
||||||
td_->updates_manager_->on_get_updates(std::move(updates), Promise<Unit>());
|
td_->updates_manager_->on_get_updates(std::move(updates), Promise<Unit>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1175,13 +1175,14 @@ vector<tl_object_ptr<telegram_api::Update>> *UpdatesManager::get_updates(telegra
|
|||||||
get_updates(static_cast<const telegram_api::Updates *>(updates_ptr)));
|
get_updates(static_cast<const telegram_api::Updates *>(updates_ptr)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdatesManager::process_group_invite_privacy_forbidden_updates(DialogId dialog_id,
|
vector<UserId> UpdatesManager::extract_group_invite_privacy_forbidden_updates(
|
||||||
tl_object_ptr<telegram_api::Updates> &updates_ptr) {
|
tl_object_ptr<telegram_api::Updates> &updates_ptr) {
|
||||||
auto updates = get_updates(updates_ptr.get());
|
auto updates = get_updates(updates_ptr.get());
|
||||||
if (updates == nullptr) {
|
if (updates == nullptr) {
|
||||||
LOG(ERROR) << "Can't find updateGroupInvitePrivacyForbidden updates";
|
LOG(ERROR) << "Can't find updateGroupInvitePrivacyForbidden updates";
|
||||||
return;
|
return {};
|
||||||
}
|
}
|
||||||
|
LOG(INFO) << "Extract updateGroupInvitePrivacyForbidden updates from " << updates->size() << " updates";
|
||||||
vector<UserId> user_ids;
|
vector<UserId> user_ids;
|
||||||
for (auto &update_ptr : *updates) {
|
for (auto &update_ptr : *updates) {
|
||||||
if (update_ptr->get_id() != telegram_api::updateGroupInvitePrivacyForbidden::ID) {
|
if (update_ptr->get_id() != telegram_api::updateGroupInvitePrivacyForbidden::ID) {
|
||||||
@ -1196,9 +1197,9 @@ void UpdatesManager::process_group_invite_privacy_forbidden_updates(DialogId dia
|
|||||||
user_ids.push_back(user_id);
|
user_ids.push_back(user_id);
|
||||||
}
|
}
|
||||||
if (!user_ids.empty()) {
|
if (!user_ids.empty()) {
|
||||||
td_->contacts_manager_->send_update_add_chat_members_privacy_forbidden(
|
td::remove_if(*updates, [](auto &update) { return update == nullptr; });
|
||||||
dialog_id, user_ids, "process_group_invite_privacy_forbidden_updates");
|
|
||||||
}
|
}
|
||||||
|
return user_ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
FlatHashSet<int64> UpdatesManager::get_sent_messages_random_ids(const telegram_api::Updates *updates_ptr) {
|
FlatHashSet<int64> UpdatesManager::get_sent_messages_random_ids(const telegram_api::Updates *updates_ptr) {
|
||||||
|
@ -103,8 +103,7 @@ class UpdatesManager final : public Actor {
|
|||||||
void add_pending_pts_update(tl_object_ptr<telegram_api::Update> &&update, int32 new_pts, int32 pts_count,
|
void add_pending_pts_update(tl_object_ptr<telegram_api::Update> &&update, int32 new_pts, int32 pts_count,
|
||||||
double receive_time, Promise<Unit> &&promise, const char *source);
|
double receive_time, Promise<Unit> &&promise, const char *source);
|
||||||
|
|
||||||
void process_group_invite_privacy_forbidden_updates(DialogId dialog_id,
|
vector<UserId> extract_group_invite_privacy_forbidden_updates(tl_object_ptr<telegram_api::Updates> &updates_ptr);
|
||||||
tl_object_ptr<telegram_api::Updates> &updates_ptr);
|
|
||||||
|
|
||||||
static FlatHashSet<int64> get_sent_messages_random_ids(const telegram_api::Updates *updates_ptr);
|
static FlatHashSet<int64> get_sent_messages_random_ids(const telegram_api::Updates *updates_ptr);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user