|
|
|
@ -518,7 +518,7 @@ class GetChannelMessagesQuery final : public Td::ResultHandler {
|
|
|
|
|
vector<MessageId> empty_message_ids;
|
|
|
|
|
for (auto &message : info.messages) {
|
|
|
|
|
if (message->get_id() == telegram_api::messageEmpty::ID) {
|
|
|
|
|
auto message_id = MessagesManager::get_message_id(message, false);
|
|
|
|
|
auto message_id = MessageId::get_message_id(message, false);
|
|
|
|
|
if (message_id.is_valid() && message_id <= last_new_message_id_) {
|
|
|
|
|
empty_message_ids.push_back(message_id);
|
|
|
|
|
}
|
|
|
|
@ -2444,7 +2444,7 @@ class GetMessagePositionQuery final : public Td::ResultHandler {
|
|
|
|
|
case telegram_api::messages_messages::ID: {
|
|
|
|
|
auto messages = move_tl_object_as<telegram_api::messages_messages>(messages_ptr);
|
|
|
|
|
if (messages->messages_.size() != 1 ||
|
|
|
|
|
MessagesManager::get_message_id(messages->messages_[0], false) != message_id_) {
|
|
|
|
|
MessageId::get_message_id(messages->messages_[0], false) != message_id_) {
|
|
|
|
|
return promise_.set_error(Status::Error(400, "Message not found by the filter"));
|
|
|
|
|
}
|
|
|
|
|
return promise_.set_value(narrow_cast<int32>(messages->messages_.size()));
|
|
|
|
@ -2452,7 +2452,7 @@ class GetMessagePositionQuery final : public Td::ResultHandler {
|
|
|
|
|
case telegram_api::messages_messagesSlice::ID: {
|
|
|
|
|
auto messages = move_tl_object_as<telegram_api::messages_messagesSlice>(messages_ptr);
|
|
|
|
|
if (messages->messages_.size() != 1 ||
|
|
|
|
|
MessagesManager::get_message_id(messages->messages_[0], false) != message_id_) {
|
|
|
|
|
MessageId::get_message_id(messages->messages_[0], false) != message_id_) {
|
|
|
|
|
return promise_.set_error(Status::Error(400, "Message not found by the filter"));
|
|
|
|
|
}
|
|
|
|
|
if (messages->offset_id_offset_ <= 0) {
|
|
|
|
@ -2465,7 +2465,7 @@ class GetMessagePositionQuery final : public Td::ResultHandler {
|
|
|
|
|
case telegram_api::messages_channelMessages::ID: {
|
|
|
|
|
auto messages = move_tl_object_as<telegram_api::messages_channelMessages>(messages_ptr);
|
|
|
|
|
if (messages->messages_.size() != 1 ||
|
|
|
|
|
MessagesManager::get_message_id(messages->messages_[0], false) != message_id_) {
|
|
|
|
|
MessageId::get_message_id(messages->messages_[0], false) != message_id_) {
|
|
|
|
|
return promise_.set_error(Status::Error(400, "Message not found by the filter"));
|
|
|
|
|
}
|
|
|
|
|
if (messages->offset_id_offset_ <= 0) {
|
|
|
|
@ -3649,7 +3649,7 @@ class SendMultiMediaQuery final : public Td::ResultHandler {
|
|
|
|
|
is_result_wrong = true;
|
|
|
|
|
}
|
|
|
|
|
for (auto &sent_message : sent_messages) {
|
|
|
|
|
if (MessagesManager::get_message_dialog_id(sent_message.first) != dialog_id_) {
|
|
|
|
|
if (DialogId::get_message_dialog_id(sent_message.first) != dialog_id_) {
|
|
|
|
|
is_result_wrong = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -4146,7 +4146,7 @@ class ForwardMessagesQuery final : public Td::ResultHandler {
|
|
|
|
|
is_result_wrong = true;
|
|
|
|
|
}
|
|
|
|
|
for (auto &sent_message : sent_messages) {
|
|
|
|
|
if (MessagesManager::get_message_dialog_id(sent_message.first) != to_dialog_id_) {
|
|
|
|
|
if (DialogId::get_message_dialog_id(sent_message.first) != to_dialog_id_) {
|
|
|
|
|
is_result_wrong = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -6621,7 +6621,7 @@ void MessagesManager::skip_old_pending_pts_update(tl_object_ptr<telegram_api::Up
|
|
|
|
|
int32 old_pts, int32 pts_count, const char *source) {
|
|
|
|
|
if (update->get_id() == telegram_api::updateNewMessage::ID) {
|
|
|
|
|
auto update_new_message = static_cast<telegram_api::updateNewMessage *>(update.get());
|
|
|
|
|
auto full_message_id = get_full_message_id(update_new_message->message_, false);
|
|
|
|
|
auto full_message_id = FullMessageId::get_full_message_id(update_new_message->message_, false);
|
|
|
|
|
if (update_message_ids_.count(full_message_id) > 0) {
|
|
|
|
|
if (new_pts == old_pts || old_pts == std::numeric_limits<int32>::max()) {
|
|
|
|
|
// apply sent message anyway if it is definitely non-deleted or being skipped because of pts overflow
|
|
|
|
@ -7917,7 +7917,7 @@ void MessagesManager::add_pending_channel_update(DialogId dialog_id, tl_object_p
|
|
|
|
|
if (new_pts <= old_pts) { // very old or unuseful update
|
|
|
|
|
if (update->get_id() == telegram_api::updateNewChannelMessage::ID) {
|
|
|
|
|
auto update_new_channel_message = static_cast<telegram_api::updateNewChannelMessage *>(update.get());
|
|
|
|
|
auto message_id = get_message_id(update_new_channel_message->message_, false);
|
|
|
|
|
auto message_id = MessageId::get_message_id(update_new_channel_message->message_, false);
|
|
|
|
|
FullMessageId full_message_id(dialog_id, message_id);
|
|
|
|
|
if (update_message_ids_.count(full_message_id) > 0) {
|
|
|
|
|
// apply sent channel message
|
|
|
|
@ -8028,7 +8028,8 @@ void MessagesManager::process_pts_update(tl_object_ptr<telegram_api::Update> &&u
|
|
|
|
|
case telegram_api::updateEditMessage::ID: {
|
|
|
|
|
auto update = move_tl_object_as<telegram_api::updateEditMessage>(update_ptr);
|
|
|
|
|
LOG(INFO) << "Process updateEditMessage";
|
|
|
|
|
bool had_message = have_message_force(get_full_message_id(update->message_, false), "updateEditMessage");
|
|
|
|
|
bool had_message =
|
|
|
|
|
have_message_force(FullMessageId::get_full_message_id(update->message_, false), "updateEditMessage");
|
|
|
|
|
auto full_message_id =
|
|
|
|
|
on_get_message(std::move(update->message_), false, false, false, false, false, "updateEditMessage");
|
|
|
|
|
on_message_edited(full_message_id, update->pts_, had_message);
|
|
|
|
@ -8122,7 +8123,8 @@ bool MessagesManager::process_channel_update(tl_object_ptr<telegram_api::Update>
|
|
|
|
|
case telegram_api::updateEditChannelMessage::ID: {
|
|
|
|
|
auto update = move_tl_object_as<telegram_api::updateEditChannelMessage>(update_ptr);
|
|
|
|
|
LOG(INFO) << "Process updateEditChannelMessage";
|
|
|
|
|
bool had_message = have_message_force(get_full_message_id(update->message_, false), "updateEditChannelMessage");
|
|
|
|
|
bool had_message =
|
|
|
|
|
have_message_force(FullMessageId::get_full_message_id(update->message_, false), "updateEditChannelMessage");
|
|
|
|
|
auto full_message_id =
|
|
|
|
|
on_get_message(std::move(update->message_), false, true, false, false, false, "updateEditChannelMessage");
|
|
|
|
|
if (full_message_id == FullMessageId()) {
|
|
|
|
@ -9799,7 +9801,7 @@ void MessagesManager::get_channel_differences_if_needed(MessagesInfo &&messages_
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
auto dialog_id = get_message_dialog_id(message);
|
|
|
|
|
auto dialog_id = DialogId::get_message_dialog_id(message);
|
|
|
|
|
if (need_channel_difference_to_add_message(dialog_id, message)) {
|
|
|
|
|
run_after_channel_difference(dialog_id, mpas.get_promise());
|
|
|
|
|
}
|
|
|
|
@ -9868,7 +9870,7 @@ void MessagesManager::on_get_history(DialogId dialog_id, MessageId from_message_
|
|
|
|
|
Dialog *d = get_dialog(dialog_id);
|
|
|
|
|
CHECK(d != nullptr);
|
|
|
|
|
|
|
|
|
|
MessageId last_received_message_id = messages.empty() ? MessageId() : get_message_id(messages[0], false);
|
|
|
|
|
MessageId last_received_message_id = messages.empty() ? MessageId() : MessageId::get_message_id(messages[0], false);
|
|
|
|
|
if (old_last_new_message_id < d->last_new_message_id && (from_the_end || old_last_new_message_id < from_message_id) &&
|
|
|
|
|
last_received_message_id < d->last_new_message_id) {
|
|
|
|
|
// new server messages were added to the dialog since the request was sent, but weren't received
|
|
|
|
@ -9911,7 +9913,7 @@ void MessagesManager::on_get_history(DialogId dialog_id, MessageId from_message_
|
|
|
|
|
// check that messages are received in decreasing message_id order
|
|
|
|
|
MessageId cur_message_id = MessageId::max();
|
|
|
|
|
for (const auto &message : messages) {
|
|
|
|
|
MessageId message_id = get_message_id(message, false);
|
|
|
|
|
MessageId message_id = MessageId::get_message_id(message, false);
|
|
|
|
|
if (message_id >= cur_message_id) {
|
|
|
|
|
string error = PSTRING() << "Receive messages in the wrong order in history of " << dialog_id << " from "
|
|
|
|
|
<< from_message_id << " with offset " << offset << ", limit " << limit
|
|
|
|
@ -9936,7 +9938,7 @@ void MessagesManager::on_get_history(DialogId dialog_id, MessageId from_message_
|
|
|
|
|
bool have_next = false;
|
|
|
|
|
|
|
|
|
|
if (narrow_cast<int32>(messages.size()) < limit + offset && messages.size() <= 1) {
|
|
|
|
|
MessageId first_received_message_id = get_message_id(messages.back(), false);
|
|
|
|
|
MessageId first_received_message_id = MessageId::get_message_id(messages.back(), false);
|
|
|
|
|
if (first_received_message_id >= from_message_id && d->first_database_message_id.is_valid() &&
|
|
|
|
|
first_received_message_id >= d->first_database_message_id) {
|
|
|
|
|
// it is likely that there are no more history messages on the server
|
|
|
|
@ -9947,19 +9949,19 @@ void MessagesManager::on_get_history(DialogId dialog_id, MessageId from_message_
|
|
|
|
|
if (d->last_new_message_id.is_valid()) {
|
|
|
|
|
// remove too new messages from response
|
|
|
|
|
while (!messages.empty()) {
|
|
|
|
|
if (get_message_dialog_id(messages[0]) == dialog_id &&
|
|
|
|
|
get_message_id(messages[0], false) <= d->last_new_message_id) {
|
|
|
|
|
if (DialogId::get_message_dialog_id(messages[0]) == dialog_id &&
|
|
|
|
|
MessageId::get_message_id(messages[0], false) <= d->last_new_message_id) {
|
|
|
|
|
// the message is old enough
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LOG(INFO) << "Ignore too new " << get_message_id(messages[0], false);
|
|
|
|
|
LOG(INFO) << "Ignore too new " << MessageId::get_message_id(messages[0], false);
|
|
|
|
|
messages.erase(messages.begin());
|
|
|
|
|
if (messages.empty()) {
|
|
|
|
|
// received no suitable messages; try again
|
|
|
|
|
return promise.set_value(Unit());
|
|
|
|
|
} else {
|
|
|
|
|
last_received_message_id = get_message_id(messages[0], false);
|
|
|
|
|
last_received_message_id = MessageId::get_message_id(messages[0], false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -9978,13 +9980,13 @@ void MessagesManager::on_get_history(DialogId dialog_id, MessageId from_message_
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (auto &message : messages) {
|
|
|
|
|
auto expected_message_id = get_message_id(message, false);
|
|
|
|
|
auto expected_message_id = MessageId::get_message_id(message, false);
|
|
|
|
|
if (!have_next && from_the_end && expected_message_id < d->last_message_id) {
|
|
|
|
|
// last message in the dialog should be attached to the next message if there is some
|
|
|
|
|
have_next = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
auto message_dialog_id = get_message_dialog_id(message);
|
|
|
|
|
auto message_dialog_id = DialogId::get_message_dialog_id(message);
|
|
|
|
|
if (message_dialog_id != dialog_id) {
|
|
|
|
|
LOG(ERROR) << "Receive " << expected_message_id << " in wrong " << message_dialog_id << " instead of "
|
|
|
|
|
<< dialog_id << ": " << oneline(to_string(message));
|
|
|
|
@ -10493,7 +10495,7 @@ void MessagesManager::on_get_messages_search_result(const string &query, int32 o
|
|
|
|
|
auto &result = it->second.second;
|
|
|
|
|
CHECK(result.empty());
|
|
|
|
|
for (auto &message : messages) {
|
|
|
|
|
auto dialog_id = get_message_dialog_id(message);
|
|
|
|
|
auto dialog_id = DialogId::get_message_dialog_id(message);
|
|
|
|
|
auto new_full_message_id = on_get_message(std::move(message), false, dialog_id.get_type() == DialogType::Channel,
|
|
|
|
|
false, false, false, "search messages");
|
|
|
|
|
if (new_full_message_id != FullMessageId()) {
|
|
|
|
@ -10524,7 +10526,7 @@ void MessagesManager::on_get_outgoing_document_messages(vector<tl_object_ptr<tel
|
|
|
|
|
|
|
|
|
|
FoundMessages found_messages;
|
|
|
|
|
for (auto &message : messages) {
|
|
|
|
|
auto dialog_id = get_message_dialog_id(message);
|
|
|
|
|
auto dialog_id = DialogId::get_message_dialog_id(message);
|
|
|
|
|
auto full_message_id = on_get_message(std::move(message), false, dialog_id.get_type() == DialogType::Channel, false,
|
|
|
|
|
false, false, "on_get_outgoing_document_messages");
|
|
|
|
|
if (full_message_id != FullMessageId()) {
|
|
|
|
@ -10569,10 +10571,10 @@ void MessagesManager::on_get_scheduled_server_messages(DialogId dialog_id, uint3
|
|
|
|
|
bool is_channel_message = dialog_id.get_type() == DialogType::Channel;
|
|
|
|
|
bool has_scheduled_server_messages = false;
|
|
|
|
|
for (auto &message : messages) {
|
|
|
|
|
auto message_dialog_id = get_message_dialog_id(message);
|
|
|
|
|
auto message_dialog_id = DialogId::get_message_dialog_id(message);
|
|
|
|
|
if (message_dialog_id != dialog_id) {
|
|
|
|
|
LOG(ERROR) << "Receive " << get_message_id(message, true) << " in wrong " << message_dialog_id << " instead of "
|
|
|
|
|
<< dialog_id << ": " << oneline(to_string(message));
|
|
|
|
|
LOG(ERROR) << "Receive " << MessageId::get_message_id(message, true) << " in wrong " << message_dialog_id
|
|
|
|
|
<< " instead of " << dialog_id << ": " << oneline(to_string(message));
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -10644,7 +10646,7 @@ void MessagesManager::on_get_message_public_forwards(int32 total_count,
|
|
|
|
|
vector<td_api::object_ptr<td_api::message>> result;
|
|
|
|
|
FullMessageId last_full_message_id;
|
|
|
|
|
for (auto &message : messages) {
|
|
|
|
|
auto dialog_id = get_message_dialog_id(message);
|
|
|
|
|
auto dialog_id = DialogId::get_message_dialog_id(message);
|
|
|
|
|
auto new_full_message_id = on_get_message(std::move(message), false, dialog_id.get_type() == DialogType::Channel,
|
|
|
|
|
false, false, false, "get message public forwards");
|
|
|
|
|
if (new_full_message_id != FullMessageId()) {
|
|
|
|
@ -13132,63 +13134,6 @@ void MessagesManager::on_update_viewed_messages_timeout(DialogId dialog_id) {
|
|
|
|
|
update_viewed_messages_timeout_.add_timeout_in(dialog_id.get(), UPDATE_VIEWED_MESSAGES_PERIOD);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MessageId MessagesManager::get_message_id(const telegram_api::Message *message_ptr, bool is_scheduled) {
|
|
|
|
|
CHECK(message_ptr != nullptr)
|
|
|
|
|
switch (message_ptr->get_id()) {
|
|
|
|
|
case telegram_api::messageEmpty::ID: {
|
|
|
|
|
auto message = static_cast<const telegram_api::messageEmpty *>(message_ptr);
|
|
|
|
|
return is_scheduled ? MessageId() : MessageId(ServerMessageId(message->id_));
|
|
|
|
|
}
|
|
|
|
|
case telegram_api::message::ID: {
|
|
|
|
|
auto message = static_cast<const telegram_api::message *>(message_ptr);
|
|
|
|
|
return is_scheduled ? MessageId(ScheduledServerMessageId(message->id_), message->date_)
|
|
|
|
|
: MessageId(ServerMessageId(message->id_));
|
|
|
|
|
}
|
|
|
|
|
case telegram_api::messageService::ID: {
|
|
|
|
|
auto message = static_cast<const telegram_api::messageService *>(message_ptr);
|
|
|
|
|
return is_scheduled ? MessageId(ScheduledServerMessageId(message->id_), message->date_)
|
|
|
|
|
: MessageId(ServerMessageId(message->id_));
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
UNREACHABLE();
|
|
|
|
|
return MessageId();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MessageId MessagesManager::get_message_id(const tl_object_ptr<telegram_api::Message> &message_ptr, bool is_scheduled) {
|
|
|
|
|
return get_message_id(message_ptr.get(), is_scheduled);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DialogId MessagesManager::get_message_dialog_id(const telegram_api::Message *message_ptr) {
|
|
|
|
|
CHECK(message_ptr != nullptr);
|
|
|
|
|
switch (message_ptr->get_id()) {
|
|
|
|
|
case telegram_api::messageEmpty::ID: {
|
|
|
|
|
auto message = static_cast<const telegram_api::messageEmpty *>(message_ptr);
|
|
|
|
|
return message->peer_id_ == nullptr ? DialogId() : DialogId(message->peer_id_);
|
|
|
|
|
}
|
|
|
|
|
case telegram_api::message::ID: {
|
|
|
|
|
auto message = static_cast<const telegram_api::message *>(message_ptr);
|
|
|
|
|
return DialogId(message->peer_id_);
|
|
|
|
|
}
|
|
|
|
|
case telegram_api::messageService::ID: {
|
|
|
|
|
auto message = static_cast<const telegram_api::messageService *>(message_ptr);
|
|
|
|
|
return DialogId(message->peer_id_);
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
UNREACHABLE();
|
|
|
|
|
return DialogId();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DialogId MessagesManager::get_message_dialog_id(const tl_object_ptr<telegram_api::Message> &message_ptr) {
|
|
|
|
|
return get_message_dialog_id(message_ptr.get());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FullMessageId MessagesManager::get_full_message_id(const tl_object_ptr<telegram_api::Message> &message_ptr,
|
|
|
|
|
bool is_scheduled) {
|
|
|
|
|
return {get_message_dialog_id(message_ptr), get_message_id(message_ptr, is_scheduled)};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int32 MessagesManager::get_message_date(const tl_object_ptr<telegram_api::Message> &message_ptr) {
|
|
|
|
|
switch (message_ptr->get_id()) {
|
|
|
|
|
case telegram_api::messageEmpty::ID:
|
|
|
|
@ -14544,7 +14489,7 @@ MessagesManager::MessageInfo MessagesManager::parse_telegram_api_message(
|
|
|
|
|
LOG_CHECK(message_ptr != nullptr) << source;
|
|
|
|
|
|
|
|
|
|
MessageInfo message_info;
|
|
|
|
|
message_info.message_id = get_message_id(message_ptr, is_scheduled);
|
|
|
|
|
message_info.message_id = MessageId::get_message_id(message_ptr, is_scheduled);
|
|
|
|
|
switch (message_ptr->get_id()) {
|
|
|
|
|
case telegram_api::messageEmpty::ID:
|
|
|
|
|
message_info.message_id = MessageId();
|
|
|
|
@ -15795,7 +15740,7 @@ void MessagesManager::on_get_dialogs(FolderId folder_id, vector<tl_object_ptr<te
|
|
|
|
|
FlatHashMap<FullMessageId, DialogDate, FullMessageIdHash> full_message_id_to_dialog_date;
|
|
|
|
|
FlatHashMap<FullMessageId, tl_object_ptr<telegram_api::Message>, FullMessageIdHash> full_message_id_to_message;
|
|
|
|
|
for (auto &message : messages) {
|
|
|
|
|
auto full_message_id = get_full_message_id(message, false);
|
|
|
|
|
auto full_message_id = FullMessageId::get_full_message_id(message, false);
|
|
|
|
|
if (!full_message_id.get_message_id().is_valid()) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
@ -18594,7 +18539,7 @@ void MessagesManager::process_discussion_message(
|
|
|
|
|
td_->contacts_manager_->on_get_chats(std::move(result->chats_), "process_discussion_message");
|
|
|
|
|
|
|
|
|
|
for (auto &message : result->messages_) {
|
|
|
|
|
auto message_dialog_id = get_message_dialog_id(message);
|
|
|
|
|
auto message_dialog_id = DialogId::get_message_dialog_id(message);
|
|
|
|
|
if (message_dialog_id != expected_dialog_id) {
|
|
|
|
|
return promise.set_error(Status::Error(500, "Expected messages in a different chat"));
|
|
|
|
|
}
|
|
|
|
@ -24038,7 +23983,7 @@ void MessagesManager::on_get_dialog_message_by_date_success(DialogId dialog_id,
|
|
|
|
|
|
|
|
|
|
for (auto &message : messages) {
|
|
|
|
|
auto message_date = get_message_date(message);
|
|
|
|
|
auto message_dialog_id = get_message_dialog_id(message);
|
|
|
|
|
auto message_dialog_id = DialogId::get_message_dialog_id(message);
|
|
|
|
|
if (message_dialog_id != dialog_id) {
|
|
|
|
|
LOG(ERROR) << "Receive message in wrong " << message_dialog_id << " instead of " << dialog_id;
|
|
|
|
|
continue;
|
|
|
|
@ -31894,7 +31839,8 @@ void MessagesManager::check_send_message_result(int64 random_id, DialogId dialog
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (sent_messages.size() != 1u || sent_messages_random_ids.size() != 1u ||
|
|
|
|
|
*sent_messages_random_ids.begin() != random_id || get_message_dialog_id(sent_messages[0].first) != dialog_id ||
|
|
|
|
|
*sent_messages_random_ids.begin() != random_id ||
|
|
|
|
|
DialogId::get_message_dialog_id(sent_messages[0].first) != dialog_id ||
|
|
|
|
|
is_invalid_poll_message(sent_messages[0].first)) {
|
|
|
|
|
LOG(ERROR) << "Receive wrong result for sending message with random_id " << random_id << " from " << source
|
|
|
|
|
<< " to " << dialog_id << ": " << oneline(to_string(*updates_ptr));
|
|
|
|
@ -33330,7 +33276,7 @@ void MessagesManager::on_create_new_dialog_success(int64 random_id, tl_object_pt
|
|
|
|
|
return on_create_new_dialog_fail(random_id, Status::Error(500, "Scheduled message received"), std::move(promise));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
auto dialog_id = get_message_dialog_id(message);
|
|
|
|
|
auto dialog_id = DialogId::get_message_dialog_id(message);
|
|
|
|
|
if (dialog_id.get_type() != expected_type) {
|
|
|
|
|
return on_create_new_dialog_fail(random_id, Status::Error(500, "Chat of wrong type has been created"),
|
|
|
|
|
std::move(promise));
|
|
|
|
@ -38954,7 +38900,7 @@ bool MessagesManager::need_channel_difference_to_add_message(DialogId dialog_id,
|
|
|
|
|
if (message_ptr == nullptr) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
if (get_message_dialog_id(message_ptr) != dialog_id) {
|
|
|
|
|
if (DialogId::get_message_dialog_id(message_ptr) != dialog_id) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -38966,7 +38912,7 @@ bool MessagesManager::need_channel_difference_to_add_message(DialogId dialog_id,
|
|
|
|
|
return d->pts > 0 && !d->is_channel_difference_finished;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return get_message_id(message_ptr, false) > d->last_new_message_id;
|
|
|
|
|
return MessageId::get_message_id(message_ptr, false) > d->last_new_message_id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MessagesManager::run_after_channel_difference(DialogId dialog_id, Promise<Unit> &&promise) {
|
|
|
|
@ -39136,7 +39082,7 @@ void MessagesManager::process_get_channel_difference_updates(
|
|
|
|
|
}
|
|
|
|
|
case telegram_api::updateEditChannelMessage::ID: {
|
|
|
|
|
auto *update = static_cast<const telegram_api::updateEditChannelMessage *>(update_ptr.get());
|
|
|
|
|
auto full_message_id = get_full_message_id(update->message_, false);
|
|
|
|
|
auto full_message_id = FullMessageId::get_full_message_id(update->message_, false);
|
|
|
|
|
if (full_message_id.get_dialog_id() != dialog_id) {
|
|
|
|
|
is_good_update = false;
|
|
|
|
|
} else {
|
|
|
|
@ -39170,7 +39116,7 @@ void MessagesManager::process_get_channel_difference_updates(
|
|
|
|
|
|
|
|
|
|
for (auto &message : new_messages) {
|
|
|
|
|
if (is_edited_message(message)) {
|
|
|
|
|
auto message_id = get_message_id(message, false);
|
|
|
|
|
auto message_id = MessageId::get_message_id(message, false);
|
|
|
|
|
if (message_id.is_valid()) {
|
|
|
|
|
changed_message_ids.insert(message_id);
|
|
|
|
|
}
|
|
|
|
@ -39199,7 +39145,7 @@ void MessagesManager::process_get_channel_difference_updates(
|
|
|
|
|
|
|
|
|
|
if (update->get_id() == telegram_api::updateNewChannelMessage::ID) {
|
|
|
|
|
auto update_new_channel_message = static_cast<telegram_api::updateNewChannelMessage *>(update.get());
|
|
|
|
|
auto message_id = get_message_id(update_new_channel_message->message_, false);
|
|
|
|
|
auto message_id = MessageId::get_message_id(update_new_channel_message->message_, false);
|
|
|
|
|
FullMessageId full_message_id(dialog_id, message_id);
|
|
|
|
|
if (update_message_ids_.count(full_message_id) > 0 && changed_message_ids.count(message_id) > 0) {
|
|
|
|
|
changed_message_ids.erase(message_id);
|
|
|
|
@ -39225,7 +39171,7 @@ void MessagesManager::process_get_channel_difference_updates(
|
|
|
|
|
|
|
|
|
|
auto it = awaited_messages.begin();
|
|
|
|
|
for (auto &message : new_messages) {
|
|
|
|
|
auto message_id = get_message_id(message, false);
|
|
|
|
|
auto message_id = MessageId::get_message_id(message, false);
|
|
|
|
|
while (it != awaited_messages.end() && it->first < message_id) {
|
|
|
|
|
on_get_message(std::move(it->second.message), true, true, false, true, true, "postponed channel update");
|
|
|
|
|
it->second.promise.set_value(Unit());
|
|
|
|
@ -39274,11 +39220,11 @@ void MessagesManager::on_get_channel_dialog(DialogId dialog_id, MessageId last_m
|
|
|
|
|
vector<tl_object_ptr<telegram_api::Message>> &&messages) {
|
|
|
|
|
FlatHashMap<FullMessageId, tl_object_ptr<telegram_api::Message>, FullMessageIdHash> full_message_id_to_message;
|
|
|
|
|
for (auto &message : messages) {
|
|
|
|
|
auto message_id = get_message_id(message, false);
|
|
|
|
|
auto message_id = MessageId::get_message_id(message, false);
|
|
|
|
|
if (!message_id.is_valid()) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
auto message_dialog_id = get_message_dialog_id(message);
|
|
|
|
|
auto message_dialog_id = DialogId::get_message_dialog_id(message);
|
|
|
|
|
if (!message_dialog_id.is_valid()) {
|
|
|
|
|
message_dialog_id = dialog_id;
|
|
|
|
|
}
|
|
|
|
@ -39508,7 +39454,7 @@ void MessagesManager::on_get_channel_difference(
|
|
|
|
|
// check that new messages are received in increasing message_id order
|
|
|
|
|
MessageId cur_message_id;
|
|
|
|
|
for (const auto &message : difference->new_messages_) {
|
|
|
|
|
auto message_id = get_message_id(message, false);
|
|
|
|
|
auto message_id = MessageId::get_message_id(message, false);
|
|
|
|
|
if (message_id <= cur_message_id) {
|
|
|
|
|
LOG(ERROR) << "Receive " << cur_message_id << " after " << message_id << " in channelDifference of "
|
|
|
|
|
<< dialog_id << " with pts " << request_pts << " and limit " << request_limit << ": "
|
|
|
|
|