Add td_api::updateChatBoost.
This commit is contained in:
parent
50243afc9a
commit
b2a85a5d1b
@ -6457,6 +6457,11 @@ updateChatMember chat_id:int53 actor_user_id:int53 date:int32 invite_link:chatIn
|
||||
//@invite_link The invite link, which was used to send join request; may be null
|
||||
updateNewChatJoinRequest chat_id:int53 request:chatJoinRequest user_chat_id:int53 invite_link:chatInviteLink = Update;
|
||||
|
||||
//@description A chat boost has changed; for bots only
|
||||
//@chat_id Chat identifier
|
||||
//@boost New information about the boost
|
||||
updateChatBoost chat_id:int53 boost:chatBoost = Update;
|
||||
|
||||
|
||||
//@description Contains a list of updates @updates List of updates
|
||||
updates updates:vector<Update> = Updates;
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "td/telegram/BoostManager.h"
|
||||
|
||||
#include "td/telegram/AccessRights.h"
|
||||
#include "td/telegram/AuthManager.h"
|
||||
#include "td/telegram/ContactsManager.h"
|
||||
#include "td/telegram/Global.h"
|
||||
#include "td/telegram/LinkManager.h"
|
||||
@ -25,7 +26,7 @@
|
||||
namespace td {
|
||||
|
||||
static td_api::object_ptr<td_api::chatBoost> get_chat_boost_object(
|
||||
Td *td, telegram_api::object_ptr<telegram_api::boost> &&boost) {
|
||||
Td *td, const telegram_api::object_ptr<telegram_api::boost> &boost) {
|
||||
auto source = [&]() -> td_api::object_ptr<td_api::ChatBoostSource> {
|
||||
if (boost->giveaway_) {
|
||||
UserId user_id(boost->user_id_);
|
||||
@ -269,7 +270,7 @@ class GetBoostsListQuery final : public Td::ResultHandler {
|
||||
auto total_count = result->count_;
|
||||
vector<td_api::object_ptr<td_api::chatBoost>> boosts;
|
||||
for (auto &boost : result->boosts_) {
|
||||
auto chat_boost_object = get_chat_boost_object(td_, std::move(boost));
|
||||
auto chat_boost_object = get_chat_boost_object(td_, boost);
|
||||
if (chat_boost_object == nullptr || chat_boost_object->expiration_date_ <= G()->unix_time()) {
|
||||
continue;
|
||||
}
|
||||
@ -388,4 +389,25 @@ void BoostManager::get_dialog_boosts(DialogId dialog_id, bool only_gift_codes, c
|
||||
td_->create_handler<GetBoostsListQuery>(std::move(promise))->send(dialog_id, only_gift_codes, offset, limit);
|
||||
}
|
||||
|
||||
void BoostManager::on_update_dialog_boost(DialogId dialog_id, telegram_api::object_ptr<telegram_api::boost> &&boost) {
|
||||
if (!td_->auth_manager_->is_bot()) {
|
||||
LOG(ERROR) << "Receive updateBotChatBoost by a non-bot";
|
||||
return;
|
||||
}
|
||||
if (!dialog_id.is_valid() || !td_->messages_manager_->have_dialog_info_force(dialog_id, "on_update_dialog_boost")) {
|
||||
LOG(ERROR) << "Receive updateBotChatBoost in " << dialog_id;
|
||||
return;
|
||||
}
|
||||
auto chat_boost_object = get_chat_boost_object(td_, boost);
|
||||
if (chat_boost_object == nullptr) {
|
||||
LOG(ERROR) << "Receive wrong updateBotChatBoost in " << dialog_id << ": " << to_string(boost);
|
||||
return;
|
||||
}
|
||||
td_->messages_manager_->force_create_dialog(dialog_id, "on_update_dialog_boost", true);
|
||||
send_closure(
|
||||
G()->td(), &Td::send_update,
|
||||
td_api::make_object<td_api::updateChatBoost>(
|
||||
td_->messages_manager_->get_chat_id_object(dialog_id, "updateChatBoost"), std::move(chat_boost_object)));
|
||||
}
|
||||
|
||||
} // namespace td
|
||||
|
@ -43,6 +43,8 @@ class BoostManager final : public Actor {
|
||||
void get_dialog_boosts(DialogId dialog_id, bool only_gift_codes, const string &offset, int32 limit,
|
||||
Promise<td_api::object_ptr<td_api::foundChatBoosts>> &&promise);
|
||||
|
||||
void on_update_dialog_boost(DialogId dialog_id, telegram_api::object_ptr<telegram_api::boost> &&boost);
|
||||
|
||||
private:
|
||||
void tear_down() final;
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "td/telegram/AttachMenuManager.h"
|
||||
#include "td/telegram/AuthManager.h"
|
||||
#include "td/telegram/AutosaveManager.h"
|
||||
#include "td/telegram/BoostManager.h"
|
||||
#include "td/telegram/CallbackQueriesManager.h"
|
||||
#include "td/telegram/CallManager.h"
|
||||
#include "td/telegram/ChannelId.h"
|
||||
@ -3029,6 +3030,12 @@ void UpdatesManager::process_qts_update(tl_object_ptr<telegram_api::Update> &&up
|
||||
add_qts(qts).set_value(Unit());
|
||||
break;
|
||||
}
|
||||
case telegram_api::updateBotChatBoost::ID: {
|
||||
auto update = move_tl_object_as<telegram_api::updateBotChatBoost>(update_ptr);
|
||||
td_->boost_manager_->on_update_dialog_boost(DialogId(update->peer_), std::move(update->boost_));
|
||||
add_qts(qts).set_value(Unit());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
UNREACHABLE();
|
||||
break;
|
||||
@ -3793,6 +3800,7 @@ bool UpdatesManager::is_qts_update(const telegram_api::Update *update) {
|
||||
case telegram_api::updateChatParticipant::ID:
|
||||
case telegram_api::updateChannelParticipant::ID:
|
||||
case telegram_api::updateBotChatInviteRequester::ID:
|
||||
case telegram_api::updateBotChatBoost::ID:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
@ -3813,6 +3821,8 @@ int32 UpdatesManager::get_update_qts(const telegram_api::Update *update) {
|
||||
return static_cast<const telegram_api::updateChannelParticipant *>(update)->qts_;
|
||||
case telegram_api::updateBotChatInviteRequester::ID:
|
||||
return static_cast<const telegram_api::updateBotChatInviteRequester *>(update)->qts_;
|
||||
case telegram_api::updateBotChatBoost::ID:
|
||||
return static_cast<const telegram_api::updateBotChatBoost *>(update)->qts_;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
@ -4286,6 +4296,11 @@ void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateBotChatInviteRe
|
||||
add_pending_qts_update(std::move(update), qts, std::move(promise));
|
||||
}
|
||||
|
||||
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateBotChatBoost> update, Promise<Unit> &&promise) {
|
||||
auto qts = update->qts_;
|
||||
add_pending_qts_update(std::move(update), qts, std::move(promise));
|
||||
}
|
||||
|
||||
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateTheme> update, Promise<Unit> &&promise) {
|
||||
td_->theme_manager_->on_update_theme(std::move(update->theme_), std::move(promise));
|
||||
}
|
||||
@ -4366,8 +4381,4 @@ void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateNewAuthorizatio
|
||||
|
||||
// unsupported updates
|
||||
|
||||
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateBotChatBoost> update, Promise<Unit> &&promise) {
|
||||
promise.set_value(Unit());
|
||||
}
|
||||
|
||||
} // namespace td
|
||||
|
@ -615,6 +615,7 @@ class UpdatesManager final : public Actor {
|
||||
void on_update(tl_object_ptr<telegram_api::updateChatParticipant> update, Promise<Unit> &&promise);
|
||||
void on_update(tl_object_ptr<telegram_api::updateChannelParticipant> update, Promise<Unit> &&promise);
|
||||
void on_update(tl_object_ptr<telegram_api::updateBotChatInviteRequester> update, Promise<Unit> &&promise);
|
||||
void on_update(tl_object_ptr<telegram_api::updateBotChatBoost> update, Promise<Unit> &&promise);
|
||||
|
||||
void on_update(tl_object_ptr<telegram_api::updateTheme> update, Promise<Unit> &&promise);
|
||||
|
||||
@ -641,8 +642,6 @@ class UpdatesManager final : public Actor {
|
||||
void on_update(tl_object_ptr<telegram_api::updateNewAuthorization> update, Promise<Unit> &&promise);
|
||||
|
||||
// unsupported updates
|
||||
|
||||
void on_update(tl_object_ptr<telegram_api::updateBotChatBoost> update, Promise<Unit> &&promise);
|
||||
};
|
||||
|
||||
} // namespace td
|
||||
|
Loading…
Reference in New Issue
Block a user