Add Client::init_message.

This commit is contained in:
levlam 2024-03-14 16:09:23 +03:00
parent a3f62fcdf7
commit a731cb0083
2 changed files with 11 additions and 5 deletions

View File

@ -12915,7 +12915,14 @@ Client::FullMessageId Client::add_message(object_ptr<td_api::message> &&message,
message_info = td::make_unique<MessageInfo>(); message_info = td::make_unique<MessageInfo>();
} }
message_info->id = message_id; init_message(message_info.get(), std::move(message), force_update_content);
return {chat_id, message_id};
}
void Client::init_message(MessageInfo *message_info, object_ptr<td_api::message> &&message, bool force_update_content) {
int64 chat_id = message->chat_id_;
message_info->id = message->id_;
message_info->chat_id = chat_id; message_info->chat_id = chat_id;
message_info->message_thread_id = message->message_thread_id_; message_info->message_thread_id = message->message_thread_id_;
message_info->date = message->date_; message_info->date = message->date_;
@ -12997,11 +13004,9 @@ Client::FullMessageId Client::add_message(object_ptr<td_api::message> &&message,
} else if (message->content_->get_id() == td_api::messagePoll::ID) { } else if (message->content_->get_id() == td_api::messagePoll::ID) {
message_info->content = std::move(message->content_); message_info->content = std::move(message->content_);
} }
set_message_reply_markup(message_info.get(), std::move(message->reply_markup_)); set_message_reply_markup(message_info, std::move(message->reply_markup_));
message = nullptr; message = nullptr;
return {chat_id, message_id};
} }
void Client::update_message_content(int64 chat_id, int64 message_id, object_ptr<td_api::MessageContent> &&content) { void Client::update_message_content(int64 chat_id, int64 message_id, object_ptr<td_api::MessageContent> &&content) {

View File

@ -924,7 +924,7 @@ class Client final : public WebhookActor::Callback {
static bool are_equal_inline_keyboards(const td_api::replyMarkupInlineKeyboard *lhs, static bool are_equal_inline_keyboards(const td_api::replyMarkupInlineKeyboard *lhs,
const td_api::replyMarkupInlineKeyboard *rhs); const td_api::replyMarkupInlineKeyboard *rhs);
void set_message_reply_markup(MessageInfo *message_info, object_ptr<td_api::ReplyMarkup> &&reply_markup); static void set_message_reply_markup(MessageInfo *message_info, object_ptr<td_api::ReplyMarkup> &&reply_markup);
static int64 get_sticker_set_id(const object_ptr<td_api::MessageContent> &content); static int64 get_sticker_set_id(const object_ptr<td_api::MessageContent> &content);
@ -975,6 +975,7 @@ class Client final : public WebhookActor::Callback {
}; };
FullMessageId add_message(object_ptr<td_api::message> &&message, bool force_update_content = false); FullMessageId add_message(object_ptr<td_api::message> &&message, bool force_update_content = false);
void init_message(MessageInfo *message_info, object_ptr<td_api::message> &&message, bool force_update_content);
const MessageInfo *get_message(int64 chat_id, int64 message_id, bool force_cache) const; const MessageInfo *get_message(int64 chat_id, int64 message_id, bool force_cache) const;
MessageInfo *get_message_editable(int64 chat_id, int64 message_id); MessageInfo *get_message_editable(int64 chat_id, int64 message_id);