Move boost-related methods to BoostManager.

This commit is contained in:
levlam 2023-10-19 16:38:40 +03:00
parent cbfdf3c9a9
commit 8068507675
5 changed files with 274 additions and 261 deletions

View File

@ -6,8 +6,169 @@
//
#include "td/telegram/BoostManager.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/Global.h"
#include "td/telegram/LinkManager.h"
#include "td/telegram/MessagesManager.h"
#include "td/telegram/Td.h"
#include "td/utils/algorithm.h"
#include "td/utils/buffer.h"
#include "td/utils/SliceBuilder.h"
namespace td {
class GetBoostsStatusQuery final : public Td::ResultHandler {
Promise<td_api::object_ptr<td_api::chatBoostStatus>> promise_;
DialogId dialog_id_;
public:
explicit GetBoostsStatusQuery(Promise<td_api::object_ptr<td_api::chatBoostStatus>> &&promise)
: promise_(std::move(promise)) {
}
void send(DialogId dialog_id) {
dialog_id_ = dialog_id;
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read);
CHECK(input_peer != nullptr);
send_query(
G()->net_query_creator().create(telegram_api::premium_getBoostsStatus(std::move(input_peer)), {{dialog_id}}));
}
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::premium_getBoostsStatus>(packet);
if (result_ptr.is_error()) {
return on_error(result_ptr.move_as_error());
}
auto result = result_ptr.move_as_ok();
LOG(DEBUG) << "Receive result for GetBoostsStatusQuery: " << to_string(result);
if (result->level_ < 0 || result->current_level_boosts_ < 0 || result->boosts_ < result->current_level_boosts_ ||
(result->next_level_boosts_ != 0 && result->boosts_ >= result->next_level_boosts_)) {
LOG(ERROR) << "Receive invalid " << to_string(result);
if (result->level_ < 0) {
result->level_ = 0;
}
if (result->current_level_boosts_ < 0) {
result->current_level_boosts_ = 0;
}
if (result->boosts_ < result->current_level_boosts_) {
result->boosts_ = result->current_level_boosts_;
}
if (result->next_level_boosts_ != 0 && result->boosts_ >= result->next_level_boosts_) {
result->next_level_boosts_ = result->boosts_ + 1;
}
}
int32 premium_member_count = 0;
double premium_member_percentage = 0.0;
if (result->premium_audience_ != nullptr) {
premium_member_count = max(0, static_cast<int32>(result->premium_audience_->part_));
auto participant_count = max(static_cast<int32>(result->premium_audience_->total_), premium_member_count);
if (dialog_id_.get_type() == DialogType::Channel) {
td_->contacts_manager_->on_update_channel_participant_count(dialog_id_.get_channel_id(), participant_count);
}
if (participant_count > 0) {
premium_member_percentage = 100.0 * premium_member_count / participant_count;
}
}
auto giveaways = transform(std::move(result->prepaid_giveaways_),
[](telegram_api::object_ptr<telegram_api::prepaidGiveaway> giveaway) {
return td_api::make_object<td_api::prepaidPremiumGiveaway>(
giveaway->id_, giveaway->quantity_, giveaway->months_, giveaway->date_);
});
promise_.set_value(td_api::make_object<td_api::chatBoostStatus>(
result->boost_url_, result->my_boost_, result->level_, result->boosts_, result->current_level_boosts_,
result->next_level_boosts_, premium_member_count, premium_member_percentage, std::move(giveaways)));
}
void on_error(Status status) final {
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetBoostsStatusQuery");
promise_.set_error(std::move(status));
}
};
class ApplyBoostQuery final : public Td::ResultHandler {
Promise<Unit> promise_;
DialogId dialog_id_;
public:
explicit ApplyBoostQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
}
void send(DialogId dialog_id) {
dialog_id_ = dialog_id;
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read);
CHECK(input_peer != nullptr);
send_query(G()->net_query_creator().create(
telegram_api::premium_applyBoost(0, vector<int>(), std::move(input_peer)), {{dialog_id}}));
}
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::premium_applyBoost>(packet);
if (result_ptr.is_error()) {
return on_error(result_ptr.move_as_error());
}
promise_.set_value(Unit());
}
void on_error(Status status) final {
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "ApplyBoostQuery");
promise_.set_error(std::move(status));
}
};
class GetBoostsListQuery final : public Td::ResultHandler {
Promise<td_api::object_ptr<td_api::foundChatBoosts>> promise_;
DialogId dialog_id_;
public:
explicit GetBoostsListQuery(Promise<td_api::object_ptr<td_api::foundChatBoosts>> &&promise)
: promise_(std::move(promise)) {
}
void send(DialogId dialog_id, const string &offset, int32 limit) {
dialog_id_ = dialog_id;
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read);
CHECK(input_peer != nullptr);
send_query(G()->net_query_creator().create(
telegram_api::premium_getBoostsList(0, false /*ignored*/, std::move(input_peer), offset, limit)));
}
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::premium_getBoostsList>(packet);
if (result_ptr.is_error()) {
return on_error(result_ptr.move_as_error());
}
auto result = result_ptr.move_as_ok();
LOG(DEBUG) << "Receive result for GetBoostsListQuery: " << to_string(result);
td_->contacts_manager_->on_get_users(std::move(result->users_), "GetBoostsListQuery");
auto total_count = result->count_;
vector<td_api::object_ptr<td_api::chatBoost>> boosts;
for (auto &booster : result->boosts_) {
UserId user_id(booster->user_id_);
if (!user_id.is_valid()) {
continue;
}
auto expire_date = booster->expires_;
if (expire_date <= G()->unix_time()) {
continue;
}
boosts.push_back(td_api::make_object<td_api::chatBoost>(
td_->contacts_manager_->get_user_id_object(user_id, "chatBoost"), expire_date));
}
promise_.set_value(
td_api::make_object<td_api::foundChatBoosts>(total_count, std::move(boosts), result->next_offset_));
}
void on_error(Status status) final {
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetBoostsListQuery");
promise_.set_error(std::move(status));
}
};
BoostManager::BoostManager(Td *td, ActorShared<> parent) : td_(td), parent_(std::move(parent)) {
}
@ -15,4 +176,92 @@ void BoostManager::tear_down() {
parent_.reset();
}
void BoostManager::get_dialog_boost_status(DialogId dialog_id,
Promise<td_api::object_ptr<td_api::chatBoostStatus>> &&promise) {
if (!td_->messages_manager_->have_dialog_force(dialog_id, "get_dialog_boost_status")) {
return promise.set_error(Status::Error(400, "Chat not found"));
}
if (!td_->messages_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
return promise.set_error(Status::Error(400, "Can't access the chat"));
}
td_->create_handler<GetBoostsStatusQuery>(std::move(promise))->send(dialog_id);
}
void BoostManager::boost_dialog(DialogId dialog_id, Promise<Unit> &&promise) {
if (!td_->messages_manager_->have_dialog_force(dialog_id, "get_dialog_boost_status")) {
return promise.set_error(Status::Error(400, "Chat not found"));
}
if (!td_->messages_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
return promise.set_error(Status::Error(400, "Can't access the chat"));
}
td_->create_handler<ApplyBoostQuery>(std::move(promise))->send(dialog_id);
}
Result<std::pair<string, bool>> BoostManager::get_dialog_boost_link(DialogId dialog_id) {
if (!td_->messages_manager_->have_dialog_force(dialog_id, "get_dialog_boost_status")) {
return Status::Error(400, "Chat not found");
}
if (!td_->messages_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
return Status::Error(400, "Can't access the chat");
}
if (dialog_id.get_type() != DialogType::Channel ||
!td_->contacts_manager_->is_broadcast_channel(dialog_id.get_channel_id())) {
return Status::Error(400, "Can't boost the chat");
}
SliceBuilder sb;
sb << LinkManager::get_t_me_url();
auto username = td_->contacts_manager_->get_channel_first_username(dialog_id.get_channel_id());
bool is_public = !username.empty();
if (is_public) {
sb << username;
} else {
sb << "c/" << dialog_id.get_channel_id().get();
}
sb << "?boost";
return std::make_pair(sb.as_cslice().str(), is_public);
}
void BoostManager::get_dialog_boost_link_info(Slice url, Promise<DialogBoostLinkInfo> &&promise) {
auto r_dialog_boost_link_info = LinkManager::get_dialog_boost_link_info(url);
if (r_dialog_boost_link_info.is_error()) {
return promise.set_error(Status::Error(400, r_dialog_boost_link_info.error().message()));
}
auto info = r_dialog_boost_link_info.move_as_ok();
auto query_promise = PromiseCreator::lambda(
[info, promise = std::move(promise)](Result<DialogId> &&result) mutable { promise.set_value(std::move(info)); });
td_->messages_manager_->resolve_dialog(info.username, info.channel_id, std::move(query_promise));
}
td_api::object_ptr<td_api::chatBoostLinkInfo> BoostManager::get_chat_boost_link_info_object(
const DialogBoostLinkInfo &info) const {
CHECK(info.username.empty() == info.channel_id.is_valid());
bool is_public = !info.username.empty();
DialogId dialog_id =
is_public ? td_->messages_manager_->resolve_dialog_username(info.username) : DialogId(info.channel_id);
return td_api::make_object<td_api::chatBoostLinkInfo>(
is_public, td_->messages_manager_->get_chat_id_object(dialog_id, "chatBoostLinkInfo"));
}
void BoostManager::get_dialog_boosts(DialogId dialog_id, const string &offset, int32 limit,
Promise<td_api::object_ptr<td_api::foundChatBoosts>> &&promise) {
if (!td_->messages_manager_->have_dialog_force(dialog_id, "get_dialog_boost_status")) {
return promise.set_error(Status::Error(400, "Chat not found"));
}
if (!td_->messages_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
return promise.set_error(Status::Error(400, "Can't access the chat"));
}
if (limit <= 0) {
return promise.set_error(Status::Error(400, "Parameter limit must be positive"));
}
td_->create_handler<GetBoostsListQuery>(std::move(promise))->send(dialog_id, offset, limit);
}
} // namespace td

View File

@ -6,9 +6,15 @@
//
#pragma once
#include "td/telegram/DialogBoostLinkInfo.h"
#include "td/telegram/DialogId.h"
#include "td/telegram/td_api.h"
#include "td/actor/actor.h"
#include "td/utils/common.h"
#include "td/utils/Promise.h"
#include "td/utils/Slice.h"
namespace td {
@ -18,6 +24,19 @@ class BoostManager final : public Actor {
public:
BoostManager(Td *td, ActorShared<> parent);
void get_dialog_boost_status(DialogId dialog_id, Promise<td_api::object_ptr<td_api::chatBoostStatus>> &&promise);
void boost_dialog(DialogId dialog_id, Promise<Unit> &&promise);
Result<std::pair<string, bool>> get_dialog_boost_link(DialogId dialog_id);
void get_dialog_boost_link_info(Slice url, Promise<DialogBoostLinkInfo> &&promise);
td_api::object_ptr<td_api::chatBoostLinkInfo> get_chat_boost_link_info_object(const DialogBoostLinkInfo &info) const;
void get_dialog_boosts(DialogId dialog_id, const string &offset, int32 limit,
Promise<td_api::object_ptr<td_api::foundChatBoosts>> &&promise);
private:
void tear_down() final;

View File

@ -14,7 +14,6 @@
#include "td/telegram/FileReferenceManager.h"
#include "td/telegram/files/FileManager.h"
#include "td/telegram/Global.h"
#include "td/telegram/LinkManager.h"
#include "td/telegram/logevent/LogEvent.h"
#include "td/telegram/logevent/LogEventHelper.h"
#include "td/telegram/MediaArea.hpp"
@ -744,157 +743,6 @@ class ActivateStealthModeQuery final : public Td::ResultHandler {
}
};
class GetBoostsStatusQuery final : public Td::ResultHandler {
Promise<td_api::object_ptr<td_api::chatBoostStatus>> promise_;
DialogId dialog_id_;
public:
explicit GetBoostsStatusQuery(Promise<td_api::object_ptr<td_api::chatBoostStatus>> &&promise)
: promise_(std::move(promise)) {
}
void send(DialogId dialog_id) {
dialog_id_ = dialog_id;
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read);
CHECK(input_peer != nullptr);
send_query(
G()->net_query_creator().create(telegram_api::premium_getBoostsStatus(std::move(input_peer)), {{dialog_id}}));
}
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::premium_getBoostsStatus>(packet);
if (result_ptr.is_error()) {
return on_error(result_ptr.move_as_error());
}
auto result = result_ptr.move_as_ok();
LOG(DEBUG) << "Receive result for GetBoostsStatusQuery: " << to_string(result);
if (result->level_ < 0 || result->current_level_boosts_ < 0 || result->boosts_ < result->current_level_boosts_ ||
(result->next_level_boosts_ != 0 && result->boosts_ >= result->next_level_boosts_)) {
LOG(ERROR) << "Receive invalid " << to_string(result);
if (result->level_ < 0) {
result->level_ = 0;
}
if (result->current_level_boosts_ < 0) {
result->current_level_boosts_ = 0;
}
if (result->boosts_ < result->current_level_boosts_) {
result->boosts_ = result->current_level_boosts_;
}
if (result->next_level_boosts_ != 0 && result->boosts_ >= result->next_level_boosts_) {
result->next_level_boosts_ = result->boosts_ + 1;
}
}
int32 premium_member_count = 0;
double premium_member_percentage = 0.0;
if (result->premium_audience_ != nullptr) {
premium_member_count = max(0, static_cast<int32>(result->premium_audience_->part_));
auto participant_count = max(static_cast<int32>(result->premium_audience_->total_), premium_member_count);
if (dialog_id_.get_type() == DialogType::Channel) {
td_->contacts_manager_->on_update_channel_participant_count(dialog_id_.get_channel_id(), participant_count);
}
if (participant_count > 0) {
premium_member_percentage = 100.0 * premium_member_count / participant_count;
}
}
auto giveaways = transform(std::move(result->prepaid_giveaways_),
[](telegram_api::object_ptr<telegram_api::prepaidGiveaway> giveaway) {
return td_api::make_object<td_api::prepaidPremiumGiveaway>(
giveaway->id_, giveaway->quantity_, giveaway->months_, giveaway->date_);
});
promise_.set_value(td_api::make_object<td_api::chatBoostStatus>(
result->boost_url_, result->my_boost_, result->level_, result->boosts_, result->current_level_boosts_,
result->next_level_boosts_, premium_member_count, premium_member_percentage, std::move(giveaways)));
}
void on_error(Status status) final {
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetBoostsStatusQuery");
promise_.set_error(std::move(status));
}
};
class ApplyBoostQuery final : public Td::ResultHandler {
Promise<Unit> promise_;
DialogId dialog_id_;
public:
explicit ApplyBoostQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
}
void send(DialogId dialog_id) {
dialog_id_ = dialog_id;
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read);
CHECK(input_peer != nullptr);
send_query(G()->net_query_creator().create(
telegram_api::premium_applyBoost(0, vector<int>(), std::move(input_peer)), {{dialog_id}}));
}
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::premium_applyBoost>(packet);
if (result_ptr.is_error()) {
return on_error(result_ptr.move_as_error());
}
promise_.set_value(Unit());
}
void on_error(Status status) final {
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "ApplyBoostQuery");
promise_.set_error(std::move(status));
}
};
class GetBoostsListQuery final : public Td::ResultHandler {
Promise<td_api::object_ptr<td_api::foundChatBoosts>> promise_;
DialogId dialog_id_;
public:
explicit GetBoostsListQuery(Promise<td_api::object_ptr<td_api::foundChatBoosts>> &&promise)
: promise_(std::move(promise)) {
}
void send(DialogId dialog_id, const string &offset, int32 limit) {
dialog_id_ = dialog_id;
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read);
CHECK(input_peer != nullptr);
send_query(G()->net_query_creator().create(
telegram_api::premium_getBoostsList(0, false /*ignored*/, std::move(input_peer), offset, limit)));
}
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::premium_getBoostsList>(packet);
if (result_ptr.is_error()) {
return on_error(result_ptr.move_as_error());
}
auto result = result_ptr.move_as_ok();
LOG(DEBUG) << "Receive result for GetBoostsListQuery: " << to_string(result);
td_->contacts_manager_->on_get_users(std::move(result->users_), "GetBoostsListQuery");
auto total_count = result->count_;
vector<td_api::object_ptr<td_api::chatBoost>> boosts;
for (auto &booster : result->boosts_) {
UserId user_id(booster->user_id_);
if (!user_id.is_valid()) {
continue;
}
auto expire_date = booster->expires_;
if (expire_date <= G()->unix_time()) {
continue;
}
boosts.push_back(td_api::make_object<td_api::chatBoost>(
td_->contacts_manager_->get_user_id_object(user_id, "chatBoost"), expire_date));
}
promise_.set_value(
td_api::make_object<td_api::foundChatBoosts>(total_count, std::move(boosts), result->next_offset_));
}
void on_error(Status status) final {
td_->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetBoostsListQuery");
promise_.set_error(std::move(status));
}
};
class GetChatsToSendStoriesQuery final : public Td::ResultHandler {
Promise<Unit> promise_;
@ -2992,94 +2840,6 @@ void StoryManager::activate_stealth_mode(Promise<Unit> &&promise) {
td_->create_handler<ActivateStealthModeQuery>(std::move(promise))->send();
}
void StoryManager::get_dialog_boost_status(DialogId dialog_id,
Promise<td_api::object_ptr<td_api::chatBoostStatus>> &&promise) {
if (!td_->messages_manager_->have_dialog_force(dialog_id, "get_dialog_boost_status")) {
return promise.set_error(Status::Error(400, "Chat not found"));
}
if (!td_->messages_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
return promise.set_error(Status::Error(400, "Can't access the chat"));
}
td_->create_handler<GetBoostsStatusQuery>(std::move(promise))->send(dialog_id);
}
void StoryManager::boost_dialog(DialogId dialog_id, Promise<Unit> &&promise) {
if (!td_->messages_manager_->have_dialog_force(dialog_id, "get_dialog_boost_status")) {
return promise.set_error(Status::Error(400, "Chat not found"));
}
if (!td_->messages_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
return promise.set_error(Status::Error(400, "Can't access the chat"));
}
td_->create_handler<ApplyBoostQuery>(std::move(promise))->send(dialog_id);
}
Result<std::pair<string, bool>> StoryManager::get_dialog_boost_link(DialogId dialog_id) {
if (!td_->messages_manager_->have_dialog_force(dialog_id, "get_dialog_boost_status")) {
return Status::Error(400, "Chat not found");
}
if (!td_->messages_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
return Status::Error(400, "Can't access the chat");
}
if (dialog_id.get_type() != DialogType::Channel ||
!td_->contacts_manager_->is_broadcast_channel(dialog_id.get_channel_id())) {
return Status::Error(400, "Can't boost the chat");
}
SliceBuilder sb;
sb << LinkManager::get_t_me_url();
auto username = td_->contacts_manager_->get_channel_first_username(dialog_id.get_channel_id());
bool is_public = !username.empty();
if (is_public) {
sb << username;
} else {
sb << "c/" << dialog_id.get_channel_id().get();
}
sb << "?boost";
return std::make_pair(sb.as_cslice().str(), is_public);
}
void StoryManager::get_dialog_boost_link_info(Slice url, Promise<DialogBoostLinkInfo> &&promise) {
auto r_dialog_boost_link_info = LinkManager::get_dialog_boost_link_info(url);
if (r_dialog_boost_link_info.is_error()) {
return promise.set_error(Status::Error(400, r_dialog_boost_link_info.error().message()));
}
auto info = r_dialog_boost_link_info.move_as_ok();
auto query_promise = PromiseCreator::lambda(
[info, promise = std::move(promise)](Result<DialogId> &&result) mutable { promise.set_value(std::move(info)); });
td_->messages_manager_->resolve_dialog(info.username, info.channel_id, std::move(query_promise));
}
td_api::object_ptr<td_api::chatBoostLinkInfo> StoryManager::get_chat_boost_link_info_object(
const DialogBoostLinkInfo &info) const {
CHECK(info.username.empty() == info.channel_id.is_valid());
bool is_public = !info.username.empty();
DialogId dialog_id =
is_public ? td_->messages_manager_->resolve_dialog_username(info.username) : DialogId(info.channel_id);
return td_api::make_object<td_api::chatBoostLinkInfo>(
is_public, td_->messages_manager_->get_chat_id_object(dialog_id, "chatBoostLinkInfo"));
}
void StoryManager::get_dialog_boosts(DialogId dialog_id, const string &offset, int32 limit,
Promise<td_api::object_ptr<td_api::foundChatBoosts>> &&promise) {
if (!td_->messages_manager_->have_dialog_force(dialog_id, "get_dialog_boost_status")) {
return promise.set_error(Status::Error(400, "Chat not found"));
}
if (!td_->messages_manager_->have_input_peer(dialog_id, AccessRights::Read)) {
return promise.set_error(Status::Error(400, "Can't access the chat"));
}
if (limit <= 0) {
return promise.set_error(Status::Error(400, "Parameter limit must be positive"));
}
td_->create_handler<GetBoostsListQuery>(std::move(promise))->send(dialog_id, offset, limit);
}
bool StoryManager::have_story(StoryFullId story_full_id) const {
return get_story(story_full_id) != nullptr;
}

View File

@ -7,7 +7,6 @@
#pragma once
#include "td/telegram/ChannelId.h"
#include "td/telegram/DialogBoostLinkInfo.h"
#include "td/telegram/DialogDate.h"
#include "td/telegram/DialogId.h"
#include "td/telegram/files/FileId.h"
@ -36,7 +35,6 @@
#include "td/utils/FlatHashMap.h"
#include "td/utils/FlatHashSet.h"
#include "td/utils/Promise.h"
#include "td/utils/Slice.h"
#include "td/utils/Status.h"
#include "td/utils/WaitFreeHashMap.h"
#include "td/utils/WaitFreeHashSet.h"
@ -269,19 +267,6 @@ class StoryManager final : public Actor {
void activate_stealth_mode(Promise<Unit> &&promise);
void get_dialog_boost_status(DialogId dialog_id, Promise<td_api::object_ptr<td_api::chatBoostStatus>> &&promise);
void boost_dialog(DialogId dialog_id, Promise<Unit> &&promise);
Result<std::pair<string, bool>> get_dialog_boost_link(DialogId dialog_id);
void get_dialog_boost_link_info(Slice url, Promise<DialogBoostLinkInfo> &&promise);
td_api::object_ptr<td_api::chatBoostLinkInfo> get_chat_boost_link_info_object(const DialogBoostLinkInfo &info) const;
void get_dialog_boosts(DialogId dialog_id, const string &offset, int32 limit,
Promise<td_api::object_ptr<td_api::foundChatBoosts>> &&promise);
void remove_story_notifications_by_story_ids(DialogId dialog_id, const vector<StoryId> &story_ids);
StoryId on_get_story(DialogId owner_dialog_id, telegram_api::object_ptr<telegram_api::StoryItem> &&story_item_ptr);

View File

@ -1142,7 +1142,7 @@ class GetDialogBoostLinkInfoRequest final : public RequestActor<DialogBoostLinkI
promise.set_value(std::move(dialog_boost_link_info_));
return;
}
td_->story_manager_->get_dialog_boost_link_info(url_, std::move(promise));
td_->boost_manager_->get_dialog_boost_link_info(url_, std::move(promise));
}
void do_set_result(DialogBoostLinkInfo &&result) final {
@ -1150,7 +1150,7 @@ class GetDialogBoostLinkInfoRequest final : public RequestActor<DialogBoostLinkI
}
void do_send_result() final {
send_result(td_->story_manager_->get_chat_boost_link_info_object(dialog_boost_link_info_));
send_result(td_->boost_manager_->get_chat_boost_link_info_object(dialog_boost_link_info_));
}
public:
@ -6640,17 +6640,17 @@ void Td::on_request(uint64 id, const td_api::activateStoryStealthMode &request)
void Td::on_request(uint64 id, const td_api::getChatBoostStatus &request) {
CHECK_IS_USER();
CREATE_REQUEST_PROMISE();
story_manager_->get_dialog_boost_status(DialogId(request.chat_id_), std::move(promise));
boost_manager_->get_dialog_boost_status(DialogId(request.chat_id_), std::move(promise));
}
void Td::on_request(uint64 id, const td_api::boostChat &request) {
CHECK_IS_USER();
CREATE_OK_REQUEST_PROMISE();
story_manager_->boost_dialog(DialogId(request.chat_id_), std::move(promise));
boost_manager_->boost_dialog(DialogId(request.chat_id_), std::move(promise));
}
void Td::on_request(uint64 id, const td_api::getChatBoostLink &request) {
auto r_boost_link = story_manager_->get_dialog_boost_link(DialogId(request.chat_id_));
auto r_boost_link = boost_manager_->get_dialog_boost_link(DialogId(request.chat_id_));
if (r_boost_link.is_error()) {
send_closure(actor_id(this), &Td::send_error, id, r_boost_link.move_as_error());
} else {
@ -6668,7 +6668,7 @@ void Td::on_request(uint64 id, td_api::getChatBoosts &request) {
CHECK_IS_USER();
CLEAN_INPUT_STRING(request.offset_);
CREATE_REQUEST_PROMISE();
story_manager_->get_dialog_boosts(DialogId(request.chat_id_), request.offset_, request.limit_, std::move(promise));
boost_manager_->get_dialog_boosts(DialogId(request.chat_id_), request.offset_, request.limit_, std::move(promise));
}
void Td::on_request(uint64 id, const td_api::getAttachmentMenuBot &request) {