Improve rescheduling of scheduled messages with replies.
This commit is contained in:
parent
647374a33f
commit
63d607c6c3
@ -35499,6 +35499,15 @@ bool MessagesManager::update_message(Dialog *d, Message *old_message, unique_ptr
|
||||
old_message->reply_to_message_id = new_message->reply_to_message_id;
|
||||
update_message_max_reply_media_timestamp(d, old_message, is_message_in_dialog);
|
||||
need_send_update = true;
|
||||
} else if (old_message->reply_to_message_id.is_valid_scheduled() &&
|
||||
old_message->reply_to_message_id.is_scheduled_server() &&
|
||||
new_message->reply_to_message_id.is_valid_scheduled() &&
|
||||
new_message->reply_to_message_id.is_scheduled_server() &&
|
||||
old_message->reply_to_message_id.get_scheduled_server_message_id() ==
|
||||
new_message->reply_to_message_id.get_scheduled_server_message_id()) {
|
||||
// schedule date has changed
|
||||
old_message->reply_to_message_id = new_message->reply_to_message_id;
|
||||
need_send_update = true;
|
||||
} else {
|
||||
LOG(ERROR) << message_id << " in " << dialog_id << " has changed message it is replied message from "
|
||||
<< old_message->reply_to_message_id << " to " << new_message->reply_to_message_id
|
||||
|
@ -1236,20 +1236,35 @@ int32 UpdatesManager::get_update_edit_message_pts(const telegram_api::Updates *u
|
||||
int32 pts = 0;
|
||||
auto updates = get_updates(updates_ptr);
|
||||
if (updates != nullptr) {
|
||||
for (auto &update : *updates) {
|
||||
for (auto &update_ptr : *updates) {
|
||||
int32 update_pts = [&] {
|
||||
switch (update->get_id()) {
|
||||
switch (update_ptr->get_id()) {
|
||||
case telegram_api::updateEditMessage::ID: {
|
||||
auto update_ptr = static_cast<const telegram_api::updateEditMessage *>(update.get());
|
||||
if (MessagesManager::get_full_message_id(update_ptr->message_, false) == full_message_id) {
|
||||
return update_ptr->pts_;
|
||||
auto update = static_cast<const telegram_api::updateEditMessage *>(update_ptr.get());
|
||||
if (MessagesManager::get_full_message_id(update->message_, false) == full_message_id) {
|
||||
return update->pts_;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
case telegram_api::updateEditChannelMessage::ID: {
|
||||
auto update_ptr = static_cast<const telegram_api::updateEditChannelMessage *>(update.get());
|
||||
if (MessagesManager::get_full_message_id(update_ptr->message_, false) == full_message_id) {
|
||||
return update_ptr->pts_;
|
||||
auto update = static_cast<const telegram_api::updateEditChannelMessage *>(update_ptr.get());
|
||||
if (MessagesManager::get_full_message_id(update->message_, false) == full_message_id) {
|
||||
return update->pts_;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
case telegram_api::updateNewScheduledMessage::ID: {
|
||||
auto update = static_cast<const telegram_api::updateNewScheduledMessage *>(update_ptr.get());
|
||||
auto new_full_message_id = MessagesManager::get_full_message_id(update->message_, true);
|
||||
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 old_message_id = full_message_id.get_message_id();
|
||||
if (new_message_id.is_valid_scheduled() && new_message_id.is_scheduled_server() &&
|
||||
old_message_id.is_valid_scheduled() && old_message_id.is_scheduled_server() &&
|
||||
old_message_id.get_scheduled_server_message_id() ==
|
||||
new_message_id.get_scheduled_server_message_id()) {
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user