Add td_api::getBusinessFeatures.
This commit is contained in:
parent
e895a46ed5
commit
4c14af9b52
@ -4955,7 +4955,7 @@ premiumFeatureAdvancedChatManagement = PremiumFeature;
|
|||||||
//@description A badge in the user's profile
|
//@description A badge in the user's profile
|
||||||
premiumFeatureProfileBadge = PremiumFeature;
|
premiumFeatureProfileBadge = PremiumFeature;
|
||||||
|
|
||||||
//@description An emoji status shown along with the user's name
|
//@description The ability to show an emoji status along with the user's name
|
||||||
premiumFeatureEmojiStatus = PremiumFeature;
|
premiumFeatureEmojiStatus = PremiumFeature;
|
||||||
|
|
||||||
//@description Profile photo animation on message and chat screens
|
//@description Profile photo animation on message and chat screens
|
||||||
@ -4993,6 +4993,42 @@ premiumFeatureMessagePrivacy = PremiumFeature;
|
|||||||
premiumFeatureLastSeenTimes = PremiumFeature;
|
premiumFeatureLastSeenTimes = PremiumFeature;
|
||||||
|
|
||||||
|
|
||||||
|
//@class BusinessFeature @description Describes a feature available to Business user accounts
|
||||||
|
|
||||||
|
//@description The ability to set location
|
||||||
|
businessFeatureLocation = BusinessFeature;
|
||||||
|
|
||||||
|
//@description The ability to set opening hours
|
||||||
|
businessFeatureOpeningHours = BusinessFeature;
|
||||||
|
|
||||||
|
//@description The ability to use quick replies
|
||||||
|
businessFeatureQuickReplies = BusinessFeature;
|
||||||
|
|
||||||
|
//@description The ability to set up a greeting message
|
||||||
|
businessFeatureGreetingMessage = BusinessFeature;
|
||||||
|
|
||||||
|
//@description The ability to set up an away message
|
||||||
|
businessFeatureAwayMessage = BusinessFeature;
|
||||||
|
|
||||||
|
//@description The ability to create links to the business account with predefined message text
|
||||||
|
businessFeatureAccountLinks = BusinessFeature;
|
||||||
|
|
||||||
|
//@description The ability to customize intro
|
||||||
|
businessFeatureIntro = BusinessFeature;
|
||||||
|
|
||||||
|
//@description The ability to connect a bot to the account
|
||||||
|
businessFeatureBots = BusinessFeature;
|
||||||
|
|
||||||
|
//@description The ability to show an emoji status along with the business name
|
||||||
|
businessFeatureEmojiStatus = BusinessFeature;
|
||||||
|
|
||||||
|
//@description The ability to display folder names for each chat in the chat list
|
||||||
|
businessFeatureChatFolderTags = BusinessFeature;
|
||||||
|
|
||||||
|
//@description Allowed to use many additional features for stories
|
||||||
|
businessFeatureUpgradedStories = BusinessFeature;
|
||||||
|
|
||||||
|
|
||||||
//@class PremiumStoryFeature @description Describes a story feature available to Premium users
|
//@class PremiumStoryFeature @description Describes a story feature available to Premium users
|
||||||
|
|
||||||
//@description Stories of the current user are displayed before stories of non-Premium contacts, supergroups, and channels
|
//@description Stories of the current user are displayed before stories of non-Premium contacts, supergroups, and channels
|
||||||
@ -5026,6 +5062,9 @@ premiumLimit type:PremiumLimitType default_value:int32 premium_value:int32 = Pre
|
|||||||
//@payment_link An internal link to be opened to pay for Telegram Premium if store payment isn't possible; may be null if direct payment isn't available
|
//@payment_link An internal link to be opened to pay for Telegram Premium if store payment isn't possible; may be null if direct payment isn't available
|
||||||
premiumFeatures features:vector<PremiumFeature> limits:vector<premiumLimit> payment_link:InternalLinkType = PremiumFeatures;
|
premiumFeatures features:vector<PremiumFeature> limits:vector<premiumLimit> payment_link:InternalLinkType = PremiumFeatures;
|
||||||
|
|
||||||
|
//@description Contains information about features, available to Business user accounts @features The list of available business features
|
||||||
|
businessFeatures features:vector<BusinessFeature> = BusinessFeatures;
|
||||||
|
|
||||||
|
|
||||||
//@class PremiumSource @description Describes a source from which the Premium features screen is opened
|
//@class PremiumSource @description Describes a source from which the Premium features screen is opened
|
||||||
|
|
||||||
@ -10324,6 +10363,10 @@ assignAppStoreTransaction receipt:bytes purpose:StorePaymentPurpose = Ok;
|
|||||||
assignGooglePlayTransaction package_name:string store_product_id:string purchase_token:string purpose:StorePaymentPurpose = Ok;
|
assignGooglePlayTransaction package_name:string store_product_id:string purchase_token:string purpose:StorePaymentPurpose = Ok;
|
||||||
|
|
||||||
|
|
||||||
|
//@description Returns information about features, available to Business users @source Source of the request; pass null if the method is called from settings or some non-standard source
|
||||||
|
getBusinessFeatures source:BusinessFeature = BusinessFeatures;
|
||||||
|
|
||||||
|
|
||||||
//@description Accepts Telegram terms of services @terms_of_service_id Terms of service identifier
|
//@description Accepts Telegram terms of services @terms_of_service_id Terms of service identifier
|
||||||
acceptTermsOfService terms_of_service_id:string = Ok;
|
acceptTermsOfService terms_of_service_id:string = Ok;
|
||||||
|
|
||||||
|
@ -111,6 +111,43 @@ static td_api::object_ptr<td_api::PremiumFeature> get_premium_feature_object(Sli
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static td_api::object_ptr<td_api::BusinessFeature> get_business_feature_object(Slice business_feature) {
|
||||||
|
if (business_feature == "business_location") {
|
||||||
|
return td_api::make_object<td_api::businessFeatureLocation>();
|
||||||
|
}
|
||||||
|
if (business_feature == "business_hours") {
|
||||||
|
return td_api::make_object<td_api::businessFeatureOpeningHours>();
|
||||||
|
}
|
||||||
|
if (business_feature == "quick_replies") {
|
||||||
|
return td_api::make_object<td_api::businessFeatureQuickReplies>();
|
||||||
|
}
|
||||||
|
if (business_feature == "greeting_message") {
|
||||||
|
return td_api::make_object<td_api::businessFeatureGreetingMessage>();
|
||||||
|
}
|
||||||
|
if (business_feature == "away_message") {
|
||||||
|
return td_api::make_object<td_api::businessFeatureAwayMessage>();
|
||||||
|
}
|
||||||
|
if (business_feature == "business_links") {
|
||||||
|
return td_api::make_object<td_api::businessFeatureAccountLinks>();
|
||||||
|
}
|
||||||
|
if (business_feature == "business_intro") {
|
||||||
|
return td_api::make_object<td_api::businessFeatureIntro>();
|
||||||
|
}
|
||||||
|
if (business_feature == "business_bots") {
|
||||||
|
return td_api::make_object<td_api::businessFeatureBots>();
|
||||||
|
}
|
||||||
|
if (business_feature == "emoji_status") {
|
||||||
|
return td_api::make_object<td_api::businessFeatureEmojiStatus>();
|
||||||
|
}
|
||||||
|
if (business_feature == "folder_tags") {
|
||||||
|
return td_api::make_object<td_api::businessFeatureChatFolderTags>();
|
||||||
|
}
|
||||||
|
if (business_feature == "stories") {
|
||||||
|
return td_api::make_object<td_api::businessFeatureUpgradedStories>();
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
Result<telegram_api::object_ptr<telegram_api::InputPeer>> get_boost_input_peer(Td *td, DialogId dialog_id) {
|
Result<telegram_api::object_ptr<telegram_api::InputPeer>> get_boost_input_peer(Td *td, DialogId dialog_id) {
|
||||||
if (dialog_id == DialogId()) {
|
if (dialog_id == DialogId()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -774,6 +811,40 @@ static string get_premium_source(const td_api::PremiumFeature *feature) {
|
|||||||
return string();
|
return string();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static string get_premium_source(const td_api::BusinessFeature *feature) {
|
||||||
|
if (feature == nullptr) {
|
||||||
|
return "business";
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (feature->get_id()) {
|
||||||
|
case td_api::businessFeatureLocation::ID:
|
||||||
|
return "business_location";
|
||||||
|
case td_api::businessFeatureOpeningHours::ID:
|
||||||
|
return "business_hours";
|
||||||
|
case td_api::businessFeatureQuickReplies::ID:
|
||||||
|
return "quick_replies";
|
||||||
|
case td_api::businessFeatureGreetingMessage::ID:
|
||||||
|
return "greeting_message";
|
||||||
|
case td_api::businessFeatureAwayMessage::ID:
|
||||||
|
return "away_message";
|
||||||
|
case td_api::businessFeatureAccountLinks::ID:
|
||||||
|
return "business_links";
|
||||||
|
case td_api::businessFeatureIntro::ID:
|
||||||
|
return "business_intro";
|
||||||
|
case td_api::businessFeatureBots::ID:
|
||||||
|
return "business_bots";
|
||||||
|
case td_api::businessFeatureEmojiStatus::ID:
|
||||||
|
return "emoji_status";
|
||||||
|
case td_api::businessFeatureChatFolderTags::ID:
|
||||||
|
return "folder_tags";
|
||||||
|
case td_api::businessFeatureUpgradedStories::ID:
|
||||||
|
return "stories";
|
||||||
|
default:
|
||||||
|
UNREACHABLE();
|
||||||
|
}
|
||||||
|
return string();
|
||||||
|
}
|
||||||
|
|
||||||
static string get_premium_source(const td_api::PremiumStoryFeature *feature) {
|
static string get_premium_source(const td_api::PremiumStoryFeature *feature) {
|
||||||
if (feature == nullptr) {
|
if (feature == nullptr) {
|
||||||
return string();
|
return string();
|
||||||
@ -961,6 +1032,39 @@ void get_premium_features(Td *td, const td_api::object_ptr<td_api::PremiumSource
|
|||||||
td_api::make_object<td_api::premiumFeatures>(std::move(features), std::move(limits), std::move(payment_link)));
|
td_api::make_object<td_api::premiumFeatures>(std::move(features), std::move(limits), std::move(payment_link)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void get_business_features(Td *td, const td_api::object_ptr<td_api::BusinessFeature> &source,
|
||||||
|
Promise<td_api::object_ptr<td_api::businessFeatures>> &&promise) {
|
||||||
|
auto business_features =
|
||||||
|
full_split(G()->get_option_string("business_features",
|
||||||
|
"business_location,business_hours,quick_replies,greeting_message,away_message,"
|
||||||
|
"business_links,business_intro,business_bots,emoji_status,folder_tags,stories"),
|
||||||
|
',');
|
||||||
|
vector<td_api::object_ptr<td_api::BusinessFeature>> features;
|
||||||
|
for (const auto &business_feature : business_features) {
|
||||||
|
auto feature = get_business_feature_object(business_feature);
|
||||||
|
if (feature != nullptr) {
|
||||||
|
features.push_back(std::move(feature));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
auto source_str = get_premium_source(source.get());
|
||||||
|
if (!source_str.empty()) {
|
||||||
|
vector<telegram_api::object_ptr<telegram_api::jsonObjectValue>> data;
|
||||||
|
vector<telegram_api::object_ptr<telegram_api::JSONValue>> promo_order;
|
||||||
|
for (const auto &business_feature : business_features) {
|
||||||
|
promo_order.push_back(telegram_api::make_object<telegram_api::jsonString>(business_feature));
|
||||||
|
}
|
||||||
|
data.push_back(telegram_api::make_object<telegram_api::jsonObjectValue>(
|
||||||
|
"business_promo_order", telegram_api::make_object<telegram_api::jsonArray>(std::move(promo_order))));
|
||||||
|
data.push_back(telegram_api::make_object<telegram_api::jsonObjectValue>(
|
||||||
|
"source", telegram_api::make_object<telegram_api::jsonString>(source_str)));
|
||||||
|
save_app_log(td, "business.promo_screen_show", DialogId(),
|
||||||
|
telegram_api::make_object<telegram_api::jsonObject>(std::move(data)), Promise<Unit>());
|
||||||
|
}
|
||||||
|
|
||||||
|
promise.set_value(td_api::make_object<td_api::businessFeatures>(std::move(features)));
|
||||||
|
}
|
||||||
|
|
||||||
void view_premium_feature(Td *td, const td_api::object_ptr<td_api::PremiumFeature> &feature, Promise<Unit> &&promise) {
|
void view_premium_feature(Td *td, const td_api::object_ptr<td_api::PremiumFeature> &feature, Promise<Unit> &&promise) {
|
||||||
auto source = get_premium_source(feature.get());
|
auto source = get_premium_source(feature.get());
|
||||||
if (source.empty()) {
|
if (source.empty()) {
|
||||||
|
@ -30,6 +30,9 @@ void get_premium_limit(const td_api::object_ptr<td_api::PremiumLimitType> &limit
|
|||||||
void get_premium_features(Td *td, const td_api::object_ptr<td_api::PremiumSource> &source,
|
void get_premium_features(Td *td, const td_api::object_ptr<td_api::PremiumSource> &source,
|
||||||
Promise<td_api::object_ptr<td_api::premiumFeatures>> &&promise);
|
Promise<td_api::object_ptr<td_api::premiumFeatures>> &&promise);
|
||||||
|
|
||||||
|
void get_business_features(Td *td, const td_api::object_ptr<td_api::BusinessFeature> &source,
|
||||||
|
Promise<td_api::object_ptr<td_api::businessFeatures>> &&promise);
|
||||||
|
|
||||||
void view_premium_feature(Td *td, const td_api::object_ptr<td_api::PremiumFeature> &feature, Promise<Unit> &&promise);
|
void view_premium_feature(Td *td, const td_api::object_ptr<td_api::PremiumFeature> &feature, Promise<Unit> &&promise);
|
||||||
|
|
||||||
void click_premium_subscription_button(Td *td, Promise<Unit> &&promise);
|
void click_premium_subscription_button(Td *td, Promise<Unit> &&promise);
|
||||||
|
@ -9312,6 +9312,12 @@ void Td::on_request(uint64 id, td_api::assignGooglePlayTransaction &request) {
|
|||||||
std::move(request.purpose_), std::move(promise));
|
std::move(request.purpose_), std::move(promise));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Td::on_request(uint64 id, const td_api::getBusinessFeatures &request) {
|
||||||
|
CHECK_IS_USER();
|
||||||
|
CREATE_REQUEST_PROMISE();
|
||||||
|
get_business_features(this, request.source_, std::move(promise));
|
||||||
|
}
|
||||||
|
|
||||||
void Td::on_request(uint64 id, td_api::acceptTermsOfService &request) {
|
void Td::on_request(uint64 id, td_api::acceptTermsOfService &request) {
|
||||||
CHECK_IS_USER();
|
CHECK_IS_USER();
|
||||||
CLEAN_INPUT_STRING(request.terms_of_service_id_);
|
CLEAN_INPUT_STRING(request.terms_of_service_id_);
|
||||||
|
@ -1794,6 +1794,8 @@ class Td final : public Actor {
|
|||||||
|
|
||||||
void on_request(uint64 id, td_api::assignGooglePlayTransaction &request);
|
void on_request(uint64 id, td_api::assignGooglePlayTransaction &request);
|
||||||
|
|
||||||
|
void on_request(uint64 id, const td_api::getBusinessFeatures &request);
|
||||||
|
|
||||||
void on_request(uint64 id, td_api::acceptTermsOfService &request);
|
void on_request(uint64 id, td_api::acceptTermsOfService &request);
|
||||||
|
|
||||||
void on_request(uint64 id, const td_api::getCountries &request);
|
void on_request(uint64 id, const td_api::getCountries &request);
|
||||||
|
@ -3341,6 +3341,8 @@ class CliClient final : public Actor {
|
|||||||
get_args(args, parameters, currency, amount);
|
get_args(args, parameters, currency, amount);
|
||||||
send_request(td_api::make_object<td_api::canPurchasePremium>(
|
send_request(td_api::make_object<td_api::canPurchasePremium>(
|
||||||
td_api::make_object<td_api::storePaymentPurposePremiumGiveaway>(parameters, currency, amount)));
|
td_api::make_object<td_api::storePaymentPurposePremiumGiveaway>(parameters, currency, amount)));
|
||||||
|
} else if (op == "gbf") {
|
||||||
|
send_request(td_api::make_object<td_api::getBusinessFeatures>(nullptr));
|
||||||
} else if (op == "atos") {
|
} else if (op == "atos") {
|
||||||
send_request(td_api::make_object<td_api::acceptTermsOfService>(args));
|
send_request(td_api::make_object<td_api::acceptTermsOfService>(args));
|
||||||
} else if (op == "gdli") {
|
} else if (op == "gdli") {
|
||||||
|
Loading…
Reference in New Issue
Block a user