Add updateAddChatMembersPrivacyForbidden.

This commit is contained in:
levlam 2023-03-03 14:42:30 +03:00
parent 82cdc98ecf
commit b45d56d116
5 changed files with 44 additions and 7 deletions

View File

@ -5560,6 +5560,9 @@ updateAnimationSearchParameters provider:string emojis:vector<string> = Update;
//@description The list of suggested to the user actions has changed @added_actions Added suggested actions @removed_actions Removed suggested actions //@description The list of suggested to the user actions has changed @added_actions Added suggested actions @removed_actions Removed suggested actions
updateSuggestedActions added_actions:vector<SuggestedAction> removed_actions:vector<SuggestedAction> = Update; updateSuggestedActions added_actions:vector<SuggestedAction> removed_actions:vector<SuggestedAction> = Update;
//@description Adding users to a chat has failed because of their privacy settings. An invite link can be shared with the users if appropriate @chat_id Chat identifier @user_ids Identifiers of users, which weren't added because of their privacy settings
updateAddChatMembersPrivacyForbidden chat_id:int53 user_ids:vector<int53> = Update;
//@description Autosave settings for some type of chats were updated @scope Type of chats for which autosave settings were updated @settings The new autosave settings; may be null if the settings are reset to default //@description Autosave settings for some type of chats were updated @scope Type of chats for which autosave settings were updated @settings The new autosave settings; may be null if the settings are reset to default
updateAutosaveSettings scope:AutosaveSettingsScope settings:scopeAutosaveSettings = Update; updateAutosaveSettings scope:AutosaveSettingsScope settings:scopeAutosaveSettings = Update;

View File

@ -2760,6 +2760,7 @@ 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);
td_->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_)); td_->updates_manager_->on_get_updates(std::move(ptr), std::move(promise_));
} }

View File

@ -33823,6 +33823,7 @@ void MessagesManager::on_create_new_dialog_success(int64 random_id, tl_object_pt
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>());
} }

View File

@ -1174,6 +1174,34 @@ 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,
tl_object_ptr<telegram_api::Updates> &updates_ptr) {
auto updates = get_updates(updates_ptr.get());
if (updates == nullptr) {
LOG(ERROR) << "Can't find updateGroupInvitePrivacyForbidden updates";
return;
}
vector<UserId> user_ids;
for (auto &update_ptr : *updates) {
if (update_ptr->get_id() != telegram_api::updateGroupInvitePrivacyForbidden::ID) {
continue;
}
auto update = telegram_api::move_object_as<telegram_api::updateGroupInvitePrivacyForbidden>(update_ptr);
UserId user_id(update->user_id_);
if (!user_id.is_valid()) {
LOG(ERROR) << "Receive " << to_string(update);
continue;
}
user_ids.push_back(user_id);
}
if (!user_ids.empty()) {
send_closure(G()->td(), &Td::send_update,
td_api::make_object<td_api::updateAddChatMembersPrivacyForbidden>(
dialog_id.get(), td_->contacts_manager_->get_user_ids_object(
user_ids, "process_group_invite_privacy_forbidden_updates")));
}
}
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) {
FlatHashSet<int64> random_ids; FlatHashSet<int64> random_ids;
auto updates = get_updates(updates_ptr); auto updates = get_updates(updates_ptr);
@ -3930,6 +3958,12 @@ void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateTranscribedAudi
promise.set_value(Unit()); promise.set_value(Unit());
} }
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateGroupInvitePrivacyForbidden> update,
Promise<Unit> &&promise) {
LOG(ERROR) << "Receive " << to_string(update);
promise.set_value(Unit());
}
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateAutoSaveSettings> update, Promise<Unit> &&promise) { void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateAutoSaveSettings> update, Promise<Unit> &&promise) {
td_->autosave_manager_->reload_autosave_settings(); td_->autosave_manager_->reload_autosave_settings();
promise.set_value(Unit()); promise.set_value(Unit());
@ -3937,9 +3971,4 @@ void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateAutoSaveSetting
// unsupported updates // unsupported updates
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateGroupInvitePrivacyForbidden> update,
Promise<Unit> &&promise) {
promise.set_value(Unit());
}
} // namespace td } // namespace td

View File

@ -103,6 +103,9 @@ 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,
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);
static const telegram_api::Message *get_message_by_random_id(const telegram_api::Updates *updates_ptr, static const telegram_api::Message *get_message_by_random_id(const telegram_api::Updates *updates_ptr,
@ -586,11 +589,11 @@ class UpdatesManager final : public Actor {
void on_update(tl_object_ptr<telegram_api::updateTranscribedAudio> update, Promise<Unit> &&promise); void on_update(tl_object_ptr<telegram_api::updateTranscribedAudio> update, Promise<Unit> &&promise);
void on_update(tl_object_ptr<telegram_api::updateGroupInvitePrivacyForbidden> update, Promise<Unit> &&promise);
void on_update(tl_object_ptr<telegram_api::updateAutoSaveSettings> update, Promise<Unit> &&promise); void on_update(tl_object_ptr<telegram_api::updateAutoSaveSettings> update, Promise<Unit> &&promise);
// unsupported updates // unsupported updates
void on_update(tl_object_ptr<telegram_api::updateGroupInvitePrivacyForbidden> update, Promise<Unit> &&promise);
}; };
} // namespace td } // namespace td