Support file reference errors for added quick replies.

This commit is contained in:
levlam 2024-04-18 15:01:58 +03:00
parent 0a29b0089c
commit 1672e580a9
2 changed files with 15 additions and 2 deletions

View File

@ -370,8 +370,8 @@ class QuickReplyManager::SendQuickReplyMediaQuery final : public Td::ResultHandl
if (file_id_.is_valid() && !was_uploaded_) {
VLOG(file_references) << "Receive " << status << " for " << file_id_;
td_->file_manager_->delete_file_reference(file_id_, file_reference_);
// td_->quick_reply_manager_->on_send_message_file_reference_error(random_id_);
// return;
td_->quick_reply_manager_->on_send_message_file_reference_error(shortcut_id_, random_id_);
return;
} else {
LOG(ERROR) << "Receive file reference error, but file_id = " << file_id_
<< ", was_uploaded = " << was_uploaded_;
@ -1692,6 +1692,17 @@ void QuickReplyManager::do_send_message(const QuickReplyMessage *m, vector<int>
}
}
void QuickReplyManager::on_send_message_file_reference_error(QuickReplyShortcutId shortcut_id, int64 random_id) {
auto *s = get_shortcut(shortcut_id);
if (s != nullptr) {
for (auto &message : s->messages_) {
if (message->random_id == random_id && message->message_id.is_yet_unsent()) {
do_send_message(message.get(), {-1});
}
}
}
}
void QuickReplyManager::on_upload_media(FileId file_id, telegram_api::object_ptr<telegram_api::InputFile> input_file) {
LOG(INFO) << "File " << file_id << " has been uploaded";

View File

@ -331,6 +331,8 @@ class QuickReplyManager final : public Actor {
void do_send_message(const QuickReplyMessage *m, vector<int> bad_parts = {});
void on_send_message_file_reference_error(QuickReplyShortcutId shortcut_id, int64 random_id);
void on_upload_media(FileId file_id, telegram_api::object_ptr<telegram_api::InputFile> input_file);
void do_send_media(QuickReplyMessage *m, FileId file_id, FileId thumbnail_file_id,