diff --git a/example/ios/build-openssl.sh b/example/ios/build-openssl.sh index ce489e717..21ed07eed 100755 --- a/example/ios/build-openssl.sh +++ b/example/ios/build-openssl.sh @@ -1,4 +1,5 @@ #!/bin/sh +cd $(dirname $0) git clone https://github.com/beeware/Python-Apple-support cd Python-Apple-support diff --git a/example/ios/build.sh b/example/ios/build.sh index 4c5aaa5ba..cd11907b2 100755 --- a/example/ios/build.sh +++ b/example/ios/build.sh @@ -1,4 +1,5 @@ #!/bin/sh +cd $(dirname $0) td_path=$(grealpath ../..) rm -rf build diff --git a/example/web/build-openssl.sh b/example/web/build-openssl.sh index 0766399f6..39e1d2d0d 100755 --- a/example/web/build-openssl.sh +++ b/example/web/build-openssl.sh @@ -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; } diff --git a/example/web/build-tdlib.sh b/example/web/build-tdlib.sh index 164b5f924..e013ccc29 100755 --- a/example/web/build-tdlib.sh +++ b/example/web/build-tdlib.sh @@ -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; } diff --git a/example/web/build-tdweb.sh b/example/web/build-tdweb.sh index 604f94a8b..730f79a4b 100755 --- a/example/web/build-tdweb.sh +++ b/example/web/build-tdweb.sh @@ -1,4 +1,5 @@ #!/bin/sh +cd $(dirname $0) cd tdweb || exit 1 npm install --no-save || exit 1 diff --git a/example/web/copy-tdlib.sh b/example/web/copy-tdlib.sh index f094de6cc..f7167d570 100755 --- a/example/web/copy-tdlib.sh +++ b/example/web/copy-tdlib.sh @@ -1,4 +1,5 @@ #!/bin/sh +cd $(dirname $0) DEST=tdweb/src/prebuilt/release/ mkdir -p $DEST || exit 1 diff --git a/format.sh b/format.sh index c33dabb5a..2a9a39f94 100755 --- a/format.sh +++ b/format.sh @@ -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 diff --git a/gen_git_commit_h.sh b/gen_git_commit_h.sh index b3416b298..15ede4cd7 100755 --- a/gen_git_commit_h.sh +++ b/gen_git_commit_h.sh @@ -1,4 +1,5 @@ #!/bin/sh +cd $(dirname $0) commit=$(git rev-parse HEAD) git diff-index --quiet HEAD dirty=$? diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 2fff4a3e8..bc16d1e7e 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -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; diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index e4c76501a..a9164ca16 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -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(G()->is_test_dc() ? 552888 : 1087968824)); } +UserId ContactsManager::get_channel_bot_user_id() { + return UserId(static_cast(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 &&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 profile_photo; @@ -10409,8 +10431,8 @@ void ContactsManager::on_get_user_photos(UserId user_id, int32 offset, int32 lim auto photo_count = narrow_cast(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 &&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); } diff --git a/td/telegram/ContactsManager.h b/td/telegram/ContactsManager.h index 87e7f06e8..89305f48b 100644 --- a/td/telegram/ContactsManager.h +++ b/td/telegram/ContactsManager.h @@ -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(); diff --git a/td/telegram/MessageSearchFilter.cpp b/td/telegram/MessageSearchFilter.cpp index c6015cb84..65c4202c6 100644 --- a/td/telegram/MessageSearchFilter.cpp +++ b/td/telegram/MessageSearchFilter.cpp @@ -78,10 +78,6 @@ MessageSearchFilter get_message_search_filter(const tl_object_ptr 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); diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 15bee6966..291cfa91c 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -13636,6 +13636,7 @@ std::pair> 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> 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 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> 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> 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> 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")); } diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index 2a6f6a14e..1410e688a 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -1152,12 +1152,6 @@ class CliClient final : public Actor { if (filter == "cp" || filter == "chatphoto") { return td_api::make_object(); } - if (filter == "c" || filter == "call") { - return td_api::make_object(); - } - if (filter == "mc" || filter == "missedcall") { - return td_api::make_object(); - } if (filter == "vn" || filter == "videonote") { return td_api::make_object(); }