2
0
mirror of https://github.com/ars3niy/tdlib-purple synced 2025-08-31 14:05:10 +00:00

When got (or failed to get) reply source, check again if message ready

Could later be still not ready due to downloads
This commit is contained in:
Arseniy Lartsev
2020-10-11 13:55:44 +02:00
parent b610766261
commit 044008da8d
4 changed files with 28 additions and 8 deletions

View File

@@ -1360,22 +1360,36 @@ void PurpleTdClient::onIncomingMessage(td::td_api::object_ptr<td::td_api::messag
);
m_data.pendingMessages.addPendingMessage(std::move(fullMessage));
}
}
void PurpleTdClient::checkMessageReady(const IncomingMessage *message)
{
if (!message || !message->message) return;
if (isMessageReady(*message, m_data)) {
std::vector<IncomingMessage> readyMessages;
m_data.pendingMessages.setMessageReady(getChatId(*message->message), getId(*message->message),
readyMessages);
message = nullptr;
showMessages(readyMessages);
}
}
void PurpleTdClient::findMessageResponse(ChatId chatId, MessageId pendingMessageId,
td::td_api::object_ptr<td::td_api::Object> object)
{
if (object && (object->get_id() == td::td_api::message::ID)) {
IncomingMessage *pendingMessage = m_data.pendingMessages.findPendingMessage(chatId, pendingMessageId);
IncomingMessage *pendingMessage = m_data.pendingMessages.findPendingMessage(chatId, pendingMessageId);
if (!pendingMessage) return;
if (object && (object->get_id() == td::td_api::message::ID))
pendingMessage->repliedMessage = td::move_tl_object_as<td::td_api::message>(object);
} else
else {
purple_debug_misc(config::pluginId, "Failed to fetch reply source for message %" G_GINT64_FORMAT "\n",
pendingMessageId.value());
pendingMessage->repliedMessageFailed = true;
}
std::vector<IncomingMessage> readyMessages;
m_data.pendingMessages.setMessageReady(chatId, pendingMessageId, readyMessages);
showMessages(readyMessages);
checkMessageReady(pendingMessage);
}
void PurpleTdClient::showMessages(std::vector<IncomingMessage>& messages)