Support address-only business location.

This commit is contained in:
levlam 2024-02-23 21:03:44 +03:00
parent 6cecda5d40
commit 370d862acf
5 changed files with 35 additions and 7 deletions

View File

@ -576,6 +576,10 @@ botMenuButton text:string url:string = BotMenuButton;
chatLocation location:location address:string = ChatLocation; chatLocation location:location address:string = ChatLocation;
//@description Represents a location of a business @location The location; may be null if not specified @address Location address; 1-96 characters
businessLocation location:location address:string = BusinessLocation;
//@description Describes an interval of time when the business is open //@description Describes an interval of time when the business is open
//@start_minute The first minute of the interval since start of the week; 0-7*24*60 //@start_minute The first minute of the interval since start of the week; 0-7*24*60
//@end_minute The first minute after the end of the interval since start of the week; 1-8*24*60 //@end_minute The first minute after the end of the interval since start of the week; 1-8*24*60
@ -859,7 +863,7 @@ botInfo short_description:string description:string photo:photo animation:animat
//@business_location Location of the business for Telegram Business users; may be null if none //@business_location Location of the business for Telegram Business users; may be null if none
//@business_work_hours Work hours of the business for Telegram Business users; may be null if none //@business_work_hours Work hours of the business for Telegram Business users; may be null if none
//@bot_info For bots, information about the bot; may be null if the user isn't a bot //@bot_info For bots, information about the bot; may be null if the user isn't a bot
userFullInfo personal_photo:chatPhoto photo:chatPhoto public_photo:chatPhoto block_list:BlockList can_be_called:Bool supports_video_calls:Bool has_private_calls:Bool has_private_forwards:Bool has_restricted_voice_and_video_note_messages:Bool has_pinned_stories:Bool need_phone_number_privacy_exception:Bool set_chat_background:Bool bio:formattedText premium_gift_options:vector<premiumPaymentOption> group_in_common_count:int32 business_location:chatLocation business_work_hours:businessWorkHours bot_info:botInfo = UserFullInfo; userFullInfo personal_photo:chatPhoto photo:chatPhoto public_photo:chatPhoto block_list:BlockList can_be_called:Bool supports_video_calls:Bool has_private_calls:Bool has_private_forwards:Bool has_restricted_voice_and_video_note_messages:Bool has_pinned_stories:Bool need_phone_number_privacy_exception:Bool set_chat_background:Bool bio:formattedText premium_gift_options:vector<premiumPaymentOption> group_in_common_count:int32 business_location:businessLocation business_work_hours:businessWorkHours bot_info:botInfo = UserFullInfo;
//@description Represents a list of users @total_count Approximate total number of users found @user_ids A list of user identifiers //@description Represents a list of users @total_count Approximate total number of users found @user_ids A list of user identifiers
users total_count:int32 user_ids:vector<int53> = Users; users total_count:int32 user_ids:vector<int53> = Users;
@ -9297,7 +9301,7 @@ setEmojiStatus emoji_status:emojiStatus = Ok;
setLocation location:location = Ok; setLocation location:location = Ok;
//@description Changes the business location of the current user. Requires Telegram Business subscription @location The new location of the business; pass null to remove the location //@description Changes the business location of the current user. Requires Telegram Business subscription @location The new location of the business; pass null to remove the location
setBusinessLocation location:chatLocation = Ok; setBusinessLocation location:businessLocation = Ok;
//@description Changes the business work hours of the current user. Requires Telegram Business subscription @work_hours The new work hours of the business; pass null to remove the work hours //@description Changes the business work hours of the current user. Requires Telegram Business subscription @work_hours The new work hours of the business; pass null to remove the work hours
setBusinessWorkHours work_hours:businessWorkHours = Ok; setBusinessWorkHours work_hours:businessWorkHours = Ok;

View File

@ -1105,6 +1105,9 @@ class UpdateBusinessLocationQuery final : public Td::ResultHandler {
if (!location_.empty()) { if (!location_.empty()) {
flags |= telegram_api::account_updateBusinessLocation::GEO_POINT_MASK; flags |= telegram_api::account_updateBusinessLocation::GEO_POINT_MASK;
} }
if (!location_.get_address().empty()) {
flags |= telegram_api::account_updateBusinessLocation::ADDRESS_MASK;
}
send_query(G()->net_query_creator().create( send_query(G()->net_query_creator().create(
telegram_api::account_updateBusinessLocation(flags, location_.get_input_geo_point(), location_.get_address()), telegram_api::account_updateBusinessLocation(flags, location_.get_input_geo_point(), location_.get_address()),
{{"me"}})); {{"me"}}));
@ -3498,7 +3501,7 @@ void ContactsManager::UserFull::store(StorerT &storer) const {
bool has_premium_gift_options = !premium_gift_options.empty(); bool has_premium_gift_options = !premium_gift_options.empty();
bool has_personal_photo = !personal_photo.is_empty(); bool has_personal_photo = !personal_photo.is_empty();
bool has_fallback_photo = !fallback_photo.is_empty(); bool has_fallback_photo = !fallback_photo.is_empty();
bool has_location = !location.empty(); bool has_location = !location.empty() || !location.get_address().empty();
bool has_work_hours = !work_hours.is_empty(); bool has_work_hours = !work_hours.is_empty();
BEGIN_STORE_FLAGS(); BEGIN_STORE_FLAGS();
STORE_FLAG(has_about); STORE_FLAG(has_about);
@ -17158,7 +17161,7 @@ tl_object_ptr<td_api::userFullInfo> ContactsManager::get_user_full_info_object(U
!user_full->private_forward_name.empty(), voice_messages_forbidden, user_full->has_pinned_stories, !user_full->private_forward_name.empty(), voice_messages_forbidden, user_full->has_pinned_stories,
user_full->need_phone_number_privacy_exception, user_full->wallpaper_overridden, std::move(bio_object), user_full->need_phone_number_privacy_exception, user_full->wallpaper_overridden, std::move(bio_object),
get_premium_payment_options_object(user_full->premium_gift_options), user_full->common_chat_count, get_premium_payment_options_object(user_full->premium_gift_options), user_full->common_chat_count,
user_full->location.get_chat_location_object(), user_full->work_hours.get_business_work_hours_object(), user_full->location.get_business_location_object(), user_full->work_hours.get_business_work_hours_object(),
std::move(bot_info)); std::move(bot_info));
} }

View File

@ -35,6 +35,16 @@ DialogLocation::DialogLocation(td_api::object_ptr<td_api::chatLocation> &&chat_l
} }
} }
DialogLocation::DialogLocation(td_api::object_ptr<td_api::businessLocation> &&business_location) {
if (business_location != nullptr) {
location_ = Location(business_location->location_);
address_ = std::move(business_location->address_);
if (!clean_input_string(address_)) {
address_.clear();
}
}
}
bool DialogLocation::empty() const { bool DialogLocation::empty() const {
return location_.empty(); return location_.empty();
} }
@ -46,6 +56,13 @@ td_api::object_ptr<td_api::chatLocation> DialogLocation::get_chat_location_objec
return td_api::make_object<td_api::chatLocation>(location_.get_location_object(), address_); return td_api::make_object<td_api::chatLocation>(location_.get_location_object(), address_);
} }
td_api::object_ptr<td_api::businessLocation> DialogLocation::get_business_location_object() const {
if (empty() && address_.empty()) {
return nullptr;
}
return td_api::make_object<td_api::businessLocation>(location_.get_location_object(), address_);
}
telegram_api::object_ptr<telegram_api::InputGeoPoint> DialogLocation::get_input_geo_point() const { telegram_api::object_ptr<telegram_api::InputGeoPoint> DialogLocation::get_input_geo_point() const {
return location_.get_input_geo_point(); return location_.get_input_geo_point();
} }

View File

@ -36,10 +36,14 @@ class DialogLocation {
explicit DialogLocation(td_api::object_ptr<td_api::chatLocation> &&chat_location); explicit DialogLocation(td_api::object_ptr<td_api::chatLocation> &&chat_location);
explicit DialogLocation(td_api::object_ptr<td_api::businessLocation> &&business_location);
bool empty() const; bool empty() const;
td_api::object_ptr<td_api::chatLocation> get_chat_location_object() const; td_api::object_ptr<td_api::chatLocation> get_chat_location_object() const;
td_api::object_ptr<td_api::businessLocation> DialogLocation::get_business_location_object() const;
telegram_api::object_ptr<telegram_api::InputGeoPoint> get_input_geo_point() const; telegram_api::object_ptr<telegram_api::InputGeoPoint> get_input_geo_point() const;
const string &get_address() const; const string &get_address() const;

View File

@ -5907,11 +5907,11 @@ class CliClient final : public Actor {
string latitude; string latitude;
string longitude; string longitude;
get_args(args, latitude, longitude); get_args(args, latitude, longitude);
if (latitude.empty() || longitude.empty()) { if (latitude.empty()) {
send_request(td_api::make_object<td_api::setBusinessLocation>(nullptr)); send_request(td_api::make_object<td_api::setBusinessLocation>(nullptr));
} else { } else {
send_request(td_api::make_object<td_api::setBusinessLocation>( send_request(td_api::make_object<td_api::setBusinessLocation>(td_api::make_object<td_api::businessLocation>(
td_api::make_object<td_api::chatLocation>(as_location(latitude, longitude, string()), "business address"))); longitude.empty() ? nullptr : as_location(latitude, longitude, string()), "business address")));
} }
} else if (op == "sbwh") { } else if (op == "sbwh") {
string time_zone_id; string time_zone_id;