Merge remote-tracking branch 'td/master'

This commit is contained in:
Andrea Cavalli 2021-12-09 17:04:06 +01:00
commit e936461bdf
15 changed files with 58 additions and 35 deletions

View File

@ -1,4 +1,5 @@
#!/bin/sh
cd $(dirname $0)
git clone https://github.com/beeware/Python-Apple-support
cd Python-Apple-support

View File

@ -1,4 +1,5 @@
#!/bin/sh
cd $(dirname $0)
td_path=$(grealpath ../..)
rm -rf build

View File

@ -1,4 +1,5 @@
#!/bin/sh
cd $(dirname $0)
emconfigure true 2> /dev/null || { echo 'emconfigure not found. Install emsdk and add emconfigure and emmake to PATH environment variable. See instruction at https://kripken.github.io/emscripten-site/docs/getting_started/downloads.html. Do not forget to add `emconfigure` and `emmake` to the PATH environment variable via `emsdk/emsdk_env.sh` script.'; exit 1; }

View File

@ -1,4 +1,5 @@
#!/bin/sh
cd $(dirname $0)
emcmake true 2> /dev/null || { echo 'emcmake not found. Install emsdk and add emcmake and emmake to PATH environment variable. See instruction at https://kripken.github.io/emscripten-site/docs/getting_started/downloads.html. Do not forget to add `emcmake` and `emmake` to the PATH environment variable via `emsdk/emsdk_env.sh` script.'; exit 1; }

View File

@ -1,4 +1,5 @@
#!/bin/sh
cd $(dirname $0)
cd tdweb || exit 1
npm install --no-save || exit 1

View File

@ -1,4 +1,5 @@
#!/bin/sh
cd $(dirname $0)
DEST=tdweb/src/prebuilt/release/
mkdir -p $DEST || exit 1

View File

@ -1,2 +1,3 @@
#!/bin/sh
cd $(dirname $0)
./src.sh | grep -v CxCli.h | grep -iv dotnet | grep -v /tl-parser/ | xargs -n 1 clang-format -verbose -style=file -i

View File

@ -1,4 +1,5 @@
#!/bin/sh
cd $(dirname $0)
commit=$(git rev-parse HEAD)
git diff-index --quiet HEAD
dirty=$?

View File

@ -2078,12 +2078,6 @@ searchMessagesFilterUrl = SearchMessagesFilter;
//@description Returns only messages containing chat photos
searchMessagesFilterChatPhoto = SearchMessagesFilter;
//@description Returns only call messages
searchMessagesFilterCall = SearchMessagesFilter;
//@description Returns only incoming call messages with missed/declined discard reasons
searchMessagesFilterMissedCall = SearchMessagesFilter;
//@description Returns only video note messages
searchMessagesFilterVideoNote = SearchMessagesFilter;
@ -4327,7 +4321,7 @@ searchChatMessages chat_id:int53 query:string sender_id:MessageSender from_messa
//@offset_chat_id The chat identifier of the last found message, or 0 for the first request
//@offset_message_id The message identifier of the last found message, or 0 for the first request
//@limit The maximum number of messages to be returned; up to 100. For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit
//@filter Additional filter for messages to search; pass null to search for all messages. Filters searchMessagesFilterCall, searchMessagesFilterMissedCall, searchMessagesFilterMention, searchMessagesFilterUnreadMention, searchMessagesFilterFailedToSend and searchMessagesFilterPinned are unsupported in this function
//@filter Additional filter for messages to search; pass null to search for all messages. Filters searchMessagesFilterMention, searchMessagesFilterUnreadMention, searchMessagesFilterFailedToSend and searchMessagesFilterPinned are unsupported in this function
//@min_date If not 0, the minimum date of the messages to return
//@max_date If not 0, the maximum date of the messages to return
searchMessages chat_list:ChatList query:string offset_date:int32 offset_chat_id:int53 offset_message_id:int53 limit:int32 filter:SearchMessagesFilter min_date:int32 max_date:int32 = Messages;
@ -4342,7 +4336,7 @@ searchSecretMessages chat_id:int53 query:string offset:string limit:int32 filter
//@description Searches for call messages. Returns the results in reverse chronological order (i. e., in order of decreasing message_id). For optimal performance, the number of returned messages is chosen by TDLib
//@from_message_id Identifier of the message from which to search; use 0 to get results from the last message
//@limit The maximum number of messages to be returned; up to 100. For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit @only_missed If true, returns only messages with missed calls
//@limit The maximum number of messages to be returned; up to 100. For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit @only_missed If true, returns only messages with missed/declined calls
searchCallMessages from_message_id:int53 limit:int32 only_missed:Bool = Messages;
//@description Deletes all call messages @revoke Pass true to delete the messages for all users
@ -4360,14 +4354,14 @@ getChatMessageByDate chat_id:int53 date:int32 = Message;
//@description Returns sparse positions of messages of the specified type in the chat to be used for shared media scroll implementation. Returns the results in reverse chronological order (i.e., in order of decreasing message_id).
//-Cannot be used in secret chats or with searchMessagesFilterFailedToSend filter without an enabled message database
//@chat_id Identifier of the chat in which to return information about message positions
//@filter Filter for message content. Filters searchMessagesFilterEmpty, searchMessagesFilterCall, searchMessagesFilterMissedCall, searchMessagesFilterMention and searchMessagesFilterUnreadMention are unsupported in this function
//@filter Filter for message content. Filters searchMessagesFilterEmpty, searchMessagesFilterMention and searchMessagesFilterUnreadMention are unsupported in this function
//@from_message_id The message identifier from which to return information about message positions
//@limit The expected number of message positions to be returned; 50-2000. A smaller number of positions can be returned, if there are not enough appropriate messages
getChatSparseMessagePositions chat_id:int53 filter:SearchMessagesFilter from_message_id:int53 limit:int32 = MessagePositions;
//@description Returns information about the next messages of the specified type in the chat splitted by days. Returns the results in reverse chronological order. Can return partial result for the last returned day. Behavior of this method depends on the value of the option "utc_time_offset"
//@chat_id Identifier of the chat in which to return information about messages
//@filter Filter for message content. Filters searchMessagesFilterEmpty, searchMessagesFilterCall, searchMessagesFilterMissedCall, searchMessagesFilterMention and searchMessagesFilterUnreadMention are unsupported in this function
//@filter Filter for message content. Filters searchMessagesFilterEmpty, searchMessagesFilterMention and searchMessagesFilterUnreadMention are unsupported in this function
//@from_message_id The message identifier from which to return information about messages; use 0 to get results from the last message
getChatMessageCalendar chat_id:int53 filter:SearchMessagesFilter from_message_id:int53 = MessageCalendar;

View File

@ -3191,6 +3191,7 @@ ContactsManager::ContactsManager(Td *td, ActorShared<> parent) : td_(td), parent
DialogId(get_service_notifications_user_id()).get());
G()->shared_config().set_option_integer("replies_bot_chat_id", DialogId(get_replies_bot_user_id()).get());
G()->shared_config().set_option_integer("group_anonymous_bot_user_id", get_anonymous_bot_user_id().get());
G()->shared_config().set_option_integer("channel_bot_user_id", get_channel_bot_user_id().get());
if (G()->parameters().use_chat_info_db) {
auto next_contacts_sync_date_string = G()->td_db()->get_binlog_pmc()->get("next_contacts_sync_date");
@ -4922,6 +4923,10 @@ UserId ContactsManager::get_anonymous_bot_user_id() {
return UserId(static_cast<int64>(G()->is_test_dc() ? 552888 : 1087968824));
}
UserId ContactsManager::get_channel_bot_user_id() {
return UserId(static_cast<int64>(G()->is_test_dc() ? 936174 : 136817688));
}
UserId ContactsManager::add_anonymous_bot_user() {
auto user_id = get_anonymous_bot_user_id();
if (!have_user_force(user_id)) {
@ -4930,6 +4935,14 @@ UserId ContactsManager::add_anonymous_bot_user() {
return user_id;
}
UserId ContactsManager::add_channel_bot_user() {
auto user_id = get_channel_bot_user_id();
if (!have_user_force(user_id)) {
LOG(FATAL) << "Failed to load channel bot user";
}
return user_id;
}
void ContactsManager::check_dialog_username(DialogId dialog_id, const string &username,
Promise<CheckDialogUsernameResult> &&promise) {
if (dialog_id != DialogId() && !dialog_id.is_valid()) {
@ -8647,7 +8660,7 @@ ContactsManager::User *ContactsManager::get_user_force(UserId user_id) {
auto u = get_user_force_impl(user_id);
if ((u == nullptr || !u->is_received) &&
(user_id == get_service_notifications_user_id() || user_id == get_replies_bot_user_id() ||
user_id == get_anonymous_bot_user_id())) {
user_id == get_anonymous_bot_user_id() || user_id == get_channel_bot_user_id())) {
int32 flags = USER_FLAG_HAS_ACCESS_HASH | USER_FLAG_HAS_FIRST_NAME | USER_FLAG_NEED_APPLY_MIN_PHOTO;
int64 profile_photo_id = 0;
int32 profile_photo_dc_id = 1;
@ -8683,6 +8696,15 @@ ContactsManager::User *ContactsManager::get_user_force(UserId user_id) {
username = G()->is_test_dc() ? "izgroupbot" : "GroupAnonymousBot";
bot_info_version = G()->is_test_dc() ? 1 : 3;
profile_photo_id = 5159307831025969322;
} else if (user_id == get_channel_bot_user_id()) {
flags |= USER_FLAG_HAS_USERNAME | USER_FLAG_IS_BOT;
if (!G()->is_test_dc()) {
flags |= USER_FLAG_IS_PRIVATE_BOT;
}
first_name = G()->is_test_dc() ? "Channels" : "Channel";
username = G()->is_test_dc() ? "channelsbot" : "Channel_Bot";
bot_info_version = G()->is_test_dc() ? 1 : 4;
profile_photo_id = 587627495930570665;
}
telegram_api::object_ptr<telegram_api::userProfilePhoto> profile_photo;
@ -10409,8 +10431,8 @@ void ContactsManager::on_get_user_photos(UserId user_id, int32 offset, int32 lim
auto photo_count = narrow_cast<int32>(photos.size());
int32 min_total_count = (offset >= 0 && photo_count > 0 ? offset : 0) + photo_count;
if (total_count < min_total_count) {
LOG(ERROR) << "Wrong photos total_count " << total_count << ". Receive " << photo_count << " photos with offset "
<< offset;
LOG(ERROR) << "Receive wrong photos total_count " << total_count << " for user " << user_id << ": receive "
<< photo_count << " photos with offset " << offset;
total_count = min_total_count;
}
LOG_IF(ERROR, limit < photo_count) << "Requested not more than " << limit << " photos, but " << photo_count
@ -13939,7 +13961,7 @@ bool ContactsManager::get_user(UserId user_id, int left_tries, Promise<Unit> &&p
}
if (user_id == get_service_notifications_user_id() || user_id == get_replies_bot_user_id() ||
user_id == get_anonymous_bot_user_id()) {
user_id == get_anonymous_bot_user_id() || user_id == get_channel_bot_user_id()) {
get_user_force(user_id);
}

View File

@ -265,8 +265,12 @@ class ContactsManager final : public Actor {
static UserId get_anonymous_bot_user_id();
static UserId get_channel_bot_user_id();
UserId add_anonymous_bot_user();
UserId add_channel_bot_user();
void on_update_online_status_privacy();
void on_update_phone_number_privacy();

View File

@ -78,10 +78,6 @@ MessageSearchFilter get_message_search_filter(const tl_object_ptr<td_api::Search
return MessageSearchFilter::Url;
case td_api::searchMessagesFilterChatPhoto::ID:
return MessageSearchFilter::ChatPhoto;
case td_api::searchMessagesFilterCall::ID:
return MessageSearchFilter::Call;
case td_api::searchMessagesFilterMissedCall::ID:
return MessageSearchFilter::MissedCall;
case td_api::searchMessagesFilterVideoNote::ID:
return MessageSearchFilter::VideoNote;
case td_api::searchMessagesFilterVoiceAndVideoNote::ID:

View File

@ -45,6 +45,7 @@ td_api::object_ptr<td_api::MessageSender> get_message_sender_object(Td *td, User
}
if (!user_id.is_valid() && td->auth_manager_->is_bot()) {
td->contacts_manager_->add_anonymous_bot_user();
td->contacts_manager_->add_channel_bot_user();
td->contacts_manager_->add_service_notifications_user();
}
return get_message_sender_object_const(td, user_id, dialog_id, source);

View File

@ -13636,6 +13636,7 @@ std::pair<DialogId, unique_ptr<MessagesManager::Message>> MessagesManager::creat
td_->contacts_manager_->add_anonymous_bot_user();
} else {
td_->contacts_manager_->add_service_notifications_user();
td_->contacts_manager_->add_channel_bot_user();
}
}
}
@ -13848,10 +13849,12 @@ std::pair<DialogId, unique_ptr<MessagesManager::Message>> MessagesManager::creat
if (message_info.media_album_id != 0) {
if (!is_allowed_media_group_content(content_type)) {
LOG(ERROR) << "Receive media group identifier " << message_info.media_album_id << " in " << message_id << " from "
<< dialog_id << " with content "
<< oneline(to_string(get_message_content_object(message->content.get(), td_, dialog_id, message->date,
is_content_secret, false, -1)));
if (content_type != MessageContentType::Unsupported) {
LOG(ERROR) << "Receive media group identifier " << message_info.media_album_id << " in " << message_id
<< " from " << dialog_id << " with content "
<< oneline(to_string(get_message_content_object(message->content.get(), td_, dialog_id,
message->date, is_content_secret, false, -1)));
}
} else {
message->media_album_id = message_info.media_album_id;
}
@ -17553,6 +17556,7 @@ Status MessagesManager::can_get_message_viewers(DialogId dialog_id, const Messag
if (m->content->get_type() == MessageContentType::Poll &&
get_message_content_poll_is_anonymous(td_, m->content.get())) {
return Status::Error(400, "Anonymous poll viewers are unavailable");
}
return Status::OK();
@ -21426,8 +21430,8 @@ td_api::object_ptr<td_api::messageCalendar> MessagesManager::get_dialog_message_
} while (random_id == 0 || found_dialog_message_calendars_.find(random_id) != found_dialog_message_calendars_.end());
found_dialog_message_calendars_[random_id]; // reserve place for result
if (filter == MessageSearchFilter::Empty || filter == MessageSearchFilter::Call ||
filter == MessageSearchFilter::MissedCall || filter == MessageSearchFilter::Mention ||
CHECK(filter != MessageSearchFilter::Call && filter != MessageSearchFilter::MissedCall);
if (filter == MessageSearchFilter::Empty || filter == MessageSearchFilter::Mention ||
filter == MessageSearchFilter::UnreadMention) {
promise.set_error(Status::Error(400, "The filter is not supported"));
return {};
@ -21697,7 +21701,6 @@ std::pair<int32, vector<MessageId>> MessagesManager::search_dialog_messages(
<< " and with limit " << limit;
switch (dialog_id.get_type()) {
case DialogType::None:
case DialogType::User:
case DialogType::Chat:
case DialogType::Channel:
@ -21712,6 +21715,7 @@ std::pair<int32, vector<MessageId>> MessagesManager::search_dialog_messages(
promise.set_error(Status::Error(500, "Search messages in secret chats is not supported"));
}
break;
case DialogType::None:
default:
UNREACHABLE();
promise.set_error(Status::Error(500, "Search messages is not supported"));
@ -22444,8 +22448,8 @@ std::pair<int32, vector<FullMessageId>> MessagesManager::search_messages(
return {};
}
if (filter == MessageSearchFilter::Call || filter == MessageSearchFilter::MissedCall ||
filter == MessageSearchFilter::Mention || filter == MessageSearchFilter::UnreadMention ||
CHECK(filter != MessageSearchFilter::Call && filter != MessageSearchFilter::MissedCall);
if (filter == MessageSearchFilter::Mention || filter == MessageSearchFilter::UnreadMention ||
filter == MessageSearchFilter::FailedToSend || filter == MessageSearchFilter::Pinned) {
promise.set_error(Status::Error(400, "The filter is not supported"));
return {};
@ -22702,8 +22706,8 @@ void MessagesManager::get_dialog_sparse_message_positions(
return promise.set_error(Status::Error(400, "Invalid limit specified"));
}
if (filter == MessageSearchFilter::Empty || filter == MessageSearchFilter::Call ||
filter == MessageSearchFilter::MissedCall || filter == MessageSearchFilter::Mention ||
CHECK(filter != MessageSearchFilter::Call && filter != MessageSearchFilter::MissedCall);
if (filter == MessageSearchFilter::Empty || filter == MessageSearchFilter::Mention ||
filter == MessageSearchFilter::UnreadMention || filter == MessageSearchFilter::Pinned) {
return promise.set_error(Status::Error(400, "The filter is not supported"));
}

View File

@ -1152,12 +1152,6 @@ class CliClient final : public Actor {
if (filter == "cp" || filter == "chatphoto") {
return td_api::make_object<td_api::searchMessagesFilterChatPhoto>();
}
if (filter == "c" || filter == "call") {
return td_api::make_object<td_api::searchMessagesFilterCall>();
}
if (filter == "mc" || filter == "missedcall") {
return td_api::make_object<td_api::searchMessagesFilterMissedCall>();
}
if (filter == "vn" || filter == "videonote") {
return td_api::make_object<td_api::searchMessagesFilterVideoNote>();
}