Improve backward compatibility.

This commit is contained in:
levlam 2022-10-17 15:44:30 +03:00
parent e42e224154
commit 4067ba66d3
4 changed files with 17 additions and 6 deletions

View File

@ -5065,11 +5065,11 @@ unique_ptr<MessageContent> get_action_message_content(Td *td, tl_object_ptr<tele
}
case telegram_api::messageActionTopicCreate::ID: {
auto action = move_tl_object_as<telegram_api::messageActionTopicCreate>(action_ptr);
break;
return make_unique<MessageUnsupported>();
}
case telegram_api::messageActionTopicEdit::ID: {
auto action = move_tl_object_as<telegram_api::messageActionTopicEdit>(action_ptr);
break;
return make_unique<MessageUnsupported>();
}
default:
UNREACHABLE();

View File

@ -32345,7 +32345,7 @@ void MessagesManager::fail_edit_message_media(FullMessageId full_message_id, Sta
cancel_edit_message_media(dialog_id, m, "Failed to edit message. MUST BE IGNORED");
}
void MessagesManager::on_update_dialog_draft_message(DialogId dialog_id,
void MessagesManager::on_update_dialog_draft_message(DialogId dialog_id, MessageId top_thread_message_id,
tl_object_ptr<telegram_api::DraftMessage> &&draft_message) {
if (!dialog_id.is_valid()) {
LOG(ERROR) << "Receive update chat draft in invalid " << dialog_id;
@ -32361,7 +32361,12 @@ void MessagesManager::on_update_dialog_draft_message(DialogId dialog_id,
}
return;
}
update_dialog_draft_message(d, get_draft_message(td_->contacts_manager_.get(), std::move(draft_message)), true, true);
auto draft = get_draft_message(td_->contacts_manager_.get(), std::move(draft_message));
if (top_thread_message_id.is_valid()) {
// TODO update thread message draft
return;
}
update_dialog_draft_message(d, std::move(draft), true, true);
}
bool MessagesManager::update_dialog_draft_message(Dialog *d, unique_ptr<DraftMessage> &&draft_message, bool from_update,

View File

@ -293,7 +293,8 @@ class MessagesManager final : public Actor {
bool on_update_message_id(int64 random_id, MessageId new_message_id, const string &source);
void on_update_dialog_draft_message(DialogId dialog_id, tl_object_ptr<telegram_api::DraftMessage> &&draft_message);
void on_update_dialog_draft_message(DialogId dialog_id, MessageId top_thread_message_id,
tl_object_ptr<telegram_api::DraftMessage> &&draft_message);
void on_update_dialog_is_pinned(FolderId folder_id, DialogId dialog_id, bool is_pinned);

View File

@ -3272,7 +3272,12 @@ void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateChatDefaultBann
}
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateDraftMessage> update, Promise<Unit> &&promise) {
td_->messages_manager_->on_update_dialog_draft_message(DialogId(update->peer_), std::move(update->draft_));
MessageId top_thread_message_id;
if ((update->flags_ & telegram_api::updateDraftMessage::TOP_MSG_ID_MASK) != 0) {
top_thread_message_id = MessageId(ServerMessageId(update->top_msg_id_));
}
td_->messages_manager_->on_update_dialog_draft_message(DialogId(update->peer_), top_thread_message_id,
std::move(update->draft_));
promise.set_value(Unit());
}