Move static get_message_id/get_message_dialog_id to corresponding classes.
This commit is contained in:
parent
d2060a2eb3
commit
0e33195953
@ -151,4 +151,29 @@ int64 DialogId::get_peer_id(const tl_object_ptr<telegram_api::Peer> &peer) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DialogId DialogId::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 DialogId::get_message_dialog_id(const tl_object_ptr<telegram_api::Message> &message_ptr) {
|
||||||
|
return get_message_dialog_id(message_ptr.get());
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace td
|
} // namespace td
|
||||||
|
@ -66,6 +66,10 @@ class DialogId {
|
|||||||
ChannelId get_channel_id() const;
|
ChannelId get_channel_id() const;
|
||||||
SecretChatId get_secret_chat_id() const;
|
SecretChatId get_secret_chat_id() const;
|
||||||
|
|
||||||
|
static DialogId get_message_dialog_id(const telegram_api::Message *message_ptr);
|
||||||
|
|
||||||
|
static DialogId get_message_dialog_id(const tl_object_ptr<telegram_api::Message> &message_ptr);
|
||||||
|
|
||||||
template <class StorerT>
|
template <class StorerT>
|
||||||
void store(StorerT &storer) const {
|
void store(StorerT &storer) const {
|
||||||
storer.store_long(id);
|
storer.store_long(id);
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include "td/telegram/DialogId.h"
|
#include "td/telegram/DialogId.h"
|
||||||
#include "td/telegram/MessageId.h"
|
#include "td/telegram/MessageId.h"
|
||||||
|
#include "td/telegram/telegram_api.h"
|
||||||
|
|
||||||
#include "td/utils/common.h"
|
#include "td/utils/common.h"
|
||||||
#include "td/utils/StringBuilder.h"
|
#include "td/utils/StringBuilder.h"
|
||||||
@ -37,10 +38,15 @@ struct FullMessageId {
|
|||||||
DialogId get_dialog_id() const {
|
DialogId get_dialog_id() const {
|
||||||
return dialog_id;
|
return dialog_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageId get_message_id() const {
|
MessageId get_message_id() const {
|
||||||
return message_id;
|
return message_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static FullMessageId get_full_message_id(const tl_object_ptr<telegram_api::Message> &message_ptr, bool is_scheduled) {
|
||||||
|
return {DialogId::get_message_dialog_id(message_ptr), MessageId::get_message_id(message_ptr, is_scheduled)};
|
||||||
|
}
|
||||||
|
|
||||||
template <class StorerT>
|
template <class StorerT>
|
||||||
void store(StorerT &storer) const {
|
void store(StorerT &storer) const {
|
||||||
dialog_id.store(storer);
|
dialog_id.store(storer);
|
||||||
|
@ -25,6 +25,33 @@ MessageId::MessageId(ScheduledServerMessageId server_message_id, int32 send_date
|
|||||||
SCHEDULED_MASK;
|
SCHEDULED_MASK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MessageId MessageId::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 MessageId::get_message_id(const tl_object_ptr<telegram_api::Message> &message_ptr, bool is_scheduled) {
|
||||||
|
return get_message_id(message_ptr.get(), is_scheduled);
|
||||||
|
}
|
||||||
|
|
||||||
vector<MessageId> MessageId::get_message_ids(const vector<int64> &input_message_ids) {
|
vector<MessageId> MessageId::get_message_ids(const vector<int64> &input_message_ids) {
|
||||||
return transform(input_message_ids, [](int64 input_message_id) { return MessageId(input_message_id); });
|
return transform(input_message_ids, [](int64 input_message_id) { return MessageId(input_message_id); });
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include "td/telegram/ScheduledServerMessageId.h"
|
#include "td/telegram/ScheduledServerMessageId.h"
|
||||||
#include "td/telegram/ServerMessageId.h"
|
#include "td/telegram/ServerMessageId.h"
|
||||||
|
#include "td/telegram/telegram_api.h"
|
||||||
|
|
||||||
#include "td/utils/common.h"
|
#include "td/utils/common.h"
|
||||||
#include "td/utils/HashTableUtils.h"
|
#include "td/utils/HashTableUtils.h"
|
||||||
@ -73,6 +74,10 @@ class MessageId {
|
|||||||
return MessageId(static_cast<int64>(std::numeric_limits<int32>::max()) << SERVER_ID_SHIFT);
|
return MessageId(static_cast<int64>(std::numeric_limits<int32>::max()) << SERVER_ID_SHIFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static MessageId get_message_id(const telegram_api::Message *message_ptr, bool is_scheduled);
|
||||||
|
|
||||||
|
static MessageId get_message_id(const tl_object_ptr<telegram_api::Message> &message_ptr, bool is_scheduled);
|
||||||
|
|
||||||
static vector<MessageId> get_message_ids(const vector<int64> &input_message_ids);
|
static vector<MessageId> get_message_ids(const vector<int64> &input_message_ids);
|
||||||
|
|
||||||
static vector<int32> get_server_message_ids(const vector<MessageId> &message_ids);
|
static vector<int32> get_server_message_ids(const vector<MessageId> &message_ids);
|
||||||
|
@ -518,7 +518,7 @@ class GetChannelMessagesQuery final : public Td::ResultHandler {
|
|||||||
vector<MessageId> empty_message_ids;
|
vector<MessageId> empty_message_ids;
|
||||||
for (auto &message : info.messages) {
|
for (auto &message : info.messages) {
|
||||||
if (message->get_id() == telegram_api::messageEmpty::ID) {
|
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_) {
|
if (message_id.is_valid() && message_id <= last_new_message_id_) {
|
||||||
empty_message_ids.push_back(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: {
|
case telegram_api::messages_messages::ID: {
|
||||||
auto messages = move_tl_object_as<telegram_api::messages_messages>(messages_ptr);
|
auto messages = move_tl_object_as<telegram_api::messages_messages>(messages_ptr);
|
||||||
if (messages->messages_.size() != 1 ||
|
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_error(Status::Error(400, "Message not found by the filter"));
|
||||||
}
|
}
|
||||||
return promise_.set_value(narrow_cast<int32>(messages->messages_.size()));
|
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: {
|
case telegram_api::messages_messagesSlice::ID: {
|
||||||
auto messages = move_tl_object_as<telegram_api::messages_messagesSlice>(messages_ptr);
|
auto messages = move_tl_object_as<telegram_api::messages_messagesSlice>(messages_ptr);
|
||||||
if (messages->messages_.size() != 1 ||
|
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_error(Status::Error(400, "Message not found by the filter"));
|
||||||
}
|
}
|
||||||
if (messages->offset_id_offset_ <= 0) {
|
if (messages->offset_id_offset_ <= 0) {
|
||||||
@ -2465,7 +2465,7 @@ class GetMessagePositionQuery final : public Td::ResultHandler {
|
|||||||
case telegram_api::messages_channelMessages::ID: {
|
case telegram_api::messages_channelMessages::ID: {
|
||||||
auto messages = move_tl_object_as<telegram_api::messages_channelMessages>(messages_ptr);
|
auto messages = move_tl_object_as<telegram_api::messages_channelMessages>(messages_ptr);
|
||||||
if (messages->messages_.size() != 1 ||
|
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_error(Status::Error(400, "Message not found by the filter"));
|
||||||
}
|
}
|
||||||
if (messages->offset_id_offset_ <= 0) {
|
if (messages->offset_id_offset_ <= 0) {
|
||||||
@ -3649,7 +3649,7 @@ class SendMultiMediaQuery final : public Td::ResultHandler {
|
|||||||
is_result_wrong = true;
|
is_result_wrong = true;
|
||||||
}
|
}
|
||||||
for (auto &sent_message : sent_messages) {
|
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;
|
is_result_wrong = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4146,7 +4146,7 @@ class ForwardMessagesQuery final : public Td::ResultHandler {
|
|||||||
is_result_wrong = true;
|
is_result_wrong = true;
|
||||||
}
|
}
|
||||||
for (auto &sent_message : sent_messages) {
|
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;
|
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) {
|
int32 old_pts, int32 pts_count, const char *source) {
|
||||||
if (update->get_id() == telegram_api::updateNewMessage::ID) {
|
if (update->get_id() == telegram_api::updateNewMessage::ID) {
|
||||||
auto update_new_message = static_cast<telegram_api::updateNewMessage *>(update.get());
|
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 (update_message_ids_.count(full_message_id) > 0) {
|
||||||
if (new_pts == old_pts || old_pts == std::numeric_limits<int32>::max()) {
|
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
|
// 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 (new_pts <= old_pts) { // very old or unuseful update
|
||||||
if (update->get_id() == telegram_api::updateNewChannelMessage::ID) {
|
if (update->get_id() == telegram_api::updateNewChannelMessage::ID) {
|
||||||
auto update_new_channel_message = static_cast<telegram_api::updateNewChannelMessage *>(update.get());
|
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);
|
FullMessageId full_message_id(dialog_id, message_id);
|
||||||
if (update_message_ids_.count(full_message_id) > 0) {
|
if (update_message_ids_.count(full_message_id) > 0) {
|
||||||
// apply sent channel message
|
// 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: {
|
case telegram_api::updateEditMessage::ID: {
|
||||||
auto update = move_tl_object_as<telegram_api::updateEditMessage>(update_ptr);
|
auto update = move_tl_object_as<telegram_api::updateEditMessage>(update_ptr);
|
||||||
LOG(INFO) << "Process updateEditMessage";
|
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 =
|
auto full_message_id =
|
||||||
on_get_message(std::move(update->message_), false, false, false, false, false, "updateEditMessage");
|
on_get_message(std::move(update->message_), false, false, false, false, false, "updateEditMessage");
|
||||||
on_message_edited(full_message_id, update->pts_, had_message);
|
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: {
|
case telegram_api::updateEditChannelMessage::ID: {
|
||||||
auto update = move_tl_object_as<telegram_api::updateEditChannelMessage>(update_ptr);
|
auto update = move_tl_object_as<telegram_api::updateEditChannelMessage>(update_ptr);
|
||||||
LOG(INFO) << "Process updateEditChannelMessage";
|
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 =
|
auto full_message_id =
|
||||||
on_get_message(std::move(update->message_), false, true, false, false, false, "updateEditChannelMessage");
|
on_get_message(std::move(update->message_), false, true, false, false, false, "updateEditChannelMessage");
|
||||||
if (full_message_id == FullMessageId()) {
|
if (full_message_id == FullMessageId()) {
|
||||||
@ -9799,7 +9801,7 @@ void MessagesManager::get_channel_differences_if_needed(MessagesInfo &&messages_
|
|||||||
continue;
|
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)) {
|
if (need_channel_difference_to_add_message(dialog_id, message)) {
|
||||||
run_after_channel_difference(dialog_id, mpas.get_promise());
|
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);
|
Dialog *d = get_dialog(dialog_id);
|
||||||
CHECK(d != nullptr);
|
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) &&
|
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) {
|
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
|
// 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
|
// check that messages are received in decreasing message_id order
|
||||||
MessageId cur_message_id = MessageId::max();
|
MessageId cur_message_id = MessageId::max();
|
||||||
for (const auto &message : messages) {
|
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) {
|
if (message_id >= cur_message_id) {
|
||||||
string error = PSTRING() << "Receive messages in the wrong order in history of " << dialog_id << " from "
|
string error = PSTRING() << "Receive messages in the wrong order in history of " << dialog_id << " from "
|
||||||
<< from_message_id << " with offset " << offset << ", limit " << limit
|
<< 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;
|
bool have_next = false;
|
||||||
|
|
||||||
if (narrow_cast<int32>(messages.size()) < limit + offset && messages.size() <= 1) {
|
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() &&
|
if (first_received_message_id >= from_message_id && d->first_database_message_id.is_valid() &&
|
||||||
first_received_message_id >= d->first_database_message_id) {
|
first_received_message_id >= d->first_database_message_id) {
|
||||||
// it is likely that there are no more history messages on the server
|
// 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()) {
|
if (d->last_new_message_id.is_valid()) {
|
||||||
// remove too new messages from response
|
// remove too new messages from response
|
||||||
while (!messages.empty()) {
|
while (!messages.empty()) {
|
||||||
if (get_message_dialog_id(messages[0]) == dialog_id &&
|
if (DialogId::get_message_dialog_id(messages[0]) == dialog_id &&
|
||||||
get_message_id(messages[0], false) <= d->last_new_message_id) {
|
MessageId::get_message_id(messages[0], false) <= d->last_new_message_id) {
|
||||||
// the message is old enough
|
// the message is old enough
|
||||||
break;
|
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());
|
messages.erase(messages.begin());
|
||||||
if (messages.empty()) {
|
if (messages.empty()) {
|
||||||
// received no suitable messages; try again
|
// received no suitable messages; try again
|
||||||
return promise.set_value(Unit());
|
return promise.set_value(Unit());
|
||||||
} else {
|
} 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) {
|
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) {
|
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
|
// last message in the dialog should be attached to the next message if there is some
|
||||||
have_next = true;
|
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) {
|
if (message_dialog_id != dialog_id) {
|
||||||
LOG(ERROR) << "Receive " << expected_message_id << " in wrong " << message_dialog_id << " instead of "
|
LOG(ERROR) << "Receive " << expected_message_id << " in wrong " << message_dialog_id << " instead of "
|
||||||
<< dialog_id << ": " << oneline(to_string(message));
|
<< 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;
|
auto &result = it->second.second;
|
||||||
CHECK(result.empty());
|
CHECK(result.empty());
|
||||||
for (auto &message : messages) {
|
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,
|
auto new_full_message_id = on_get_message(std::move(message), false, dialog_id.get_type() == DialogType::Channel,
|
||||||
false, false, false, "search messages");
|
false, false, false, "search messages");
|
||||||
if (new_full_message_id != FullMessageId()) {
|
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;
|
FoundMessages found_messages;
|
||||||
for (auto &message : 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,
|
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");
|
false, false, "on_get_outgoing_document_messages");
|
||||||
if (full_message_id != FullMessageId()) {
|
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 is_channel_message = dialog_id.get_type() == DialogType::Channel;
|
||||||
bool has_scheduled_server_messages = false;
|
bool has_scheduled_server_messages = false;
|
||||||
for (auto &message : messages) {
|
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) {
|
if (message_dialog_id != dialog_id) {
|
||||||
LOG(ERROR) << "Receive " << get_message_id(message, true) << " in wrong " << message_dialog_id << " instead of "
|
LOG(ERROR) << "Receive " << MessageId::get_message_id(message, true) << " in wrong " << message_dialog_id
|
||||||
<< dialog_id << ": " << oneline(to_string(message));
|
<< " instead of " << dialog_id << ": " << oneline(to_string(message));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -10644,7 +10646,7 @@ void MessagesManager::on_get_message_public_forwards(int32 total_count,
|
|||||||
vector<td_api::object_ptr<td_api::message>> result;
|
vector<td_api::object_ptr<td_api::message>> result;
|
||||||
FullMessageId last_full_message_id;
|
FullMessageId last_full_message_id;
|
||||||
for (auto &message : messages) {
|
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,
|
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");
|
false, false, false, "get message public forwards");
|
||||||
if (new_full_message_id != FullMessageId()) {
|
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);
|
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) {
|
int32 MessagesManager::get_message_date(const tl_object_ptr<telegram_api::Message> &message_ptr) {
|
||||||
switch (message_ptr->get_id()) {
|
switch (message_ptr->get_id()) {
|
||||||
case telegram_api::messageEmpty::ID:
|
case telegram_api::messageEmpty::ID:
|
||||||
@ -14544,7 +14489,7 @@ MessagesManager::MessageInfo MessagesManager::parse_telegram_api_message(
|
|||||||
LOG_CHECK(message_ptr != nullptr) << source;
|
LOG_CHECK(message_ptr != nullptr) << source;
|
||||||
|
|
||||||
MessageInfo message_info;
|
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()) {
|
switch (message_ptr->get_id()) {
|
||||||
case telegram_api::messageEmpty::ID:
|
case telegram_api::messageEmpty::ID:
|
||||||
message_info.message_id = MessageId();
|
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, DialogDate, FullMessageIdHash> full_message_id_to_dialog_date;
|
||||||
FlatHashMap<FullMessageId, tl_object_ptr<telegram_api::Message>, FullMessageIdHash> full_message_id_to_message;
|
FlatHashMap<FullMessageId, tl_object_ptr<telegram_api::Message>, FullMessageIdHash> full_message_id_to_message;
|
||||||
for (auto &message : messages) {
|
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()) {
|
if (!full_message_id.get_message_id().is_valid()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -18594,7 +18539,7 @@ void MessagesManager::process_discussion_message(
|
|||||||
td_->contacts_manager_->on_get_chats(std::move(result->chats_), "process_discussion_message");
|
td_->contacts_manager_->on_get_chats(std::move(result->chats_), "process_discussion_message");
|
||||||
|
|
||||||
for (auto &message : result->messages_) {
|
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) {
|
if (message_dialog_id != expected_dialog_id) {
|
||||||
return promise.set_error(Status::Error(500, "Expected messages in a different chat"));
|
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) {
|
for (auto &message : messages) {
|
||||||
auto message_date = get_message_date(message);
|
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) {
|
if (message_dialog_id != dialog_id) {
|
||||||
LOG(ERROR) << "Receive message in wrong " << message_dialog_id << " instead of " << dialog_id;
|
LOG(ERROR) << "Receive message in wrong " << message_dialog_id << " instead of " << dialog_id;
|
||||||
continue;
|
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 ||
|
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)) {
|
is_invalid_poll_message(sent_messages[0].first)) {
|
||||||
LOG(ERROR) << "Receive wrong result for sending message with random_id " << random_id << " from " << source
|
LOG(ERROR) << "Receive wrong result for sending message with random_id " << random_id << " from " << source
|
||||||
<< " to " << dialog_id << ": " << oneline(to_string(*updates_ptr));
|
<< " 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));
|
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) {
|
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"),
|
return on_create_new_dialog_fail(random_id, Status::Error(500, "Chat of wrong type has been created"),
|
||||||
std::move(promise));
|
std::move(promise));
|
||||||
@ -38954,7 +38900,7 @@ bool MessagesManager::need_channel_difference_to_add_message(DialogId dialog_id,
|
|||||||
if (message_ptr == nullptr) {
|
if (message_ptr == nullptr) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (get_message_dialog_id(message_ptr) != dialog_id) {
|
if (DialogId::get_message_dialog_id(message_ptr) != dialog_id) {
|
||||||
return false;
|
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 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) {
|
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: {
|
case telegram_api::updateEditChannelMessage::ID: {
|
||||||
auto *update = static_cast<const telegram_api::updateEditChannelMessage *>(update_ptr.get());
|
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) {
|
if (full_message_id.get_dialog_id() != dialog_id) {
|
||||||
is_good_update = false;
|
is_good_update = false;
|
||||||
} else {
|
} else {
|
||||||
@ -39170,7 +39116,7 @@ void MessagesManager::process_get_channel_difference_updates(
|
|||||||
|
|
||||||
for (auto &message : new_messages) {
|
for (auto &message : new_messages) {
|
||||||
if (is_edited_message(message)) {
|
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()) {
|
if (message_id.is_valid()) {
|
||||||
changed_message_ids.insert(message_id);
|
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) {
|
if (update->get_id() == telegram_api::updateNewChannelMessage::ID) {
|
||||||
auto update_new_channel_message = static_cast<telegram_api::updateNewChannelMessage *>(update.get());
|
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);
|
FullMessageId full_message_id(dialog_id, message_id);
|
||||||
if (update_message_ids_.count(full_message_id) > 0 && changed_message_ids.count(message_id) > 0) {
|
if (update_message_ids_.count(full_message_id) > 0 && changed_message_ids.count(message_id) > 0) {
|
||||||
changed_message_ids.erase(message_id);
|
changed_message_ids.erase(message_id);
|
||||||
@ -39225,7 +39171,7 @@ void MessagesManager::process_get_channel_difference_updates(
|
|||||||
|
|
||||||
auto it = awaited_messages.begin();
|
auto it = awaited_messages.begin();
|
||||||
for (auto &message : new_messages) {
|
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) {
|
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");
|
on_get_message(std::move(it->second.message), true, true, false, true, true, "postponed channel update");
|
||||||
it->second.promise.set_value(Unit());
|
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) {
|
vector<tl_object_ptr<telegram_api::Message>> &&messages) {
|
||||||
FlatHashMap<FullMessageId, tl_object_ptr<telegram_api::Message>, FullMessageIdHash> full_message_id_to_message;
|
FlatHashMap<FullMessageId, tl_object_ptr<telegram_api::Message>, FullMessageIdHash> full_message_id_to_message;
|
||||||
for (auto &message : messages) {
|
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()) {
|
if (!message_id.is_valid()) {
|
||||||
continue;
|
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()) {
|
if (!message_dialog_id.is_valid()) {
|
||||||
message_dialog_id = dialog_id;
|
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
|
// check that new messages are received in increasing message_id order
|
||||||
MessageId cur_message_id;
|
MessageId cur_message_id;
|
||||||
for (const auto &message : difference->new_messages_) {
|
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) {
|
if (message_id <= cur_message_id) {
|
||||||
LOG(ERROR) << "Receive " << cur_message_id << " after " << message_id << " in channelDifference of "
|
LOG(ERROR) << "Receive " << cur_message_id << " after " << message_id << " in channelDifference of "
|
||||||
<< dialog_id << " with pts " << request_pts << " and limit " << request_limit << ": "
|
<< dialog_id << " with pts " << request_pts << " and limit " << request_limit << ": "
|
||||||
|
@ -160,16 +160,6 @@ class MessagesManager final : public Actor {
|
|||||||
MessagesManager &operator=(MessagesManager &&) = delete;
|
MessagesManager &operator=(MessagesManager &&) = delete;
|
||||||
~MessagesManager() final;
|
~MessagesManager() final;
|
||||||
|
|
||||||
static MessageId get_message_id(const telegram_api::Message *message_ptr, bool is_scheduled);
|
|
||||||
|
|
||||||
static MessageId get_message_id(const tl_object_ptr<telegram_api::Message> &message_ptr, bool is_scheduled);
|
|
||||||
|
|
||||||
static DialogId get_message_dialog_id(const telegram_api::Message *message_ptr);
|
|
||||||
|
|
||||||
static DialogId get_message_dialog_id(const tl_object_ptr<telegram_api::Message> &message_ptr);
|
|
||||||
|
|
||||||
static FullMessageId get_full_message_id(const tl_object_ptr<telegram_api::Message> &message_ptr, bool is_scheduled);
|
|
||||||
|
|
||||||
tl_object_ptr<telegram_api::InputPeer> get_input_peer(DialogId dialog_id, AccessRights access_rights) const;
|
tl_object_ptr<telegram_api::InputPeer> get_input_peer(DialogId dialog_id, AccessRights access_rights) const;
|
||||||
|
|
||||||
static tl_object_ptr<telegram_api::InputPeer> get_input_peer_force(DialogId dialog_id);
|
static tl_object_ptr<telegram_api::InputPeer> get_input_peer_force(DialogId dialog_id);
|
||||||
|
@ -1155,7 +1155,7 @@ FlatHashSet<int64> UpdatesManager::get_sent_messages_random_ids(const telegram_a
|
|||||||
if (random_id != 0) {
|
if (random_id != 0) {
|
||||||
bool found_message = false;
|
bool found_message = false;
|
||||||
for (auto message : new_messages) {
|
for (auto message : new_messages) {
|
||||||
MessageId message_id = MessagesManager::get_message_id(message.first, message.second);
|
MessageId message_id = MessageId::get_message_id(message.first, message.second);
|
||||||
if (message.second) {
|
if (message.second) {
|
||||||
found_message |= message_id.is_valid_scheduled() &&
|
found_message |= message_id.is_valid_scheduled() &&
|
||||||
message_id.get_scheduled_server_message_id().get() == update_message_id->id_;
|
message_id.get_scheduled_server_message_id().get() == update_message_id->id_;
|
||||||
@ -1207,7 +1207,7 @@ const telegram_api::Message *UpdatesManager::get_message_by_random_id(const tele
|
|||||||
} else if (constructor_id == telegram_api::updateNewChannelMessage::ID) {
|
} else if (constructor_id == telegram_api::updateNewChannelMessage::ID) {
|
||||||
message = &static_cast<const telegram_api::updateNewChannelMessage *>(update.get())->message_;
|
message = &static_cast<const telegram_api::updateNewChannelMessage *>(update.get())->message_;
|
||||||
}
|
}
|
||||||
if (message != nullptr && MessagesManager::get_full_message_id(*message, false) == full_message_id) {
|
if (message != nullptr && FullMessageId::get_full_message_id(*message, false) == full_message_id) {
|
||||||
if (result != nullptr) {
|
if (result != nullptr) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@ -1382,21 +1382,21 @@ int32 UpdatesManager::get_update_edit_message_pts(const telegram_api::Updates *u
|
|||||||
switch (update_ptr->get_id()) {
|
switch (update_ptr->get_id()) {
|
||||||
case telegram_api::updateEditMessage::ID: {
|
case telegram_api::updateEditMessage::ID: {
|
||||||
auto update = static_cast<const telegram_api::updateEditMessage *>(update_ptr.get());
|
auto update = static_cast<const telegram_api::updateEditMessage *>(update_ptr.get());
|
||||||
if (MessagesManager::get_full_message_id(update->message_, false) == full_message_id) {
|
if (FullMessageId::get_full_message_id(update->message_, false) == full_message_id) {
|
||||||
return update->pts_;
|
return update->pts_;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
case telegram_api::updateEditChannelMessage::ID: {
|
case telegram_api::updateEditChannelMessage::ID: {
|
||||||
auto update = static_cast<const telegram_api::updateEditChannelMessage *>(update_ptr.get());
|
auto update = static_cast<const telegram_api::updateEditChannelMessage *>(update_ptr.get());
|
||||||
if (MessagesManager::get_full_message_id(update->message_, false) == full_message_id) {
|
if (FullMessageId::get_full_message_id(update->message_, false) == full_message_id) {
|
||||||
return update->pts_;
|
return update->pts_;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
case telegram_api::updateNewScheduledMessage::ID: {
|
case telegram_api::updateNewScheduledMessage::ID: {
|
||||||
auto update = static_cast<const telegram_api::updateNewScheduledMessage *>(update_ptr.get());
|
auto update = static_cast<const telegram_api::updateNewScheduledMessage *>(update_ptr.get());
|
||||||
auto new_full_message_id = MessagesManager::get_full_message_id(update->message_, true);
|
auto new_full_message_id = FullMessageId::get_full_message_id(update->message_, true);
|
||||||
if (new_full_message_id.get_dialog_id() == full_message_id.get_dialog_id()) {
|
if (new_full_message_id.get_dialog_id() == full_message_id.get_dialog_id()) {
|
||||||
auto new_message_id = new_full_message_id.get_message_id();
|
auto new_message_id = new_full_message_id.get_message_id();
|
||||||
auto old_message_id = full_message_id.get_message_id();
|
auto old_message_id = full_message_id.get_message_id();
|
||||||
@ -1928,7 +1928,7 @@ void UpdatesManager::on_pending_updates(vector<tl_object_ptr<telegram_api::Updat
|
|||||||
|
|
||||||
// for channels we can try to replace unacceptable update with updateChannelTooLong
|
// for channels we can try to replace unacceptable update with updateChannelTooLong
|
||||||
if (message_ptr != nullptr) {
|
if (message_ptr != nullptr) {
|
||||||
auto dialog_id = td_->messages_manager_->get_message_dialog_id(*message_ptr);
|
auto dialog_id = DialogId::get_message_dialog_id(*message_ptr);
|
||||||
if (dialog_id.get_type() == DialogType::Channel) {
|
if (dialog_id.get_type() == DialogType::Channel) {
|
||||||
auto channel_id = dialog_id.get_channel_id();
|
auto channel_id = dialog_id.get_channel_id();
|
||||||
if (td_->contacts_manager_->have_channel_force(channel_id)) {
|
if (td_->contacts_manager_->have_channel_force(channel_id)) {
|
||||||
@ -2867,7 +2867,7 @@ void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateNewMessage> upd
|
|||||||
}
|
}
|
||||||
|
|
||||||
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateNewChannelMessage> update, Promise<Unit> &&promise) {
|
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateNewChannelMessage> update, Promise<Unit> &&promise) {
|
||||||
DialogId dialog_id = MessagesManager::get_message_dialog_id(update->message_);
|
DialogId dialog_id = DialogId::get_message_dialog_id(update->message_);
|
||||||
int new_pts = update->pts_;
|
int new_pts = update->pts_;
|
||||||
int pts_count = update->pts_count_;
|
int pts_count = update->pts_count_;
|
||||||
td_->messages_manager_->add_pending_channel_update(dialog_id, std::move(update), new_pts, pts_count,
|
td_->messages_manager_->add_pending_channel_update(dialog_id, std::move(update), new_pts, pts_count,
|
||||||
@ -2956,7 +2956,7 @@ void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateChannel> update
|
|||||||
}
|
}
|
||||||
|
|
||||||
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateEditChannelMessage> update, Promise<Unit> &&promise) {
|
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateEditChannelMessage> update, Promise<Unit> &&promise) {
|
||||||
DialogId dialog_id = MessagesManager::get_message_dialog_id(update->message_);
|
DialogId dialog_id = DialogId::get_message_dialog_id(update->message_);
|
||||||
int new_pts = update->pts_;
|
int new_pts = update->pts_;
|
||||||
int pts_count = update->pts_count_;
|
int pts_count = update->pts_count_;
|
||||||
td_->messages_manager_->add_pending_channel_update(dialog_id, std::move(update), new_pts, pts_count,
|
td_->messages_manager_->add_pending_channel_update(dialog_id, std::move(update), new_pts, pts_count,
|
||||||
@ -3205,7 +3205,7 @@ bool UpdatesManager::check_pts_update(const tl_object_ptr<telegram_api::Update>
|
|||||||
return true;
|
return true;
|
||||||
case telegram_api::updateNewMessage::ID: {
|
case telegram_api::updateNewMessage::ID: {
|
||||||
auto update_new_message = static_cast<const telegram_api::updateNewMessage *>(update.get());
|
auto update_new_message = static_cast<const telegram_api::updateNewMessage *>(update.get());
|
||||||
return check_pts_update_dialog_id(MessagesManager::get_message_dialog_id(update_new_message->message_));
|
return check_pts_update_dialog_id(DialogId::get_message_dialog_id(update_new_message->message_));
|
||||||
}
|
}
|
||||||
case telegram_api::updateReadHistoryInbox::ID: {
|
case telegram_api::updateReadHistoryInbox::ID: {
|
||||||
auto update_read_history_inbox = static_cast<const telegram_api::updateReadHistoryInbox *>(update.get());
|
auto update_read_history_inbox = static_cast<const telegram_api::updateReadHistoryInbox *>(update.get());
|
||||||
@ -3217,7 +3217,7 @@ bool UpdatesManager::check_pts_update(const tl_object_ptr<telegram_api::Update>
|
|||||||
}
|
}
|
||||||
case telegram_api::updateEditMessage::ID: {
|
case telegram_api::updateEditMessage::ID: {
|
||||||
auto update_edit_message = static_cast<const telegram_api::updateEditMessage *>(update.get());
|
auto update_edit_message = static_cast<const telegram_api::updateEditMessage *>(update.get());
|
||||||
return check_pts_update_dialog_id(MessagesManager::get_message_dialog_id(update_edit_message->message_));
|
return check_pts_update_dialog_id(DialogId::get_message_dialog_id(update_edit_message->message_));
|
||||||
}
|
}
|
||||||
case telegram_api::updatePinnedMessages::ID: {
|
case telegram_api::updatePinnedMessages::ID: {
|
||||||
auto update_pinned_messages = static_cast<const telegram_api::updatePinnedMessages *>(update.get());
|
auto update_pinned_messages = static_cast<const telegram_api::updatePinnedMessages *>(update.get());
|
||||||
|
Loading…
Reference in New Issue
Block a user