diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 1a4cc674f..f344441af 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -3935,6 +3935,10 @@ updatePollAnswer poll_id:int64 user_id:int53 option_ids:vector = Update; //@old_chat_member Previous chat member @new_chat_member New chat member updateChatMember chat_id:int53 actor_user_id:int53 date:int32 invite_link:chatInviteLink old_chat_member:chatMember new_chat_member:chatMember = Update; +//@description A user sent a join request to a chat; for bots only @chat_id Chat identifier @user_id Identifier of the user, which sent the join request +//@bio A short user bio @date Point in time (Unix timestamp) when the request was sent @invite_link The invite link, which was used to send join request; may be null +updateNewChatJoinRequest chat_id:int53 user_id:int53 bio:string date:int32 invite_link:chatInviteLink = Update; + //@description Contains a list of updates @updates List of updates updates updates:vector = Updates; diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index ebab9cca2..d03a52c71 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -13625,14 +13625,10 @@ void ContactsManager::on_update_bot_stopped(UserId user_id, int32 date, bool is_ LOG(ERROR) << "Receive updateBotStopped by non-bot"; return; } - if (!user_id.is_valid() || date <= 0) { + if (date <= 0 || !have_user_force(user_id)) { LOG(ERROR) << "Receive invalid updateBotStopped by " << user_id << " at " << date; return; } - if (!have_user_force(user_id)) { - LOG(ERROR) << "Receive updateBotStopped by unknown " << user_id; - return; - } DialogParticipant old_dialog_participant(DialogId(get_my_id()), user_id, date, DialogParticipantStatus::Banned(0)); DialogParticipant new_dialog_participant(DialogId(get_my_id()), user_id, date, DialogParticipantStatus::Member()); @@ -13746,6 +13742,22 @@ void ContactsManager::on_update_channel_participant(ChannelId channel_id, UserId new_dialog_participant); } +void ContactsManager::on_update_chat_invite_requester(DialogId dialog_id, UserId user_id, string about, int32 date, + DialogInviteLink invite_link) { + if (!td_->auth_manager_->is_bot() || date <= 0 || !have_user_force(user_id) || + !td_->messages_manager_->have_dialog_info_force(dialog_id)) { + LOG(ERROR) << "Receive invalid updateBotChatInviteRequester by " << user_id << " in " << dialog_id << " at " + << date; + return; + } + td_->messages_manager_->force_create_dialog(dialog_id, "on_update_chat_invite_requester", true); + + send_closure(G()->td(), &Td::send_update, + td_api::make_object( + dialog_id.get(), get_user_id_object(user_id, "on_update_chat_invite_requester"), about, date, + invite_link.get_chat_invite_link_object(this))); +} + void ContactsManager::update_contacts_hints(const User *u, UserId user_id, bool from_database) { bool is_contact = is_user_contact(u, user_id, false); if (td_->auth_manager_->is_bot()) { diff --git a/td/telegram/ContactsManager.h b/td/telegram/ContactsManager.h index 52761b0c6..abff47b0e 100644 --- a/td/telegram/ContactsManager.h +++ b/td/telegram/ContactsManager.h @@ -202,6 +202,8 @@ class ContactsManager final : public Actor { void on_update_channel_participant(ChannelId channel_id, UserId user_id, int32 date, DialogInviteLink invite_link, tl_object_ptr old_participant, tl_object_ptr new_participant); + void on_update_chat_invite_requester(DialogId dialog_id, UserId user_id, string about, int32 date, + DialogInviteLink invite_link); int32 on_update_peer_located(vector> &&peers, bool from_update); diff --git a/td/telegram/UpdatesManager.cpp b/td/telegram/UpdatesManager.cpp index f403ee835..c50195871 100644 --- a/td/telegram/UpdatesManager.cpp +++ b/td/telegram/UpdatesManager.cpp @@ -2119,6 +2119,14 @@ void UpdatesManager::process_qts_update(tl_object_ptr &&up add_qts(qts).set_value(Unit()); break; } + case telegram_api::updateBotChatInviteRequester::ID: { + auto update = move_tl_object_as(update_ptr); + td_->contacts_manager_->on_update_chat_invite_requester(DialogId(update->peer_), UserId(update->user_id_), + std::move(update->about_), update->date_, + DialogInviteLink(std::move(update->invite_))); + add_qts(qts).set_value(Unit()); + break; + } default: UNREACHABLE(); break; @@ -2774,6 +2782,7 @@ bool UpdatesManager::is_qts_update(const telegram_api::Update *update) { case telegram_api::updateBotStopped::ID: case telegram_api::updateChatParticipant::ID: case telegram_api::updateChannelParticipant::ID: + case telegram_api::updateBotChatInviteRequester::ID: return true; default: return false; @@ -2792,6 +2801,8 @@ int32 UpdatesManager::get_update_qts(const telegram_api::Update *update) { return static_cast(update)->qts_; case telegram_api::updateChannelParticipant::ID: return static_cast(update)->qts_; + case telegram_api::updateBotChatInviteRequester::ID: + return static_cast(update)->qts_; default: return 0; } @@ -3207,6 +3218,12 @@ void UpdatesManager::on_update(tl_object_ptr update, + Promise &&promise) { + auto qts = update->qts_; + add_pending_qts_update(std::move(update), qts, std::move(promise)); +} + void UpdatesManager::on_update(tl_object_ptr update, Promise &&promise) { td_->theme_manager_->on_update_theme(std::move(update->theme_), std::move(promise)); } @@ -3219,8 +3236,4 @@ void UpdatesManager::on_update(tl_object_ptr update, - Promise &&promise) { -} - } // namespace td diff --git a/td/telegram/UpdatesManager.h b/td/telegram/UpdatesManager.h index 05527d8f6..cdbed6c6d 100644 --- a/td/telegram/UpdatesManager.h +++ b/td/telegram/UpdatesManager.h @@ -487,14 +487,13 @@ class UpdatesManager final : public Actor { void on_update(tl_object_ptr update, Promise &&promise); void on_update(tl_object_ptr update, Promise &&promise); void on_update(tl_object_ptr update, Promise &&promise); + void on_update(tl_object_ptr update, Promise &&promise); void on_update(tl_object_ptr update, Promise &&promise); void on_update(tl_object_ptr update, Promise &&promise); // unsupported updates - - void on_update(tl_object_ptr update, Promise &&promise); }; } // namespace td