Merge remote-tracking branch 'td/master'
This commit is contained in:
commit
778ca70dd5
@ -17,10 +17,12 @@
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/sha.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <atomic>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <iterator>
|
||||
#include <random>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@ -38,10 +40,7 @@ class SHA1Bench final : public td::Benchmark {
|
||||
}
|
||||
|
||||
void start_up() final {
|
||||
for (int i = 0; i < DATA_SIZE; i++) {
|
||||
data[i] = 123;
|
||||
data[i] = 0;
|
||||
}
|
||||
std::fill(std::begin(data), std::end(data), static_cast<unsigned char>(123));
|
||||
}
|
||||
|
||||
void run(int n) final {
|
||||
@ -64,9 +63,7 @@ class AesEcbBench final : public td::Benchmark {
|
||||
}
|
||||
|
||||
void start_up() final {
|
||||
for (int i = 0; i < DATA_SIZE; i++) {
|
||||
data[i] = 123;
|
||||
}
|
||||
std::fill(std::begin(data), std::end(data), static_cast<unsigned char>(123));
|
||||
td::Random::secure_bytes(key.raw, sizeof(key));
|
||||
td::Random::secure_bytes(iv.raw, sizeof(iv));
|
||||
}
|
||||
@ -95,9 +92,7 @@ class AesIgeEncryptBench final : public td::Benchmark {
|
||||
}
|
||||
|
||||
void start_up() final {
|
||||
for (int i = 0; i < DATA_SIZE; i++) {
|
||||
data[i] = 123;
|
||||
}
|
||||
std::fill(std::begin(data), std::end(data), static_cast<unsigned char>(123));
|
||||
td::Random::secure_bytes(key.raw, sizeof(key));
|
||||
td::Random::secure_bytes(iv.raw, sizeof(iv));
|
||||
}
|
||||
@ -123,9 +118,7 @@ class AesIgeDecryptBench final : public td::Benchmark {
|
||||
}
|
||||
|
||||
void start_up() final {
|
||||
for (int i = 0; i < DATA_SIZE; i++) {
|
||||
data[i] = 123;
|
||||
}
|
||||
std::fill(std::begin(data), std::end(data), static_cast<unsigned char>(123));
|
||||
td::Random::secure_bytes(key.raw, sizeof(key));
|
||||
td::Random::secure_bytes(iv.raw, sizeof(iv));
|
||||
}
|
||||
@ -151,9 +144,7 @@ class AesCtrBench final : public td::Benchmark {
|
||||
}
|
||||
|
||||
void start_up() final {
|
||||
for (int i = 0; i < DATA_SIZE; i++) {
|
||||
data[i] = 123;
|
||||
}
|
||||
std::fill(std::begin(data), std::end(data), static_cast<unsigned char>(123));
|
||||
td::Random::secure_bytes(key.raw, sizeof(key));
|
||||
td::Random::secure_bytes(iv.raw, sizeof(iv));
|
||||
}
|
||||
@ -180,9 +171,7 @@ class AesCtrOpenSSLBench final : public td::Benchmark {
|
||||
}
|
||||
|
||||
void start_up() final {
|
||||
for (int i = 0; i < DATA_SIZE; i++) {
|
||||
data[i] = 123;
|
||||
}
|
||||
std::fill(std::begin(data), std::end(data), static_cast<unsigned char>(123));
|
||||
td::Random::secure_bytes(key.raw, sizeof(key));
|
||||
td::Random::secure_bytes(iv.raw, sizeof(iv));
|
||||
}
|
||||
@ -216,9 +205,7 @@ class AesCbcDecryptBench final : public td::Benchmark {
|
||||
}
|
||||
|
||||
void start_up() final {
|
||||
for (int i = 0; i < DATA_SIZE; i++) {
|
||||
data[i] = 123;
|
||||
}
|
||||
std::fill(std::begin(data), std::end(data), static_cast<unsigned char>(123));
|
||||
td::Random::secure_bytes(as_slice(key));
|
||||
td::Random::secure_bytes(as_slice(iv));
|
||||
}
|
||||
@ -242,9 +229,7 @@ class AesCbcEncryptBench final : public td::Benchmark {
|
||||
}
|
||||
|
||||
void start_up() final {
|
||||
for (int i = 0; i < DATA_SIZE; i++) {
|
||||
data[i] = 123;
|
||||
}
|
||||
std::fill(std::begin(data), std::end(data), static_cast<unsigned char>(123));
|
||||
td::Random::secure_bytes(as_slice(key));
|
||||
td::Random::secure_bytes(as_slice(iv));
|
||||
}
|
||||
@ -269,9 +254,7 @@ class AesIgeShortBench final : public td::Benchmark {
|
||||
}
|
||||
|
||||
void start_up() final {
|
||||
for (int i = 0; i < SHORT_DATA_SIZE; i++) {
|
||||
data[i] = 123;
|
||||
}
|
||||
std::fill(std::begin(data), std::end(data), static_cast<unsigned char>(123));
|
||||
td::Random::secure_bytes(as_slice(key));
|
||||
td::Random::secure_bytes(as_slice(iv));
|
||||
}
|
||||
@ -372,10 +355,7 @@ class Crc32Bench final : public td::Benchmark {
|
||||
}
|
||||
|
||||
void start_up() final {
|
||||
for (int i = 0; i < DATA_SIZE; i++) {
|
||||
data[i] = 123;
|
||||
data[i] = 0;
|
||||
}
|
||||
std::fill(std::begin(data), std::end(data), static_cast<unsigned char>(123));
|
||||
}
|
||||
|
||||
void run(int n) final {
|
||||
@ -396,10 +376,7 @@ class Crc64Bench final : public td::Benchmark {
|
||||
}
|
||||
|
||||
void start_up() final {
|
||||
for (int i = 0; i < DATA_SIZE; i++) {
|
||||
data[i] = 123;
|
||||
data[i] = 0;
|
||||
}
|
||||
std::fill(std::begin(data), std::end(data), static_cast<unsigned char>(123));
|
||||
}
|
||||
|
||||
void run(int n) final {
|
||||
|
@ -96,8 +96,8 @@ td::Result<TlsInfo> test_tls(const td::string &url) {
|
||||
const size_t MAX_GREASE = 7;
|
||||
char greases[MAX_GREASE];
|
||||
td::Random::secure_bytes(td::MutableSlice{greases, MAX_GREASE});
|
||||
for (size_t i = 0; i < MAX_GREASE; i++) {
|
||||
greases[i] = static_cast<char>((greases[i] & 0xF0) + 0x0A);
|
||||
for (auto &grease : greases) {
|
||||
grease = static_cast<char>((grease & 0xF0) + 0x0A);
|
||||
}
|
||||
for (size_t i = 1; i < MAX_GREASE; i += 2) {
|
||||
if (greases[i] == greases[i - 1]) {
|
||||
|
@ -2544,7 +2544,7 @@ chatEventInvitesToggled can_invite_users:Bool = ChatEventAction;
|
||||
//@description The linked chat of a supergroup was changed @old_linked_chat_id Previous supergroup linked chat identifier @new_linked_chat_id New supergroup linked chat identifier
|
||||
chatEventLinkedChatChanged old_linked_chat_id:int53 new_linked_chat_id:int53 = ChatEventAction;
|
||||
|
||||
//@description The slow_mode_delay setting of a supergroup was changed @old_slow_mode_delay Previous value of slow_mode_delay @new_slow_mode_delay New value of slow_mode_delay
|
||||
//@description The slow_mode_delay setting of a supergroup was changed @old_slow_mode_delay Previous value of slow_mode_delay, in seconds @new_slow_mode_delay New value of slow_mode_delay, in seconds
|
||||
chatEventSlowModeDelayChanged old_slow_mode_delay:int32 new_slow_mode_delay:int32 = ChatEventAction;
|
||||
|
||||
//@description The message TTL setting was changed @old_message_ttl_setting Previous value of message_ttl_setting @new_message_ttl_setting New value of message_ttl_setting
|
||||
@ -4715,7 +4715,7 @@ setChatDiscussionGroup chat_id:int53 discussion_chat_id:int53 = Ok;
|
||||
//@description Changes the location of a chat. Available only for some location-based supergroups, use supergroupFullInfo.can_set_location to check whether the method is allowed to use @chat_id Chat identifier @location New location for the chat; must be valid and not null
|
||||
setChatLocation chat_id:int53 location:chatLocation = Ok;
|
||||
|
||||
//@description Changes the slow mode delay of a chat. Available only for supergroups; requires can_restrict_members rights @chat_id Chat identifier @slow_mode_delay New slow mode delay for the chat; must be one of 0, 10, 30, 60, 300, 900, 3600
|
||||
//@description Changes the slow mode delay of a chat. Available only for supergroups; requires can_restrict_members rights @chat_id Chat identifier @slow_mode_delay New slow mode delay for the chat, in seconds; must be one of 0, 10, 30, 60, 300, 900, 3600
|
||||
setChatSlowModeDelay chat_id:int53 slow_mode_delay:int32 = Ok;
|
||||
|
||||
//@description Pins a message in a chat; requires can_pin_messages rights or can_edit_messages rights in the channel
|
||||
@ -4770,7 +4770,7 @@ getChatMember chat_id:int53 member_id:MessageSender = ChatMember;
|
||||
//@description Searches for a specified query in the first name, last name and username of the members of a specified chat. Requires administrator rights in channels
|
||||
//@chat_id Chat identifier
|
||||
//@query Query to search for
|
||||
//@limit The maximum number of users to be returned
|
||||
//@limit The maximum number of users to be returned; up to 200
|
||||
//@filter The type of users to search for; pass null to search among all chat members
|
||||
searchChatMembers chat_id:int53 query:string limit:int32 filter:ChatMembersFilter = ChatMembers;
|
||||
|
||||
@ -4901,11 +4901,11 @@ getChatInviteLinkCounts chat_id:int53 = ChatInviteLinkCounts;
|
||||
//@is_revoked Pass true if revoked links needs to be returned instead of active or expired
|
||||
//@offset_date Creation date of an invite link starting after which to return invite links; use 0 to get results from the beginning
|
||||
//@offset_invite_link Invite link starting after which to return invite links; use empty string to get results from the beginning
|
||||
//@limit The maximum number of invite links to return
|
||||
//@limit The maximum number of invite links to return; up to 100
|
||||
getChatInviteLinks chat_id:int53 creator_user_id:int53 is_revoked:Bool offset_date:int32 offset_invite_link:string limit:int32 = ChatInviteLinks;
|
||||
|
||||
//@description Returns chat members joined a chat by an invite link. Requires administrator privileges and can_invite_users right in the chat for own links and owner privileges for other links @chat_id Chat identifier @invite_link Invite link for which to return chat members
|
||||
//@offset_member A chat member from which to return next chat members; pass null to get results from the beginning @limit The maximum number of chat members to return
|
||||
//@offset_member A chat member from which to return next chat members; pass null to get results from the beginning @limit The maximum number of chat members to return; up to 100
|
||||
getChatInviteLinkMembers chat_id:int53 invite_link:string offset_member:chatInviteLinkMember limit:int32 = ChatInviteLinkMembers;
|
||||
|
||||
//@description Revokes invite link for a chat. Available for basic groups, supergroups, and channels. Requires administrator privileges and can_invite_users right in the chat for own links and owner privileges for other links.
|
||||
@ -5043,7 +5043,7 @@ toggleGroupCallParticipantIsHandRaised group_call_id:int32 participant_id:Messag
|
||||
|
||||
//@description Loads more participants of a group call. The loaded participants will be received through updates. Use the field groupCall.loaded_all_participants to check whether all participants has already been loaded
|
||||
//@group_call_id Group call identifier. The group call must be previously received through getGroupCall and must be joined or being joined
|
||||
//@limit The maximum number of participants to load
|
||||
//@limit The maximum number of participants to load; up to 100
|
||||
loadGroupCallParticipants group_call_id:int32 limit:int32 = Ok;
|
||||
|
||||
//@description Leaves a group call @group_call_id Group call identifier
|
||||
@ -5119,12 +5119,12 @@ searchStickers emoji:string limit:int32 = Stickers;
|
||||
//@description Returns a list of installed sticker sets @is_masks Pass true to return mask sticker sets; pass false to return ordinary sticker sets
|
||||
getInstalledStickerSets is_masks:Bool = StickerSets;
|
||||
|
||||
//@description Returns a list of archived sticker sets @is_masks Pass true to return mask stickers sets; pass false to return ordinary sticker sets @offset_sticker_set_id Identifier of the sticker set from which to return the result @limit The maximum number of sticker sets to return
|
||||
//@description Returns a list of archived sticker sets @is_masks Pass true to return mask stickers sets; pass false to return ordinary sticker sets @offset_sticker_set_id Identifier of the sticker set from which to return the result @limit The maximum number of sticker sets to return; up to 100
|
||||
getArchivedStickerSets is_masks:Bool offset_sticker_set_id:int64 limit:int32 = StickerSets;
|
||||
|
||||
//@description Returns a list of trending sticker sets. For optimal performance, the number of returned sticker sets is chosen by TDLib
|
||||
//@offset The offset from which to return the sticker sets; must be non-negative
|
||||
//@limit The maximum number of sticker sets to be returned; must be non-negative. For optimal performance, the number of returned sticker sets is chosen by TDLib and can be smaller than the specified limit, even if the end of the list has not been reached
|
||||
//@limit The maximum number of sticker sets to be returned; up to 100. For optimal performance, the number of returned sticker sets is chosen by TDLib and can be smaller than the specified limit, even if the end of the list has not been reached
|
||||
getTrendingStickerSets offset:int32 limit:int32 = StickerSets;
|
||||
|
||||
//@description Returns a list of sticker sets attached to a file. Currently only photos and videos can have attached sticker sets @file_id File identifier
|
||||
|
@ -2223,8 +2223,8 @@ static FormattedText parse_text_url_entities_v3(Slice text, const vector<Message
|
||||
}
|
||||
|
||||
size_t splittable_entity_pos[SPLITTABLE_ENTITY_TYPE_COUNT] = {};
|
||||
for (size_t index = 0; index < SPLITTABLE_ENTITY_TYPE_COUNT; index++) {
|
||||
check_non_intersecting(part_splittable_entities[index]);
|
||||
for (const auto &splittable_entities : part_splittable_entities) {
|
||||
check_non_intersecting(splittable_entities);
|
||||
}
|
||||
if (part_end != max_end) {
|
||||
// try to find text_url entities in the left part
|
||||
|
@ -2266,7 +2266,7 @@ class SearchMessagesQuery final : public Td::ResultHandler {
|
||||
}
|
||||
|
||||
void on_error(uint64 id, Status status) final {
|
||||
if (!handle_errors_) {
|
||||
if (handle_errors_) {
|
||||
td->messages_manager_->on_get_dialog_error(dialog_id_, status, "SearchMessagesQuery");
|
||||
}
|
||||
td->messages_manager_->on_failed_dialog_messages_search(dialog_id_, random_id_);
|
||||
|
@ -5910,8 +5910,7 @@ void StickersManager::on_load_recent_stickers_finished(bool is_attached, vector<
|
||||
}
|
||||
recent_sticker_ids_[is_attached] = std::move(recent_sticker_ids);
|
||||
are_recent_stickers_loaded_[is_attached] = true;
|
||||
need_update_recent_stickers_[is_attached] = true;
|
||||
send_update_recent_stickers(from_database);
|
||||
send_update_recent_stickers(is_attached, from_database);
|
||||
auto promises = std::move(load_recent_stickers_queries_[is_attached]);
|
||||
load_recent_stickers_queries_[is_attached].clear();
|
||||
for (auto &promise : promises) {
|
||||
@ -6083,8 +6082,6 @@ void StickersManager::add_recent_sticker_impl(bool is_attached, FileId sticker_i
|
||||
return promise.set_error(Status::Error(400, "Can't save encrypted stickers"));
|
||||
}
|
||||
|
||||
need_update_recent_stickers_[is_attached] = true;
|
||||
|
||||
auto it = std::find_if(sticker_ids.begin(), sticker_ids.end(), is_equal);
|
||||
if (it == sticker_ids.end()) {
|
||||
if (static_cast<int32>(sticker_ids.size()) == recent_stickers_limit_) {
|
||||
@ -6099,7 +6096,7 @@ void StickersManager::add_recent_sticker_impl(bool is_attached, FileId sticker_i
|
||||
sticker_ids[0] = sticker_id;
|
||||
}
|
||||
|
||||
send_update_recent_stickers();
|
||||
send_update_recent_stickers(is_attached);
|
||||
if (add_on_server) {
|
||||
send_save_recent_sticker_query(is_attached, sticker_id, false, std::move(promise));
|
||||
}
|
||||
@ -6130,8 +6127,7 @@ void StickersManager::remove_recent_sticker(bool is_attached, const tl_object_pt
|
||||
|
||||
send_save_recent_sticker_query(is_attached, file_id, true, std::move(promise));
|
||||
|
||||
need_update_recent_stickers_[is_attached] = true;
|
||||
send_update_recent_stickers();
|
||||
send_update_recent_stickers(is_attached);
|
||||
}
|
||||
|
||||
void StickersManager::clear_recent_stickers(bool is_attached, Promise<Unit> &&promise) {
|
||||
@ -6150,8 +6146,7 @@ void StickersManager::clear_recent_stickers(bool is_attached, Promise<Unit> &&pr
|
||||
|
||||
sticker_ids.clear();
|
||||
|
||||
need_update_recent_stickers_[is_attached] = true;
|
||||
send_update_recent_stickers();
|
||||
send_update_recent_stickers(is_attached);
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::updateRecentStickers> StickersManager::get_update_recent_stickers_object(
|
||||
@ -6160,30 +6155,27 @@ td_api::object_ptr<td_api::updateRecentStickers> StickersManager::get_update_rec
|
||||
is_attached != 0, td_->file_manager_->get_file_ids_object(recent_sticker_ids_[is_attached]));
|
||||
}
|
||||
|
||||
void StickersManager::send_update_recent_stickers(bool from_database) {
|
||||
for (int is_attached = 0; is_attached < 2; is_attached++) {
|
||||
if (need_update_recent_stickers_[is_attached]) {
|
||||
need_update_recent_stickers_[is_attached] = false;
|
||||
if (are_recent_stickers_loaded_[is_attached]) {
|
||||
vector<FileId> new_recent_sticker_file_ids;
|
||||
for (auto &sticker_id : recent_sticker_ids_[is_attached]) {
|
||||
append(new_recent_sticker_file_ids, get_sticker_file_ids(sticker_id));
|
||||
}
|
||||
std::sort(new_recent_sticker_file_ids.begin(), new_recent_sticker_file_ids.end());
|
||||
if (new_recent_sticker_file_ids != recent_sticker_file_ids_[is_attached]) {
|
||||
td_->file_manager_->change_files_source(get_recent_stickers_file_source_id(is_attached),
|
||||
recent_sticker_file_ids_[is_attached], new_recent_sticker_file_ids);
|
||||
recent_sticker_file_ids_[is_attached] = std::move(new_recent_sticker_file_ids);
|
||||
}
|
||||
void StickersManager::send_update_recent_stickers(bool is_attached, bool from_database) {
|
||||
if (!are_recent_stickers_loaded_[is_attached]) {
|
||||
return;
|
||||
}
|
||||
|
||||
recent_stickers_hash_[is_attached] = get_recent_stickers_hash(recent_sticker_ids_[is_attached]);
|
||||
send_closure(G()->td(), &Td::send_update, get_update_recent_stickers_object(is_attached));
|
||||
vector<FileId> new_recent_sticker_file_ids;
|
||||
for (auto &sticker_id : recent_sticker_ids_[is_attached]) {
|
||||
append(new_recent_sticker_file_ids, get_sticker_file_ids(sticker_id));
|
||||
}
|
||||
std::sort(new_recent_sticker_file_ids.begin(), new_recent_sticker_file_ids.end());
|
||||
if (new_recent_sticker_file_ids != recent_sticker_file_ids_[is_attached]) {
|
||||
td_->file_manager_->change_files_source(get_recent_stickers_file_source_id(is_attached),
|
||||
recent_sticker_file_ids_[is_attached], new_recent_sticker_file_ids);
|
||||
recent_sticker_file_ids_[is_attached] = std::move(new_recent_sticker_file_ids);
|
||||
}
|
||||
|
||||
if (!from_database) {
|
||||
save_recent_stickers_to_database(is_attached != 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
recent_stickers_hash_[is_attached] = get_recent_stickers_hash(recent_sticker_ids_[is_attached]);
|
||||
send_closure(G()->td(), &Td::send_update, get_update_recent_stickers_object(is_attached));
|
||||
|
||||
if (!from_database) {
|
||||
save_recent_stickers_to_database(is_attached != 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -6204,7 +6196,7 @@ void StickersManager::on_update_recent_stickers_limit(int32 recent_stickers_limi
|
||||
for (int is_attached = 0; is_attached < 2; is_attached++) {
|
||||
if (static_cast<int32>(recent_sticker_ids_[is_attached].size()) > recent_stickers_limit) {
|
||||
recent_sticker_ids_[is_attached].resize(recent_stickers_limit);
|
||||
send_update_recent_stickers();
|
||||
send_update_recent_stickers(is_attached);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -539,7 +539,7 @@ class StickersManager final : public Actor {
|
||||
|
||||
td_api::object_ptr<td_api::updateRecentStickers> get_update_recent_stickers_object(int is_attached) const;
|
||||
|
||||
void send_update_recent_stickers(bool from_database = false);
|
||||
void send_update_recent_stickers(bool is_attached, bool from_database = false);
|
||||
|
||||
void save_recent_stickers_to_database(bool is_attached);
|
||||
|
||||
@ -706,7 +706,6 @@ class StickersManager final : public Actor {
|
||||
|
||||
bool need_update_installed_sticker_sets_[2] = {false, false};
|
||||
bool need_update_featured_sticker_sets_ = false;
|
||||
bool need_update_recent_stickers_[2] = {false, false};
|
||||
|
||||
bool are_installed_sticker_sets_loaded_[2] = {false, false};
|
||||
bool are_featured_sticker_sets_loaded_ = false;
|
||||
|
@ -23,9 +23,9 @@ namespace tl {
|
||||
namespace simple {
|
||||
|
||||
inline std::string gen_cpp_name(std::string name) {
|
||||
for (std::size_t i = 0; i < name.size(); i++) {
|
||||
if ((name[i] < '0' || '9' < name[i]) && (name[i] < 'a' || 'z' < name[i]) && (name[i] < 'A' || 'Z' < name[i])) {
|
||||
name[i] = '_';
|
||||
for (auto &c : name) {
|
||||
if ((c < '0' || '9' < c) && (c < 'a' || 'z' < c) && (c < 'A' || 'Z' < c)) {
|
||||
c = '_';
|
||||
}
|
||||
}
|
||||
assert(!name.empty());
|
||||
|
Loading…
Reference in New Issue
Block a user