Merge remote-tracking branch 'td/master'
This commit is contained in:
commit
32224f0b5a
@ -4113,7 +4113,8 @@ unique_ptr<MessageContent> get_message_content(Td *td, FormattedText message,
|
||||
tl_object_ptr<telegram_api::MessageMedia> &&media,
|
||||
DialogId owner_dialog_id, bool is_content_read, UserId via_bot_user_id,
|
||||
int32 *ttl, bool *disable_web_page_preview) {
|
||||
if (!td->auth_manager_->was_authorized() && !G()->close_flag() && media != nullptr) {
|
||||
if (!td->auth_manager_->was_authorized() && !G()->close_flag() && media != nullptr &&
|
||||
media->get_id() != telegram_api::messageMediaEmpty::ID) {
|
||||
LOG(ERROR) << "Receive without authorization " << to_string(media);
|
||||
media = nullptr;
|
||||
}
|
||||
|
@ -9121,6 +9121,48 @@ void MessagesManager::on_get_messages(vector<tl_object_ptr<telegram_api::Message
|
||||
promise.set_value(Unit());
|
||||
}
|
||||
|
||||
bool MessagesManager::delete_newer_server_messages_at_the_end(Dialog *d, MessageId max_message_id) {
|
||||
vector<MessageId> message_ids;
|
||||
find_newer_messages(d->messages.get(), max_message_id, message_ids);
|
||||
if (message_ids.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool need_update_dialog_pos = false;
|
||||
vector<int64> deleted_message_ids;
|
||||
for (auto message_id : message_ids) {
|
||||
CHECK(message_id > max_message_id);
|
||||
if (message_id.is_server()) {
|
||||
auto message =
|
||||
delete_message(d, message_id, true, &need_update_dialog_pos, "delete_newer_server_messages_at_the_end 1");
|
||||
CHECK(message != nullptr);
|
||||
deleted_message_ids.push_back(message->message_id.get());
|
||||
}
|
||||
}
|
||||
if (need_update_dialog_pos) {
|
||||
send_update_chat_last_message(d, "delete_newer_server_messages_at_the_end 2");
|
||||
}
|
||||
|
||||
if (!deleted_message_ids.empty()) {
|
||||
send_update_delete_messages(d->dialog_id, std::move(deleted_message_ids), true, false);
|
||||
|
||||
message_ids.clear();
|
||||
find_newer_messages(d->messages.get(), max_message_id, message_ids);
|
||||
}
|
||||
|
||||
// connect all messages with ID > max_message_id
|
||||
for (size_t i = 0; i + 1 < message_ids.size(); i++) {
|
||||
auto m = get_message(d, message_ids[i]);
|
||||
CHECK(m != nullptr);
|
||||
if (!m->have_next) {
|
||||
m->have_next = true;
|
||||
attach_message_to_next(d, message_ids[i], "delete_newer_server_messages_at_the_end 3");
|
||||
}
|
||||
}
|
||||
|
||||
return !message_ids.empty();
|
||||
}
|
||||
|
||||
void MessagesManager::on_get_history(DialogId dialog_id, MessageId from_message_id, MessageId old_last_new_message_id,
|
||||
int32 offset, int32 limit, bool from_the_end,
|
||||
vector<tl_object_ptr<telegram_api::Message>> &&messages, Promise<Unit> &&promise) {
|
||||
@ -9219,43 +9261,8 @@ void MessagesManager::on_get_history(DialogId dialog_id, MessageId from_message_
|
||||
if (from_the_end) {
|
||||
// delete all server messages with ID > last_received_message_id
|
||||
// there were no new messages received after the getHistory request was sent, so they are already deleted message
|
||||
vector<MessageId> message_ids;
|
||||
find_newer_messages(d->messages.get(), last_received_message_id, message_ids);
|
||||
if (!message_ids.empty()) {
|
||||
bool need_update_dialog_pos = false;
|
||||
vector<int64> deleted_message_ids;
|
||||
for (auto message_id : message_ids) {
|
||||
CHECK(message_id > last_received_message_id);
|
||||
if (message_id.is_server()) {
|
||||
auto message = delete_message(d, message_id, true, &need_update_dialog_pos, "on_get_gistory 1");
|
||||
CHECK(message != nullptr);
|
||||
deleted_message_ids.push_back(message->message_id.get());
|
||||
}
|
||||
}
|
||||
if (need_update_dialog_pos) {
|
||||
send_update_chat_last_message(d, "on_get_gistory 2");
|
||||
}
|
||||
|
||||
if (!deleted_message_ids.empty()) {
|
||||
send_update_delete_messages(dialog_id, std::move(deleted_message_ids), true, false);
|
||||
|
||||
message_ids.clear();
|
||||
find_newer_messages(d->messages.get(), last_received_message_id, message_ids);
|
||||
}
|
||||
|
||||
// connect all messages with ID > last_received_message_id
|
||||
for (size_t i = 0; i + 1 < message_ids.size(); i++) {
|
||||
auto m = get_message(d, message_ids[i]);
|
||||
CHECK(m != nullptr);
|
||||
if (!m->have_next) {
|
||||
m->have_next = true;
|
||||
attach_message_to_next(d, message_ids[i], "on_get_history 3");
|
||||
}
|
||||
}
|
||||
|
||||
if (!message_ids.empty()) {
|
||||
have_next = true;
|
||||
}
|
||||
if (delete_newer_server_messages_at_the_end(d, last_received_message_id)) {
|
||||
have_next = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -9299,6 +9306,11 @@ void MessagesManager::on_get_history(DialogId dialog_id, MessageId from_message_
|
||||
}
|
||||
}
|
||||
|
||||
if (from_the_end && last_added_message_id.is_valid() && last_added_message_id != last_received_message_id) {
|
||||
CHECK(last_added_message_id < last_received_message_id);
|
||||
delete_newer_server_messages_at_the_end(d, last_added_message_id);
|
||||
}
|
||||
|
||||
if (have_full_history) {
|
||||
d->have_full_history = true;
|
||||
on_dialog_updated(dialog_id, "set have_full_history 2");
|
||||
@ -9413,7 +9425,6 @@ void MessagesManager::on_get_history(DialogId dialog_id, MessageId from_message_
|
||||
<< prev_have_full_history << " " << d->debug_last_new_message_id << " " << d->debug_first_database_message_id
|
||||
<< " " << d->debug_last_database_message_id << " " << from_message_id << " " << offset << " " << limit << " "
|
||||
<< messages.size() << " " << last_received_message_id << " " << d->debug_set_dialog_last_database_message_id;
|
||||
|
||||
CHECK(d->last_database_message_id.is_valid());
|
||||
|
||||
for (auto &first_message_id : d->first_database_message_id_by_index) {
|
||||
|
@ -2102,6 +2102,8 @@ class MessagesManager final : public Actor {
|
||||
|
||||
void on_update_dialog_online_member_count_timeout(DialogId dialog_id);
|
||||
|
||||
bool delete_newer_server_messages_at_the_end(Dialog *d, MessageId max_message_id);
|
||||
|
||||
template <class T, class It>
|
||||
vector<MessageId> get_message_history_slice(const T &begin, It it, const T &end, MessageId from_message_id,
|
||||
int32 offset, int32 limit);
|
||||
|
@ -1637,7 +1637,7 @@ class CliClient final : public Actor {
|
||||
string args;
|
||||
std::tie(op, args) = split(cmd);
|
||||
|
||||
const int32 OP_BLOCK_COUNT = 5;
|
||||
const int32 OP_BLOCK_COUNT = 10;
|
||||
int32 op_not_found_count = 0;
|
||||
|
||||
if (op == "gas") {
|
||||
@ -2212,6 +2212,9 @@ class CliClient final : public Actor {
|
||||
send_request(td_api::make_object<td_api::setCustomLanguagePackString>(language_code, std::move(str)));
|
||||
} else if (op == "dlp") {
|
||||
send_request(td_api::make_object<td_api::deleteLanguagePack>(args));
|
||||
} else if (op == "on" || op == "off") {
|
||||
send_request(td_api::make_object<td_api::setOption>("online",
|
||||
td_api::make_object<td_api::optionValueBoolean>(op == "on")));
|
||||
} else if (op == "go") {
|
||||
send_request(td_api::make_object<td_api::getOption>(args));
|
||||
} else if (op == "sob") {
|
||||
@ -2285,7 +2288,11 @@ class CliClient final : public Actor {
|
||||
send_get_background_url(get_freeform_gradient_background({0xFEDCBA, 0x222222}));
|
||||
send_get_background_url(get_freeform_gradient_background({0xFEDCBA, 0x111111, 0x222222}));
|
||||
send_get_background_url(get_freeform_gradient_background({0xABCDEF, 0xFEDCBA, 0x111111, 0x222222}));
|
||||
} else if (op == "sbg") {
|
||||
} else {
|
||||
op_not_found_count++;
|
||||
}
|
||||
|
||||
if (op == "sbg") {
|
||||
send_request(td_api::make_object<td_api::searchBackground>(args));
|
||||
} else if (op == "sbgd") {
|
||||
send_request(td_api::make_object<td_api::setBackground>(nullptr, nullptr, as_bool(args)));
|
||||
@ -2545,17 +2552,17 @@ class CliClient final : public Actor {
|
||||
send_request(td_api::make_object<td_api::getAnimatedEmoji>(args));
|
||||
} else if (op == "gesu") {
|
||||
send_request(td_api::make_object<td_api::getEmojiSuggestionsUrl>(args));
|
||||
} else {
|
||||
op_not_found_count++;
|
||||
}
|
||||
|
||||
if (op == "gsan") {
|
||||
} else if (op == "gsan") {
|
||||
send_request(td_api::make_object<td_api::getSavedAnimations>());
|
||||
} else if (op == "asan") {
|
||||
send_request(td_api::make_object<td_api::addSavedAnimation>(as_input_file_id(args)));
|
||||
} else if (op == "rsan") {
|
||||
send_request(td_api::make_object<td_api::removeSavedAnimation>(as_input_file_id(args)));
|
||||
} else if (op == "guf") {
|
||||
} else {
|
||||
op_not_found_count++;
|
||||
}
|
||||
|
||||
if (op == "guf") {
|
||||
send_request(td_api::make_object<td_api::getUserFullInfo>(as_user_id(args)));
|
||||
} else if (op == "gbg") {
|
||||
send_request(td_api::make_object<td_api::getBasicGroup>(as_basic_group_id(args)));
|
||||
@ -2773,7 +2780,11 @@ class CliClient final : public Actor {
|
||||
send_request(td_api::make_object<td_api::sendChatScreenshotTakenNotification>(as_chat_id(args)));
|
||||
} else if (op == "closeSC" || op == "cancelSC") {
|
||||
send_request(td_api::make_object<td_api::closeSecretChat>(as_secret_chat_id(args)));
|
||||
} else if (op == "cc" || op == "CreateCall") {
|
||||
} else {
|
||||
op_not_found_count++;
|
||||
}
|
||||
|
||||
if (op == "cc" || op == "CreateCall") {
|
||||
send_request(td_api::make_object<td_api::createCall>(
|
||||
as_user_id(args), td_api::make_object<td_api::callProtocol>(true, true, 65, 65, vector<string>{"2.6", "3.0"}),
|
||||
rand_bool()));
|
||||
@ -3425,7 +3436,11 @@ class CliClient final : public Actor {
|
||||
get_args(args, chat_id, message_id);
|
||||
send_request(td_api::make_object<td_api::getCallbackQueryAnswer>(
|
||||
as_chat_id(chat_id), as_message_id(message_id), td_api::make_object<td_api::callbackQueryPayloadGame>("")));
|
||||
} else if (op == "san") {
|
||||
} else {
|
||||
op_not_found_count++;
|
||||
}
|
||||
|
||||
if (op == "san") {
|
||||
string chat_id;
|
||||
string animation_path;
|
||||
int32 width;
|
||||
@ -3721,7 +3736,11 @@ class CliClient final : public Actor {
|
||||
send_message(chat_id,
|
||||
td_api::make_object<td_api::inputMessageVenue>(td_api::make_object<td_api::venue>(
|
||||
as_location(latitude, longitude, accuracy), title, address, provider, venue_id, venue_type)));
|
||||
} else if (op == "test") {
|
||||
} else {
|
||||
op_not_found_count++;
|
||||
}
|
||||
|
||||
if (op == "test") {
|
||||
send_request(td_api::make_object<td_api::testNetwork>());
|
||||
} else if (op == "alarm") {
|
||||
send_request(td_api::make_object<td_api::setAlarm>(to_double(args)));
|
||||
@ -4261,7 +4280,11 @@ class CliClient final : public Actor {
|
||||
bool is_dark;
|
||||
get_args(args, chat_id, is_dark);
|
||||
send_request(td_api::make_object<td_api::getChatStatistics>(as_chat_id(chat_id), is_dark));
|
||||
} else if (op == "sgs") {
|
||||
} else {
|
||||
op_not_found_count++;
|
||||
}
|
||||
|
||||
if (op == "sgs") {
|
||||
string chat_id;
|
||||
string message_id;
|
||||
string user_id;
|
||||
|
Loading…
Reference in New Issue
Block a user