Generate boost links for supergroups and in new format,

This commit is contained in:
levlam 2024-02-09 14:39:35 +03:00
parent 7b6c5b3517
commit 49003c5cce
2 changed files with 8 additions and 7 deletions

View File

@ -3793,7 +3793,10 @@ chatBoostStatus boost_url:string applied_slot_ids:vector<int32> level:int32 gift
//@expiration_date Point in time (Unix timestamp) when the boost will expire
chatBoost id:string count:int32 source:ChatBoostSource start_date:int32 expiration_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, then there are no more results
//@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, then there are no more results
foundChatBoosts total_count:int32 boosts:vector<chatBoost> next_offset:string = FoundChatBoosts;
//@description Describes a slot for chat boost

View File

@ -414,22 +414,20 @@ Result<std::pair<string, bool>> BoostManager::get_dialog_boost_link(DialogId dia
if (!td_->dialog_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())) {
if (dialog_id.get_type() != DialogType::Channel) {
return Status::Error(400, "Can't boost the chat");
}
SliceBuilder sb;
sb << LinkManager::get_t_me_url();
sb << LinkManager::get_t_me_url() << "boost";
auto username = td_->contacts_manager_->get_channel_first_username(dialog_id.get_channel_id());
bool is_public = !username.empty();
if (is_public) {
sb << username;
sb << '/' << username;
} else {
sb << "c/" << dialog_id.get_channel_id().get();
sb << "?c=" << dialog_id.get_channel_id().get();
}
sb << "?boost";
return std::make_pair(sb.as_cslice().str(), is_public);
}