Support file reference repair for quick reply messages.
This commit is contained in:
parent
ee25355ba6
commit
3f85140627
@ -16,6 +16,7 @@
|
|||||||
#include "td/telegram/Global.h"
|
#include "td/telegram/Global.h"
|
||||||
#include "td/telegram/MessagesManager.h"
|
#include "td/telegram/MessagesManager.h"
|
||||||
#include "td/telegram/NotificationSettingsManager.h"
|
#include "td/telegram/NotificationSettingsManager.h"
|
||||||
|
#include "td/telegram/QuickReplyManager.h"
|
||||||
#include "td/telegram/StickerSetId.h"
|
#include "td/telegram/StickerSetId.h"
|
||||||
#include "td/telegram/StickersManager.h"
|
#include "td/telegram/StickersManager.h"
|
||||||
#include "td/telegram/StoryManager.h"
|
#include "td/telegram/StoryManager.h"
|
||||||
@ -80,6 +81,7 @@ fileSourceUserFull = FileSource; // repa
|
|||||||
fileSourceAttachmentMenuBot user_id:int53 = FileSource; // repaired with messages.getAttachMenuBot
|
fileSourceAttachmentMenuBot user_id:int53 = FileSource; // repaired with messages.getAttachMenuBot
|
||||||
fileSourceWebApp user_id:int53 short_name:string = FileSource; // repaired with messages.getAttachMenuBot
|
fileSourceWebApp user_id:int53 short_name:string = FileSource; // repaired with messages.getAttachMenuBot
|
||||||
fileSourceStory chat_id:int53 story_id:int32 = FileSource; // repaired with stories.getStoriesByID
|
fileSourceStory chat_id:int53 story_id:int32 = FileSource; // repaired with stories.getStoriesByID
|
||||||
|
fileSourceQuickReplyMessage shortcut_id:int32 message_id:int53 = FileSource; // repaired with messages.getQuickReplyMessages
|
||||||
*/
|
*/
|
||||||
|
|
||||||
FileSourceId FileReferenceManager::get_current_file_source_id() const {
|
FileSourceId FileReferenceManager::get_current_file_source_id() const {
|
||||||
@ -169,6 +171,11 @@ FileSourceId FileReferenceManager::create_story_file_source(StoryFullId story_fu
|
|||||||
return add_file_source_id(source, PSLICE() << story_full_id);
|
return add_file_source_id(source, PSLICE() << story_full_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FileSourceId FileReferenceManager::create_quick_reply_message_file_source(QuickReplyMessageFullId message_full_id) {
|
||||||
|
FileSourceQuickReplyMessage source{message_full_id};
|
||||||
|
return add_file_source_id(source, PSLICE() << "quick reply " << message_full_id);
|
||||||
|
}
|
||||||
|
|
||||||
FileReferenceManager::Node &FileReferenceManager::add_node(NodeId node_id) {
|
FileReferenceManager::Node &FileReferenceManager::add_node(NodeId node_id) {
|
||||||
CHECK(node_id.is_valid());
|
CHECK(node_id.is_valid());
|
||||||
auto &node = nodes_[node_id];
|
auto &node = nodes_[node_id];
|
||||||
@ -383,6 +390,11 @@ void FileReferenceManager::send_query(Destination dest, FileSourceId file_source
|
|||||||
[&](const FileSourceStory &source) {
|
[&](const FileSourceStory &source) {
|
||||||
send_closure_later(G()->story_manager(), &StoryManager::reload_story, source.story_full_id, std::move(promise),
|
send_closure_later(G()->story_manager(), &StoryManager::reload_story, source.story_full_id, std::move(promise),
|
||||||
"FileSourceStory");
|
"FileSourceStory");
|
||||||
|
},
|
||||||
|
[&](const FileSourceQuickReplyMessage &source) {
|
||||||
|
send_closure_later(G()->quick_reply_manager(), &QuickReplyManager::reload_quick_reply_message,
|
||||||
|
source.message_full_id.get_quick_reply_shortcut_id(),
|
||||||
|
source.message_full_id.get_message_id(), std::move(promise));
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include "td/telegram/files/FileSourceId.h"
|
#include "td/telegram/files/FileSourceId.h"
|
||||||
#include "td/telegram/MessageFullId.h"
|
#include "td/telegram/MessageFullId.h"
|
||||||
#include "td/telegram/PhotoSizeSource.h"
|
#include "td/telegram/PhotoSizeSource.h"
|
||||||
|
#include "td/telegram/QuickReplyMessageFullId.h"
|
||||||
#include "td/telegram/SetWithPosition.h"
|
#include "td/telegram/SetWithPosition.h"
|
||||||
#include "td/telegram/StoryFullId.h"
|
#include "td/telegram/StoryFullId.h"
|
||||||
#include "td/telegram/td_api.h"
|
#include "td/telegram/td_api.h"
|
||||||
@ -66,6 +67,7 @@ class FileReferenceManager final : public Actor {
|
|||||||
FileSourceId create_attach_menu_bot_file_source(UserId user_id);
|
FileSourceId create_attach_menu_bot_file_source(UserId user_id);
|
||||||
FileSourceId create_web_app_file_source(UserId user_id, const string &short_name);
|
FileSourceId create_web_app_file_source(UserId user_id, const string &short_name);
|
||||||
FileSourceId create_story_file_source(StoryFullId story_full_id);
|
FileSourceId create_story_file_source(StoryFullId story_full_id);
|
||||||
|
FileSourceId create_quick_reply_message_file_source(QuickReplyMessageFullId message_full_id);
|
||||||
|
|
||||||
using NodeId = FileId;
|
using NodeId = FileId;
|
||||||
void repair_file_reference(NodeId node_id, Promise<> promise);
|
void repair_file_reference(NodeId node_id, Promise<> promise);
|
||||||
@ -174,13 +176,17 @@ class FileReferenceManager final : public Actor {
|
|||||||
struct FileSourceStory {
|
struct FileSourceStory {
|
||||||
StoryFullId story_full_id;
|
StoryFullId story_full_id;
|
||||||
};
|
};
|
||||||
|
struct FileSourceQuickReplyMessage {
|
||||||
|
QuickReplyMessageFullId message_full_id;
|
||||||
|
};
|
||||||
|
|
||||||
// append only
|
// append only
|
||||||
using FileSource =
|
using FileSource =
|
||||||
Variant<FileSourceMessage, FileSourceUserPhoto, FileSourceChatPhoto, FileSourceChannelPhoto, FileSourceWallpapers,
|
Variant<FileSourceMessage, FileSourceUserPhoto, FileSourceChatPhoto, FileSourceChannelPhoto, FileSourceWallpapers,
|
||||||
FileSourceWebPage, FileSourceSavedAnimations, FileSourceRecentStickers, FileSourceFavoriteStickers,
|
FileSourceWebPage, FileSourceSavedAnimations, FileSourceRecentStickers, FileSourceFavoriteStickers,
|
||||||
FileSourceBackground, FileSourceChatFull, FileSourceChannelFull, FileSourceAppConfig,
|
FileSourceBackground, FileSourceChatFull, FileSourceChannelFull, FileSourceAppConfig,
|
||||||
FileSourceSavedRingtones, FileSourceUserFull, FileSourceAttachMenuBot, FileSourceWebApp, FileSourceStory>;
|
FileSourceSavedRingtones, FileSourceUserFull, FileSourceAttachMenuBot, FileSourceWebApp, FileSourceStory,
|
||||||
|
FileSourceQuickReplyMessage>;
|
||||||
WaitFreeVector<FileSource> file_sources_;
|
WaitFreeVector<FileSource> file_sources_;
|
||||||
|
|
||||||
int64 query_generation_{0};
|
int64 query_generation_{0};
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
#include "td/telegram/MessageFullId.h"
|
#include "td/telegram/MessageFullId.h"
|
||||||
#include "td/telegram/MessagesManager.h"
|
#include "td/telegram/MessagesManager.h"
|
||||||
#include "td/telegram/NotificationSettingsManager.h"
|
#include "td/telegram/NotificationSettingsManager.h"
|
||||||
|
#include "td/telegram/QuickReplyManager.h"
|
||||||
|
#include "td/telegram/QuickReplyMessageFullId.h"
|
||||||
#include "td/telegram/StickersManager.h"
|
#include "td/telegram/StickersManager.h"
|
||||||
#include "td/telegram/StoryFullId.h"
|
#include "td/telegram/StoryFullId.h"
|
||||||
#include "td/telegram/StoryManager.h"
|
#include "td/telegram/StoryManager.h"
|
||||||
@ -36,32 +38,34 @@ void FileReferenceManager::store_file_source(FileSourceId file_source_id, Storer
|
|||||||
CHECK(index < file_sources_.size());
|
CHECK(index < file_sources_.size());
|
||||||
auto &source = file_sources_[index];
|
auto &source = file_sources_[index];
|
||||||
td::store(source.get_offset(), storer);
|
td::store(source.get_offset(), storer);
|
||||||
source.visit(overloaded([&](const FileSourceMessage &source) { td::store(source.message_full_id, storer); },
|
source.visit(
|
||||||
[&](const FileSourceUserPhoto &source) {
|
overloaded([&](const FileSourceMessage &source) { td::store(source.message_full_id, storer); },
|
||||||
td::store(source.user_id, storer);
|
[&](const FileSourceUserPhoto &source) {
|
||||||
td::store(source.photo_id, storer);
|
td::store(source.user_id, storer);
|
||||||
},
|
td::store(source.photo_id, storer);
|
||||||
[&](const FileSourceChatPhoto &source) { td::store(source.chat_id, storer); },
|
},
|
||||||
[&](const FileSourceChannelPhoto &source) { td::store(source.channel_id, storer); },
|
[&](const FileSourceChatPhoto &source) { td::store(source.chat_id, storer); },
|
||||||
[&](const FileSourceWallpapers &source) {},
|
[&](const FileSourceChannelPhoto &source) { td::store(source.channel_id, storer); },
|
||||||
[&](const FileSourceWebPage &source) { td::store(source.url, storer); },
|
[&](const FileSourceWallpapers &source) {},
|
||||||
[&](const FileSourceSavedAnimations &source) {},
|
[&](const FileSourceWebPage &source) { td::store(source.url, storer); },
|
||||||
[&](const FileSourceRecentStickers &source) { td::store(source.is_attached, storer); },
|
[&](const FileSourceSavedAnimations &source) {},
|
||||||
[&](const FileSourceFavoriteStickers &source) {},
|
[&](const FileSourceRecentStickers &source) { td::store(source.is_attached, storer); },
|
||||||
[&](const FileSourceBackground &source) {
|
[&](const FileSourceFavoriteStickers &source) {},
|
||||||
td::store(source.background_id, storer);
|
[&](const FileSourceBackground &source) {
|
||||||
td::store(source.access_hash, storer);
|
td::store(source.background_id, storer);
|
||||||
},
|
td::store(source.access_hash, storer);
|
||||||
[&](const FileSourceChatFull &source) { td::store(source.chat_id, storer); },
|
},
|
||||||
[&](const FileSourceChannelFull &source) { td::store(source.channel_id, storer); },
|
[&](const FileSourceChatFull &source) { td::store(source.chat_id, storer); },
|
||||||
[&](const FileSourceAppConfig &source) {}, [&](const FileSourceSavedRingtones &source) {},
|
[&](const FileSourceChannelFull &source) { td::store(source.channel_id, storer); },
|
||||||
[&](const FileSourceUserFull &source) { td::store(source.user_id, storer); },
|
[&](const FileSourceAppConfig &source) {}, [&](const FileSourceSavedRingtones &source) {},
|
||||||
[&](const FileSourceAttachMenuBot &source) { td::store(source.user_id, storer); },
|
[&](const FileSourceUserFull &source) { td::store(source.user_id, storer); },
|
||||||
[&](const FileSourceWebApp &source) {
|
[&](const FileSourceAttachMenuBot &source) { td::store(source.user_id, storer); },
|
||||||
td::store(source.user_id, storer);
|
[&](const FileSourceWebApp &source) {
|
||||||
td::store(source.short_name, storer);
|
td::store(source.user_id, storer);
|
||||||
},
|
td::store(source.short_name, storer);
|
||||||
[&](const FileSourceStory &source) { td::store(source.story_full_id, storer); }));
|
},
|
||||||
|
[&](const FileSourceStory &source) { td::store(source.story_full_id, storer); },
|
||||||
|
[&](const FileSourceQuickReplyMessage &source) { td::store(source.message_full_id, storer); }));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class ParserT>
|
template <class ParserT>
|
||||||
@ -149,6 +153,11 @@ FileSourceId FileReferenceManager::parse_file_source(Td *td, ParserT &parser) {
|
|||||||
td::parse(story_full_id, parser);
|
td::parse(story_full_id, parser);
|
||||||
return td->story_manager_->get_story_file_source_id(story_full_id);
|
return td->story_manager_->get_story_file_source_id(story_full_id);
|
||||||
}
|
}
|
||||||
|
case 18: {
|
||||||
|
QuickReplyMessageFullId message_full_id;
|
||||||
|
td::parse(message_full_id, parser);
|
||||||
|
return td->quick_reply_manager_->get_quick_reply_message_file_source_id(message_full_id);
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
parser.set_error("Invalid type in FileSource");
|
parser.set_error("Invalid type in FileSource");
|
||||||
return FileSourceId();
|
return FileSourceId();
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include "td/telegram/ContactsManager.h"
|
#include "td/telegram/ContactsManager.h"
|
||||||
#include "td/telegram/Dependencies.h"
|
#include "td/telegram/Dependencies.h"
|
||||||
#include "td/telegram/DialogManager.h"
|
#include "td/telegram/DialogManager.h"
|
||||||
|
#include "td/telegram/FileReferenceManager.h"
|
||||||
#include "td/telegram/Global.h"
|
#include "td/telegram/Global.h"
|
||||||
#include "td/telegram/logevent/LogEvent.h"
|
#include "td/telegram/logevent/LogEvent.h"
|
||||||
#include "td/telegram/logevent/LogEventHelper.h"
|
#include "td/telegram/logevent/LogEventHelper.h"
|
||||||
@ -1290,6 +1291,21 @@ void QuickReplyManager::send_update_quick_reply_shortcut_messages(const Shortcut
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FileSourceId QuickReplyManager::get_quick_reply_message_file_source_id(QuickReplyMessageFullId message_full_id) {
|
||||||
|
if (td_->auth_manager_->is_bot()) {
|
||||||
|
return FileSourceId();
|
||||||
|
}
|
||||||
|
if (!message_full_id.is_server()) {
|
||||||
|
return FileSourceId();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto &file_source_id = message_full_id_to_file_source_id_[message_full_id];
|
||||||
|
if (!file_source_id.is_valid()) {
|
||||||
|
file_source_id = td_->file_reference_manager_->create_quick_reply_message_file_source(message_full_id);
|
||||||
|
}
|
||||||
|
return file_source_id;
|
||||||
|
}
|
||||||
|
|
||||||
void QuickReplyManager::get_current_state(vector<td_api::object_ptr<td_api::Update>> &updates) const {
|
void QuickReplyManager::get_current_state(vector<td_api::object_ptr<td_api::Update>> &updates) const {
|
||||||
if (td_->auth_manager_->is_bot()) {
|
if (td_->auth_manager_->is_bot()) {
|
||||||
return;
|
return;
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "td/telegram/DialogId.h"
|
#include "td/telegram/DialogId.h"
|
||||||
|
#include "td/telegram/files/FileSourceId.h"
|
||||||
#include "td/telegram/MessageId.h"
|
#include "td/telegram/MessageId.h"
|
||||||
#include "td/telegram/QuickReplyMessageFullId.h"
|
#include "td/telegram/QuickReplyMessageFullId.h"
|
||||||
#include "td/telegram/QuickReplyShortcutId.h"
|
#include "td/telegram/QuickReplyShortcutId.h"
|
||||||
@ -48,6 +49,8 @@ class QuickReplyManager final : public Actor {
|
|||||||
|
|
||||||
void reload_quick_reply_message(QuickReplyShortcutId shortcut_id, MessageId message_id, Promise<Unit> &&promise);
|
void reload_quick_reply_message(QuickReplyShortcutId shortcut_id, MessageId message_id, Promise<Unit> &&promise);
|
||||||
|
|
||||||
|
FileSourceId get_quick_reply_message_file_source_id(QuickReplyMessageFullId message_full_id);
|
||||||
|
|
||||||
void get_current_state(vector<td_api::object_ptr<td_api::Update>> &updates) const;
|
void get_current_state(vector<td_api::object_ptr<td_api::Update>> &updates) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -252,6 +255,8 @@ class QuickReplyManager final : public Actor {
|
|||||||
|
|
||||||
FlatHashSet<QuickReplyMessageFullId, QuickReplyMessageFullIdHash> deleted_message_full_ids_;
|
FlatHashSet<QuickReplyMessageFullId, QuickReplyMessageFullIdHash> deleted_message_full_ids_;
|
||||||
|
|
||||||
|
FlatHashMap<QuickReplyMessageFullId, FileSourceId, QuickReplyMessageFullIdHash> message_full_id_to_file_source_id_;
|
||||||
|
|
||||||
Td *td_;
|
Td *td_;
|
||||||
ActorShared<> parent_;
|
ActorShared<> parent_;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user