Minor fixes.

This commit is contained in:
levlam 2022-06-02 16:19:16 +03:00
parent 329f3a11cb
commit 1e417ea212
33 changed files with 55 additions and 34 deletions

View File

@ -2553,7 +2553,7 @@ attachmentMenuBotColor light_color:int32 dark_color:int32 = AttachmentMenuBotCol
//@bot_user_id User identifier of the bot added to attachment menu
//@supports_self_chat True, if the bot supports opening from attachment menu in the chat with the bot
//@supports_user_chats True, if the bot supports opening from attachment menu in private chats with ordinary users
//@supports_bot_chats True, if the bot supports opening from attachment menu in private chats with other bots
//@supports_bot_chats True, if the bot supports opening from attachment menu in private chats with other bots
//@supports_group_chats True, if the bot supports opening from attachment menu in basic group and supergroup chats
//@supports_channel_chats True, if the bot supports opening from attachment menu in channel chats
//@supports_settings True, if the bot supports "settings_button_pressed" event
@ -2962,7 +2962,7 @@ premiumLimit type:PremiumLimitType default_value:int32 premium_value:int32 = Pre
premiumFeatures features:vector<PremiumFeature> limits:vector<premiumLimit> payment_link:InternalLinkType = PremiumFeatures;
//@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
//@description A limit was exceeded @limit_type Type of the exceeded limit
premiumSourceLimitExceeded limit_type:PremiumLimitType = PremiumSource;
@ -3547,7 +3547,7 @@ targetChatCurrent = TargetChat;
//@description The chat needs to be chosen by the user among chats of the specified types
//@allow_user_chats True, if private chats with ordinary users are allowed
//@allow_bot_chats True, if private chats with other bots are allowed
//@allow_bot_chats True, if private chats with other bots are allowed
//@allow_group_chats True, if basic group and supergroup chats are allowed
//@allow_channel_chats True, if channel chats are allowed
targetChatChosen allow_user_chats:Bool allow_bot_chats:Bool allow_group_chats:Bool allow_channel_chats:Bool = TargetChat;
@ -3565,7 +3565,7 @@ internalLinkTypeActiveSessions = InternalLinkType;
//-Then call searchPublicChat with the given bot username, check that the user is a bot and can be added to attachment menu. Then use getAttachmentMenuBot to receive information about the bot.
//-If the bot isn't added to attachment menu, then user needs to confirm adding the bot to attachment menu. If user confirms adding, then use toggleBotIsAddedToAttachmentMenu to add it.
//-If the attachment menu bot can't be used in the opened chat, show an error to the user. If the bot is added to attachment menu and can be used in the chat, then use openWebApp with the given URL
//@target_chat Description of the chat to be opened @bot_username Username of the bot @url URL to be passed to openWebApp
//@target_chat Target chat to be opened @bot_username Username of the bot @url URL to be passed to openWebApp
internalLinkTypeAttachmentMenuBot target_chat:TargetChat bot_username:string url:string = InternalLinkType;
//@description The link contains an authentication code. Call checkAuthenticationCode with the code if the current authorization state is authorizationStateWaitCode @code The authentication code
@ -3632,7 +3632,7 @@ internalLinkTypePassportDataRequest bot_user_id:int53 scope:string public_key:st
//@hash Hash value from the link @phone_number Phone number value from the link
internalLinkTypePhoneNumberConfirmation hash:string phone_number:string = InternalLinkType;
//@description The link is a link to the Premium features screen of the applcation, from which the user can subscribe to Telegram Premium. Call getPremiumFeatures with the given referrer to process the link @referrer Referrer specified in the link
//@description The link is a link to the Premium features screen of the applcation from which the user can subscribe to Telegram Premium. Call getPremiumFeatures with the given referrer to process the link @referrer Referrer specified in the link
internalLinkTypePremiumFeatures referrer:string = InternalLinkType;
//@description The link is a link to the privacy and security settings section of the app
@ -3913,7 +3913,7 @@ text text:string = Text;
//@description Contains a value representing a number of seconds @seconds Number of seconds
seconds seconds:double = Seconds;
//@description Contains size of downloaded prefix of a file @size The prefix size
//@description Contains size of downloaded prefix of a file @size The prefix size, in bytes
fileDownloadedPrefixSize size:int53 = FileDownloadedPrefixSize;

View File

@ -11,6 +11,7 @@
#include "td/utils/buffer.h"
#include "td/utils/logging.h"
#include "td/utils/Status.h"
namespace td {

View File

@ -8,6 +8,7 @@
#include "td/telegram/AuthManager.h"
#include "td/telegram/files/FileManager.h"
#include "td/telegram/files/FileType.h"
#include "td/telegram/PhotoFormat.h"
#include "td/telegram/secret_api.h"
#include "td/telegram/Td.h"

View File

@ -13,6 +13,7 @@
#include "td/utils/buffer.h"
#include "td/utils/logging.h"
#include "td/utils/misc.h"
#include "td/utils/Status.h"
namespace td {
@ -26,7 +27,7 @@ static td_api::object_ptr<td_api::autoDownloadSettings> convert_auto_download_se
auto audio_preload_next = (flags & telegram_api::autoDownloadSettings::AUDIO_PRELOAD_NEXT_MASK) != 0;
auto phonecalls_less_data = (flags & telegram_api::autoDownloadSettings::PHONECALLS_LESS_DATA_MASK) != 0;
constexpr int32 MAX_PHOTO_SIZE = 10 * (1 << 20) /* 10 MB */;
constexpr int64 MAX_DOCUMENT_SIZE = (1ll << 52);
constexpr int64 MAX_DOCUMENT_SIZE = (static_cast<int64>(1) << 52);
return td_api::make_object<td_api::autoDownloadSettings>(
!disabled, clamp(settings->photo_size_max_, static_cast<int32>(0), MAX_PHOTO_SIZE),
clamp(settings->video_size_max_, static_cast<int64>(0), MAX_DOCUMENT_SIZE),

View File

@ -35,6 +35,8 @@
#include "td/utils/SliceBuilder.h"
#include "td/utils/tl_helpers.h"
#include <algorithm>
namespace td {
class GetBackgroundQuery final : public Td::ResultHandler {

View File

@ -11,6 +11,7 @@
#include "td/telegram/DhCache.h"
#include "td/telegram/DialogId.h"
#include "td/telegram/files/FileManager.h"
#include "td/telegram/files/FileType.h"
#include "td/telegram/Global.h"
#include "td/telegram/misc.h"
#include "td/telegram/net/NetQueryCreator.h"

View File

@ -20,6 +20,7 @@
#include "td/actor/actor.h"
#include "td/actor/PromiseFuture.h"
#include "td/utils/common.h"
#include "td/utils/Container.h"
#include "td/utils/Status.h"

View File

@ -13,6 +13,8 @@
#include "td/actor/actor.h"
#include "td/actor/PromiseFuture.h"
#include "td/utils/common.h"
#include "td/utils/FlatHashMap.h"
#include "td/utils/Status.h"

View File

@ -14,6 +14,7 @@
#include "td/telegram/Dependencies.h"
#include "td/telegram/DialogInviteLink.h"
#include "td/telegram/DialogLocation.h"
#include "td/telegram/Document.h"
#include "td/telegram/DocumentsManager.h"
#include "td/telegram/FileReferenceManager.h"
#include "td/telegram/files/FileManager.h"

View File

@ -10,6 +10,7 @@
#include "td/telegram/LinkManager.h"
#include "td/utils/logging.h"
#include "td/utils/SliceBuilder.h"
namespace td {

View File

@ -10,6 +10,7 @@
#include "td/utils/common.h"
#include "td/utils/format.h"
#include "td/utils/misc.h"
#include "td/utils/StringBuilder.h"
#include "td/utils/tl_helpers.h"
@ -42,7 +43,7 @@ struct EncryptedFile {
template <class StorerT>
void store(StorerT &storer) const {
using td::store;
bool has_64bit_size = (size_ >= (1ll << 31));
bool has_64bit_size = (size_ >= (static_cast<int64>(1) << 31));
BEGIN_STORE_FLAGS();
STORE_FLAG(has_64bit_size);
END_STORE_FLAGS();

View File

@ -36,6 +36,7 @@
#include "td/utils/SliceBuilder.h"
#include "td/utils/StringBuilder.h"
#include "td/utils/Time.h"
#include "td/utils/utf8.h"
#include <tuple>

View File

@ -30,7 +30,6 @@
#include "td/utils/buffer.h"
#include "td/utils/common.h"
#include "td/utils/Slice.h"
#include "td/utils/Status.h"
#include <utility>

View File

@ -6,6 +6,7 @@
//
#include "td/telegram/NotificationSound.h"
#include "td/utils/logging.h"
#include "td/utils/tl_helpers.h"
namespace td {
@ -239,7 +240,7 @@ unique_ptr<NotificationSound> get_notification_sound(telegram_api::NotificationS
case telegram_api::notificationSoundRingtone::ID: {
const auto *sound = static_cast<telegram_api::notificationSoundRingtone *>(notification_sound);
if (sound->id_ == 0 || sound->id_ == -1) {
LOG(ERROR) << "Receive ringtone with id = " << sound->id_;
LOG(ERROR) << "Receive ringtone with ID = " << sound->id_;
return make_unique<NotificationSoundNone>();
}
return td::make_unique<NotificationSoundRingtone>(sound->id_);

View File

@ -8,7 +8,6 @@
#include "td/telegram/logevent/LogEvent.h"
#include "td/telegram/NotificationSoundType.h"
#include "td/telegram/td_api.h"
#include "td/telegram/telegram_api.h"
#include "td/utils/common.h"

View File

@ -31,6 +31,7 @@
#include "td/utils/buffer.h"
#include "td/utils/logging.h"
#include "td/utils/misc.h"
#include "td/utils/port/Clocks.h"
#include "td/utils/SliceBuilder.h"
#include "td/utils/Status.h"

View File

@ -19,7 +19,6 @@
#include "td/utils/common.h"
#include "td/utils/format.h"
#include "td/utils/logging.h"
#include "td/utils/misc.h"
#include "td/utils/SliceBuilder.h"
#include <algorithm>

View File

@ -8,15 +8,21 @@
#include "td/telegram/Application.h"
#include "td/telegram/ConfigShared.h"
#include "td/telegram/DialogId.h"
#include "td/telegram/Document.h"
#include "td/telegram/DocumentsManager.h"
#include "td/telegram/Global.h"
#include "td/telegram/MessageEntity.h"
#include "td/telegram/Td.h"
#include "td/telegram/telegram_api.h"
#include "td/telegram/VideosManager.h"
#include "td/utils/algorithm.h"
#include "td/utils/buffer.h"
#include "td/utils/logging.h"
#include "td/utils/misc.h"
#include "td/utils/SliceBuilder.h"
#include "td/utils/Status.h"
namespace td {

View File

@ -9,6 +9,8 @@
#include "td/telegram/files/FileManager.h"
#include "td/telegram/SecretChatLayer.h"
#include "td/utils/misc.h"
namespace td {
SecretInputMedia::SecretInputMedia(tl_object_ptr<telegram_api::InputEncryptedFile> input_file, BufferSlice &&thumbnail,

View File

@ -313,8 +313,9 @@ void SponsoredMessageManager::on_get_dialog_sponsored_messages(
auto local_id = current_sponsored_message_id_.get();
CHECK(!current_sponsored_message_id_.is_valid());
CHECK(!current_sponsored_message_id_.is_scheduled());
CHECK(messages->message_random_ids.count(local_id) == 0);
messages->message_random_ids[local_id] = sponsored_message->random_id_.as_slice().str();
auto is_inserted =
messages->message_random_ids.emplace(local_id, sponsored_message->random_id_.as_slice().str()).second;
CHECK(is_inserted);
messages->messages.emplace_back(local_id, sponsored_message->recommended_, sponsor_dialog_id, server_message_id,
std::move(sponsored_message->start_param_), std::move(invite_hash),
std::move(content));

View File

@ -9,7 +9,6 @@
#include "td/actor/PromiseFuture.h"
#include "td/actor/SleepActor.h"
#include "td/utils/algorithm.h"
#include "td/utils/logging.h"
#include "td/utils/Time.h"

View File

@ -143,7 +143,6 @@
#include "td/utils/MimeType.h"
#include "td/utils/misc.h"
#include "td/utils/PathView.h"
#include "td/utils/port/Clocks.h"
#include "td/utils/port/IPAddress.h"
#include "td/utils/port/path.h"
#include "td/utils/port/SocketFd.h"

View File

@ -15,7 +15,6 @@
#include "td/telegram/telegram_api.h"
#include "td/utils/logging.h"
#include "td/utils/misc.h"
#include "td/utils/Status.h"
namespace td {

View File

@ -10,7 +10,6 @@
#include "td/telegram/files/FileManager.h"
#include "td/telegram/PhotoFormat.h"
#include "td/telegram/secret_api.h"
#include "td/telegram/SecretChatLayer.h"
#include "td/telegram/Td.h"
#include "td/telegram/td_api.h"
#include "td/telegram/telegram_api.h"

View File

@ -6,6 +6,8 @@
//
#include "td/telegram/VoiceNotesManager.h"
#include "td/telegram/AccessRights.h"
#include "td/telegram/DialogId.h"
#include "td/telegram/Dimensions.h"
#include "td/telegram/files/FileManager.h"
#include "td/telegram/Global.h"
@ -17,7 +19,6 @@
#include "td/utils/buffer.h"
#include "td/utils/logging.h"
#include "td/utils/misc.h"
namespace td {
@ -263,7 +264,7 @@ void VoiceNotesManager::unregister_voice_note(FileId voice_note_file_id, FullMes
if (message_ids.empty()) {
voice_note_messages_.erase(voice_note_file_id);
}
is_deleted = message_voice_notes_.erase(full_message_id);
is_deleted = message_voice_notes_.erase(full_message_id) > 0;
CHECK(is_deleted);
}

View File

@ -11,7 +11,6 @@
#include "td/telegram/SecretInputMedia.h"
#include "td/telegram/td_api.h"
#include "td/telegram/telegram_api.h"
#include "td/telegram/Version.h"
#include "td/actor/actor.h"
#include "td/actor/PromiseFuture.h"

View File

@ -9,6 +9,7 @@
#include "td/telegram/VoiceNotesManager.h"
#include "td/telegram/files/FileId.hpp"
#include "td/telegram/Version.h"
#include "td/utils/common.h"
#include "td/utils/tl_helpers.h"

View File

@ -49,7 +49,6 @@ void FileLoadManager::download(QueryId id, const FullRemoteFileLocation &remote_
if (stop_flag_) {
return;
}
CHECK(query_id_to_node_id_.count(id) == 0);
NodeId node_id = nodes_container_.create(Node());
Node *node = nodes_container_.get(node_id);
CHECK(node);
@ -63,7 +62,8 @@ void FileLoadManager::download(QueryId id, const FullRemoteFileLocation &remote_
auto &resource_manager = get_download_resource_manager(is_small, dc_id);
send_closure(resource_manager, &ResourceManager::register_worker,
ActorShared<FileLoaderActor>(node->loader_.get(), static_cast<uint64>(-1)), priority);
query_id_to_node_id_[id] = node_id;
bool is_inserted = query_id_to_node_id_.emplace(id, node_id).second;
CHECK(is_inserted);
}
void FileLoadManager::upload(QueryId id, const LocalFileLocation &local_location,
@ -72,7 +72,6 @@ void FileLoadManager::upload(QueryId id, const LocalFileLocation &local_location
if (stop_flag_) {
return;
}
CHECK(query_id_to_node_id_.count(id) == 0);
NodeId node_id = nodes_container_.create(Node());
Node *node = nodes_container_.get(node_id);
CHECK(node);
@ -82,7 +81,8 @@ void FileLoadManager::upload(QueryId id, const LocalFileLocation &local_location
std::move(bad_parts), std::move(callback));
send_closure(upload_resource_manager_, &ResourceManager::register_worker,
ActorShared<FileLoaderActor>(node->loader_.get(), static_cast<uint64>(-1)), priority);
query_id_to_node_id_[id] = node_id;
bool is_inserted = query_id_to_node_id_.emplace(id, node_id).second;
CHECK(is_inserted);
}
void FileLoadManager::upload_by_hash(QueryId id, const FullLocalFileLocation &local_location, int64 size,
@ -90,7 +90,6 @@ void FileLoadManager::upload_by_hash(QueryId id, const FullLocalFileLocation &lo
if (stop_flag_) {
return;
}
CHECK(query_id_to_node_id_.count(id) == 0);
NodeId node_id = nodes_container_.create(Node());
Node *node = nodes_container_.get(node_id);
CHECK(node);
@ -99,7 +98,8 @@ void FileLoadManager::upload_by_hash(QueryId id, const FullLocalFileLocation &lo
node->loader_ = create_actor<FileHashUploader>("HashUploader", local_location, size, std::move(callback));
send_closure(upload_resource_manager_, &ResourceManager::register_worker,
ActorShared<FileLoaderActor>(node->loader_.get(), static_cast<uint64>(-1)), priority);
query_id_to_node_id_[id] = node_id;
bool is_inserted = query_id_to_node_id_.emplace(id, node_id).second;
CHECK(is_inserted);
}
void FileLoadManager::update_priority(QueryId id, int8 priority) {
@ -121,7 +121,6 @@ void FileLoadManager::from_bytes(QueryId id, FileType type, BufferSlice bytes, s
if (stop_flag_) {
return;
}
CHECK(query_id_to_node_id_.count(id) == 0);
NodeId node_id = nodes_container_.create(Node());
Node *node = nodes_container_.get(node_id);
CHECK(node);
@ -129,7 +128,8 @@ void FileLoadManager::from_bytes(QueryId id, FileType type, BufferSlice bytes, s
auto callback = make_unique<FileFromBytesCallback>(actor_shared(this, node_id));
node->loader_ =
create_actor<FileFromBytes>("FromBytes", type, std::move(bytes), std::move(name), std::move(callback));
query_id_to_node_id_[id] = node_id;
bool is_inserted = query_id_to_node_id_.emplace(id, node_id).second;
CHECK(is_inserted);
}
void FileLoadManager::get_content(const FullLocalFileLocation &local_location, Promise<BufferSlice> promise) {

View File

@ -319,7 +319,7 @@ void PartialLocalFileLocation::store(StorerT &storer) const {
store(iv_, storer);
store(ready_bitmask_, storer);
if (deprecated_ready_part_count == -2) {
CHECK(part_size_ < (1ll << 62));
CHECK(part_size_ < (static_cast<int64>(1) << 62));
store(static_cast<int32>(part_size_ >> 31), storer);
}
}

View File

@ -179,8 +179,8 @@ void ConnectionCreator::add_proxy(int32 old_proxy_id, string server, int32 port,
proxy_id = max_proxy_id_++;
G()->td_db()->get_binlog_pmc()->set("proxy_max_id", to_string(max_proxy_id_));
}
CHECK(proxies_.count(proxy_id) == 0);
proxies_.emplace(proxy_id, std::move(new_proxy));
bool is_inserted = proxies_.emplace(proxy_id, std::move(new_proxy)).second;
CHECK(is_inserted);
G()->td_db()->get_binlog_pmc()->set(get_proxy_database_key(proxy_id),
log_event_store(proxies_[proxy_id]).as_slice().str());
return proxy_id;

View File

@ -14,6 +14,7 @@
#include "td/utils/as.h"
#include "td/utils/misc.h"
#include "td/utils/SliceBuilder.h"
#include "td/utils/Time.h"
#include <algorithm>

View File

@ -9,6 +9,9 @@
#include "td/utils/common.h"
#include "td/utils/HashTableUtils.h"
#include <type_traits>
#include <utility>
namespace td {
template <class KeyT, class Enable = void>
@ -71,7 +74,7 @@ struct SetNode<KeyT, typename std::enable_if_t<(sizeof(KeyT) > 28 * sizeof(void
KeyT first{};
template <class InputKeyT>
Impl(InputKeyT &&key) : first(std::forward<InputKeyT>(key)) {
explicit Impl(InputKeyT &&key) : first(std::forward<InputKeyT>(key)) {
DCHECK(!is_hash_table_key_empty(first));
}
Impl(const Impl &other) = delete;

View File

@ -9,7 +9,6 @@
#include "td/utils/base64.h"
#include "td/utils/FlatHashSet.h"
#include "td/utils/Gzip.h"
#include "td/utils/misc.h"
namespace td {