Add td_api::getChatBoosts.
This commit is contained in:
parent
9a9cf8c48d
commit
583168767d
@ -649,7 +649,7 @@ inputChatPhotoSticker sticker:chatPhotoSticker = InputChatPhoto;
|
||||
chatPermissions can_send_basic_messages:Bool can_send_audios:Bool can_send_documents:Bool can_send_photos:Bool can_send_videos:Bool can_send_video_notes:Bool can_send_voice_notes:Bool can_send_polls:Bool can_send_other_messages:Bool can_add_web_page_previews:Bool can_change_info:Bool can_invite_users:Bool can_pin_messages:Bool can_manage_topics:Bool = ChatPermissions;
|
||||
|
||||
//@description Describes rights of the administrator
|
||||
//@can_manage_chat True, if the administrator can get chat event log, get chat statistics, get message statistics in channels, get channel members, see anonymous administrators in supergroups and ignore slow mode. Implied by any other privilege; applicable to supergroups and channels only
|
||||
//@can_manage_chat True, if the administrator can get chat event log, get chat statistics, get chat boosts in channels, get message statistics in channels, get channel members, see anonymous administrators in supergroups and ignore slow mode. Implied by any other privilege; applicable to supergroups and channels only
|
||||
//@can_change_info True, if the administrator can change the chat title, photo, and other settings
|
||||
//@can_post_messages True, if the administrator can create channel posts; applicable to channels only
|
||||
//@can_edit_messages True, if the administrator can edit messages of other users and pin messages; applicable to channels only
|
||||
@ -3362,6 +3362,12 @@ chatActiveStories chat_id:int53 list:StoryList order:int53 max_read_story_id:int
|
||||
//@premium_member_percentage A percentage of Telegram Premium subscribers joined the chat; always 0 if the current user isn't an administrator in the chat
|
||||
chatBoostStatus is_boosted:Bool level:int32 boost_count:int32 current_level_boost_count:int32 next_level_boost_count:int32 premium_member_count:int32 premium_member_percentage:double = ChatBoostStatus;
|
||||
|
||||
//@description Describes a boost of a chat @user_id Identifier of a user that boosted the chat @expire_date Date when the boost will automatically expire if the user will not prolongate their Telegram Premium subscription
|
||||
chatBoost user_id:int53 expire_date:int32 = ChatBoost;
|
||||
|
||||
//@description Contains a list of boosts applied to a chat @total_count Total number of boosts applied to the chat @boosts List of boosts @next_offset The offset for the next request. If empty, there are no more results
|
||||
foundChatBoosts total_count:int32 boosts:vector<chatBoost> next_offset:string = FoundChatBoosts;
|
||||
|
||||
|
||||
//@class CallDiscardReason @description Describes the reason why a call was discarded
|
||||
|
||||
@ -7707,6 +7713,12 @@ getChatBoostLink chat_id:int53 = ChatBoostLink;
|
||||
//@description Returns information about a link to boost a chat. Can be called for any internal link of the type internalLinkTypeChatBoost @url The link to boost a chat
|
||||
getChatBoostLinkInfo url:string = ChatBoostLinkInfo;
|
||||
|
||||
//@description Returns list of boosts applied to a chat. The user must be an administrator in the channel chat to get the list of boosts
|
||||
//@chat_id Identifier of the chat
|
||||
//@offset Offset of the first entry to return as received from the previous request; use empty string to get the first chunk of results
|
||||
//@limit The maximum number of boosts to be returned; up to 100. For optimal performance, the number of returned boosts can be smaller than the specified limit
|
||||
getChatBoosts chat_id:int53 offset:string limit:int32 = FoundChatBoosts;
|
||||
|
||||
|
||||
//@description Returns information about a bot that can be added to attachment or side menu @bot_user_id Bot's user identifier
|
||||
getAttachmentMenuBot bot_user_id:int53 = AttachmentMenuBot;
|
||||
|
@ -874,6 +874,58 @@ class ApplyBoostQuery final : public Td::ResultHandler {
|
||||
}
|
||||
};
|
||||
|
||||
class GetBoostersListQuery final : public Td::ResultHandler {
|
||||
Promise<td_api::object_ptr<td_api::foundChatBoosts>> promise_;
|
||||
DialogId dialog_id_;
|
||||
|
||||
public:
|
||||
explicit GetBoostersListQuery(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::stories_getBoostersList(std::move(input_peer), offset, limit)));
|
||||
}
|
||||
|
||||
void on_result(BufferSlice packet) final {
|
||||
auto result_ptr = fetch_result<telegram_api::stories_getBoostersList>(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 GetBoostersListQuery: " << to_string(result);
|
||||
td_->contacts_manager_->on_get_users(std::move(result->users_), "GetBoostersListQuery");
|
||||
|
||||
auto total_count = result->count_;
|
||||
vector<td_api::object_ptr<td_api::chatBoost>> boosts;
|
||||
for (auto &booster : result->boosters_) {
|
||||
UserId user_id(booster->user_id_);
|
||||
if (!user_id.is_valid()) {
|
||||
LOG(ERROR) << "Receive " << to_string(booster);
|
||||
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, "GetBoostersListQuery");
|
||||
promise_.set_error(std::move(status));
|
||||
}
|
||||
};
|
||||
|
||||
class GetChatsToSendStoriesQuery final : public Td::ResultHandler {
|
||||
Promise<Unit> promise_;
|
||||
|
||||
@ -3039,6 +3091,21 @@ td_api::object_ptr<td_api::chatBoostLinkInfo> StoryManager::get_chat_boost_link_
|
||||
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<GetBoostersListQuery>(std::move(promise))->send(dialog_id, offset, limit);
|
||||
}
|
||||
|
||||
bool StoryManager::have_story(StoryFullId story_full_id) const {
|
||||
return get_story(story_full_id) != nullptr;
|
||||
}
|
||||
|
@ -283,6 +283,9 @@ class StoryManager final : public Actor {
|
||||
|
||||
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);
|
||||
|
@ -6647,6 +6647,13 @@ void Td::on_request(uint64 id, td_api::getChatBoostLinkInfo &request) {
|
||||
CREATE_REQUEST(GetDialogBoostLinkInfoRequest, std::move(request.url_));
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::getAttachmentMenuBot &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_REQUEST_PROMISE();
|
||||
|
@ -1050,6 +1050,8 @@ class Td final : public Actor {
|
||||
|
||||
void on_request(uint64 id, td_api::getChatBoostLinkInfo &request);
|
||||
|
||||
void on_request(uint64 id, td_api::getChatBoosts &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::getAttachmentMenuBot &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::toggleBotIsAddedToAttachmentMenu &request);
|
||||
|
@ -4308,6 +4308,12 @@ class CliClient final : public Actor {
|
||||
send_request(td_api::make_object<td_api::getChatBoostLink>(chat_id));
|
||||
} else if (op == "gcbli") {
|
||||
send_request(td_api::make_object<td_api::getChatBoostLinkInfo>(args));
|
||||
} else if (op == "gcb") {
|
||||
ChatId chat_id;
|
||||
string offset;
|
||||
string limit;
|
||||
get_args(args, chat_id);
|
||||
send_request(td_api::make_object<td_api::getChatBoosts>(chat_id, offset, as_limit(limit)));
|
||||
} else if (op == "gamb") {
|
||||
UserId user_id;
|
||||
get_args(args, user_id);
|
||||
|
Loading…
Reference in New Issue
Block a user