Add RepliedMessageInfo::get_message_reply_to_message_object.

This commit is contained in:
levlam 2023-10-25 17:24:24 +03:00
parent e4ffed5752
commit fc3dfbe3c0
2 changed files with 24 additions and 0 deletions

View File

@ -7,6 +7,7 @@
#include "td/telegram/RepliedMessageInfo.h"
#include "td/telegram/MessageFullId.h"
#include "td/telegram/MessagesManager.h"
#include "td/telegram/OptionManager.h"
#include "td/telegram/ScheduledServerMessageId.h"
#include "td/telegram/ServerMessageId.h"
@ -101,6 +102,17 @@ RepliedMessageInfo::RepliedMessageInfo(Td *td, tl_object_ptr<telegram_api::messa
}
}
td_api::object_ptr<td_api::messageReplyToMessage> RepliedMessageInfo::get_message_reply_to_message_object(
Td *td, DialogId dialog_id) const {
if (dialog_id_.is_valid()) {
dialog_id = dialog_id_;
} else {
CHECK(dialog_id.is_valid());
}
return td_api::make_object<td_api::messageReplyToMessage>(
td->messages_manager_->get_chat_id_object(dialog_id, "messageReplyToMessage"), message_id_.get());
}
MessageId RepliedMessageInfo::get_same_chat_reply_to_message_id() const {
return is_same_chat_reply() ? message_id_ : MessageId();
}

View File

@ -9,6 +9,7 @@
#include "td/telegram/DialogId.h"
#include "td/telegram/MessageId.h"
#include "td/telegram/MessageOrigin.h"
#include "td/telegram/td_api.h"
#include "td/telegram/telegram_api.h"
#include "td/utils/common.h"
@ -31,6 +32,10 @@ class RepliedMessageInfo {
explicit RepliedMessageInfo(MessageId reply_to_message_id) : message_id_(reply_to_message_id) {
}
RepliedMessageInfo(MessageId reply_to_message_id, DialogId reply_in_dialog_id)
: message_id_(reply_to_message_id), dialog_id_(reply_in_dialog_id) {
}
RepliedMessageInfo(Td *td, tl_object_ptr<telegram_api::messageReplyHeader> &&reply_header, DialogId dialog_id,
MessageId message_id, int32 date);
@ -42,6 +47,13 @@ class RepliedMessageInfo {
return message_id_ == MessageId() && dialog_id_ == DialogId() && origin_date_ == 0 && origin_.is_empty();
}
bool is_yet_unsent_message() const {
return message_id_ != MessageId() && message_id_.is_yet_unsent();
}
td_api::object_ptr<td_api::messageReplyToMessage> get_message_reply_to_message_object(Td *td,
DialogId dialog_id) const;
MessageId get_same_chat_reply_to_message_id() const;
MessageFullId get_reply_message_full_id(DialogId owner_dialog_id) const;