Add td_api::businessChatLink.

This commit is contained in:
levlam 2024-04-10 18:19:39 +03:00
parent 6c2becce09
commit de881cce99
6 changed files with 124 additions and 0 deletions

View File

@ -305,6 +305,7 @@ set(TDLIB_SOURCE
td/telegram/BusinessAwayMessage.cpp
td/telegram/BusinessAwayMessageSchedule.cpp
td/telegram/BusinessBotManageBar.cpp
td/telegram/BusinessChatLink.cpp
td/telegram/BusinessConnectedBot.cpp
td/telegram/BusinessConnectionManager.cpp
td/telegram/BusinessGreetingMessage.cpp
@ -600,6 +601,7 @@ set(TDLIB_SOURCE
td/telegram/BusinessAwayMessage.h
td/telegram/BusinessAwayMessageSchedule.h
td/telegram/BusinessBotManageBar.h
td/telegram/BusinessChatLink.h
td/telegram/BusinessConnectedBot.h
td/telegram/BusinessConnectionId.h
td/telegram/BusinessConnectionManager.h

View File

@ -311,6 +311,7 @@ function split_file($file, $chunks, $undo) {
'boost_manager[_(-](?![.]get[(][)])|BoostManager' => 'BoostManager',
'bot_info_manager[_(-](?![.]get[(][)])|BotInfoManager' => 'BotInfoManager',
'BusinessAwayMessage' => 'BusinessAwayMessage',
'BusinessChatLink' => 'BusinessChatLink',
'BusinessConnectedBot' => 'BusinessConnectedBot',
'BusinessConnectionId' => 'BusinessConnectionId',
'business_connection_manager[_(-](?![.]get[(][)])|BusinessConnectionManager' => 'BusinessConnectionManager',
@ -375,6 +376,7 @@ function split_file($file, $chunks, $undo) {
'messages_manager[_(-](?![.]get[(][)])|MessagesManager' => 'MessagesManager',
'MessageThreadInfo' => 'MessageThreadInfo',
'MessageTtl' => 'MessageTtl',
'MissingInvitee' => 'MissingInvitee',
'notification_manager[_(-](?![.]get[(][)])|NotificationManager|notifications[)]' => 'NotificationManager',
'notification_settings_manager[_(-](?![.]get[(][)])|NotificationSettingsManager' => 'NotificationSettingsManager',
'option_manager[_(-](?![.]get[(][)])|OptionManager' => 'OptionManager',

View File

@ -659,6 +659,17 @@ businessOpeningHours time_zone_id:string opening_hours:vector<businessOpeningHou
businessInfo location:businessLocation opening_hours:businessOpeningHours greeting_message_settings:businessGreetingMessageSettings away_message_settings:businessAwayMessageSettings start_page:businessStartPage = BusinessInfo;
//@description Contains information about a business chat link
//@link The HTTPS link
//@text Message draft text that will be added to the input field
//@title Link title
//@view_count Number of times the link was used
businessChatLink link:string text:formattedText title:string view_count:int32 = BusinessChatLink;
//@description Contains a list of business chat links created by the user @links List of links
businessChatLinks links:vector<businessChatLink> = BusinessChatLinks;
//@class ChatPhotoStickerType @description Describes type of sticker, which was used to create a chat photo
//@description Information about the sticker, which was used to create the chat photo
@ -9724,6 +9735,7 @@ setBusinessAwayMessageSettings away_message_settings:businessAwayMessageSettings
//@description Changes the business start page of the current user. Requires Telegram Business subscription @start_page The new start page of the business; pass null to remove custom start page
setBusinessStartPage start_page:inputBusinessStartPage = Ok;
//@description Changes the phone number of the user and sends an authentication code to the user's new phone number; for official Android and iOS applications only. On success, returns information about the sent code
//@phone_number The new phone number of the user in international format
//@settings Settings for the authentication of the user's phone number; pass null to use default settings

View File

@ -0,0 +1,53 @@
//
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#include "td/telegram/BusinessChatLink.h"
#include "td/utils/algorithm.h"
#include "td/utils/format.h"
#include "td/utils/logging.h"
namespace td {
BusinessChatLink::BusinessChatLink(const UserManager *user_manager,
telegram_api::object_ptr<telegram_api::businessChatLink> &&link)
: link_(std::move(link->link_))
, text_(get_message_text(user_manager, std::move(link->message_), std::move(link->entities_), true, true, 0, false,
"BusinessChatLink"))
, title_(std::move(link->title_))
, view_count_(link->views_) {
}
td_api::object_ptr<td_api::businessChatLink> BusinessChatLink::get_business_chat_link_object() const {
return td_api::make_object<td_api::businessChatLink>(
link_, get_formatted_text_object(text_, true, -1), title_, view_count_);
}
StringBuilder &operator<<(StringBuilder &string_builder, const BusinessChatLink &link) {
return string_builder << '[' << link.link_ << ' ' << link.title_ << ' ' << link.view_count_ << ']';
}
BusinessChatLinks::BusinessChatLinks(const UserManager *user_manager,
vector<telegram_api::object_ptr<telegram_api::businessChatLink>> &&links) {
for (auto &link : links) {
business_chat_links_.emplace_back(user_manager, std::move(link));
if (!business_chat_links_.back().is_valid()) {
LOG(ERROR) << "Receive invalid " << business_chat_links_.back() << " business link";
business_chat_links_.pop_back();
}
}
}
td_api::object_ptr<td_api::businessChatLinks> BusinessChatLinks::get_business_chat_links_object() const {
return td_api::make_object<td_api::businessChatLinks>(transform(
business_chat_links_, [](const BusinessChatLink &link) { return link.get_business_chat_link_object(); }));
}
StringBuilder &operator<<(StringBuilder &string_builder, const BusinessChatLinks &links) {
return string_builder << links.business_chat_links_;
}
} // namespace td

View File

@ -0,0 +1,54 @@
//
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#pragma once
#include "td/telegram/MessageEntity.h"
#include "td/telegram/td_api.h"
#include "td/telegram/telegram_api.h"
#include "td/utils/common.h"
#include "td/utils/StringBuilder.h"
namespace td {
class UserManager;
class BusinessChatLink {
string link_;
FormattedText text_;
string title_;
int32 view_count_ = 0;
friend StringBuilder &operator<<(StringBuilder &string_builder, const BusinessChatLink &link);
public:
BusinessChatLink(const UserManager *user_manager, telegram_api::object_ptr<telegram_api::businessChatLink> &&link);
bool is_valid() const {
return !link_.empty();
}
td_api::object_ptr<td_api::businessChatLink> get_business_chat_link_object() const;
};
StringBuilder &operator<<(StringBuilder &string_builder, const BusinessChatLink &link);
class BusinessChatLinks {
vector<BusinessChatLink> business_chat_links_;
friend StringBuilder &operator<<(StringBuilder &string_builder, const BusinessChatLinks &links);
public:
explicit BusinessChatLinks(const UserManager *user_manager,
vector<telegram_api::object_ptr<telegram_api::businessChatLink>> &&links);
td_api::object_ptr<td_api::businessChatLinks> get_business_chat_links_object() const;
};
StringBuilder &operator<<(StringBuilder &string_builder, const BusinessChatLinks &links);
} // namespace td

View File

@ -9,6 +9,7 @@
#include "td/telegram/UserManager.h"
#include "td/utils/algorithm.h"
#include "td/utils/format.h"
#include "td/utils/logging.h"
namespace td {