Add and use MessagesManager::get_message_original_date.

This commit is contained in:
levlam 2024-01-11 19:36:00 +03:00
parent b3a94f187f
commit 8c6024808a
3 changed files with 16 additions and 2 deletions

View File

@ -60,6 +60,10 @@ struct MessageForwardInfo {
void add_min_channel_ids(vector<ChannelId> &channel_ids) const;
int32 get_origin_date() const {
return date_;
}
MessageFullId get_origin_message_full_id() const {
return origin_.get_message_full_id();
}

View File

@ -13911,7 +13911,7 @@ void MessagesManager::on_update_sent_text_message(int64 random_id,
CHECK(old_message_text != nullptr);
FormattedText new_message_text = get_message_text(
td_->contacts_manager_.get(), old_message_text->text, std::move(entities), true, td_->auth_manager_->is_bot(),
m->forward_info ? m->forward_info->date_ : m->date, m->media_album_id != 0, "on_update_sent_text_message");
get_message_original_date(m), m->media_album_id != 0, "on_update_sent_text_message");
auto new_content = get_message_content(td_, std::move(new_message_text), std::move(message_media), dialog_id, m->date,
true /*likely ignored*/, UserId() /*likely ignored*/, nullptr /*ignored*/,
nullptr, "on_update_sent_text_message");
@ -22726,7 +22726,7 @@ MessagesManager::ForwardedMessageInfo MessagesManager::get_forwarded_message_inf
return result;
}
auto dialog_id = message_full_id.get_dialog_id();
result.origin_date_ = m->forward_info != nullptr ? m->forward_info->date_ : m->date;
result.origin_date_ = get_message_original_date(m);
result.origin_ = get_forwarded_message_origin(dialog_id, m);
result.content_ = dup_message_content(td_, td_->dialog_manager_->get_my_dialog_id(), m->content.get(),
MessageContentDupType::Forward, MessageCopyOptions());
@ -24613,6 +24613,14 @@ int32 MessagesManager::get_message_schedule_date(const Message *m) {
return m->date;
}
int32 MessagesManager::get_message_original_date(const Message *m) {
CHECK(m != nullptr);
if (m->forward_info != nullptr) {
return m->forward_info->get_origin_date();
}
return m->date;
}
DialogId MessagesManager::get_message_original_sender(const Message *m) {
CHECK(m != nullptr);
if (m->forward_info != nullptr) {

View File

@ -3038,6 +3038,8 @@ class MessagesManager final : public Actor {
static int32 get_message_schedule_date(const Message *m);
static int32 get_message_original_date(const Message *m);
static DialogId get_message_original_sender(const Message *m);
static DialogId get_message_sender(const Message *m);