Add add_message_content_dependencies.

GitOrigin-RevId: 10c2cafe4de13907cad62c7f5df55f008fffbc94
This commit is contained in:
levlam 2018-09-28 04:29:55 +03:00
parent 4597689060
commit 4451d8d2ed
2 changed files with 30 additions and 23 deletions

View File

@ -16681,22 +16681,11 @@ bool MessagesManager::is_message_auto_read(DialogId dialog_id, bool is_outgoing)
} }
} }
void MessagesManager::add_message_dependencies(Dependencies &dependencies, DialogId dialog_id, const Message *m) { void MessagesManager::add_message_content_dependencies(Dependencies &dependencies,
dependencies.user_ids.insert(m->sender_user_id); const MessageContent *message_content) {
dependencies.user_ids.insert(m->via_bot_user_id); switch (message_content->get_type()) {
if (m->forward_info != nullptr) {
dependencies.user_ids.insert(m->forward_info->sender_user_id);
if (m->forward_info->dialog_id.is_valid() && dependencies.dialog_ids.insert(m->forward_info->dialog_id).second) {
add_dialog_dependencies(dependencies, m->forward_info->dialog_id);
}
if (m->forward_info->from_dialog_id.is_valid() &&
dependencies.dialog_ids.insert(m->forward_info->from_dialog_id).second) {
add_dialog_dependencies(dependencies, m->forward_info->from_dialog_id);
}
}
switch (m->content->get_type()) {
case MessageContentType::Text: { case MessageContentType::Text: {
auto content = static_cast<const MessageText *>(m->content.get()); auto content = static_cast<const MessageText *>(message_content);
dependencies.web_page_ids.insert(content->web_page_id); dependencies.web_page_ids.insert(content->web_page_id);
break; break;
} }
@ -16705,14 +16694,14 @@ void MessagesManager::add_message_dependencies(Dependencies &dependencies, Dialo
case MessageContentType::Audio: case MessageContentType::Audio:
break; break;
case MessageContentType::Contact: { case MessageContentType::Contact: {
auto content = static_cast<const MessageContact *>(m->content.get()); auto content = static_cast<const MessageContact *>(message_content);
dependencies.user_ids.insert(content->contact.get_user_id()); dependencies.user_ids.insert(content->contact.get_user_id());
break; break;
} }
case MessageContentType::Document: case MessageContentType::Document:
break; break;
case MessageContentType::Game: { case MessageContentType::Game: {
auto content = static_cast<const MessageGame *>(m->content.get()); auto content = static_cast<const MessageGame *>(message_content);
dependencies.user_ids.insert(content->game.get_bot_user_id()); dependencies.user_ids.insert(content->game.get_bot_user_id());
break; break;
} }
@ -16735,7 +16724,7 @@ void MessagesManager::add_message_dependencies(Dependencies &dependencies, Dialo
case MessageContentType::VoiceNote: case MessageContentType::VoiceNote:
break; break;
case MessageContentType::ChatCreate: { case MessageContentType::ChatCreate: {
auto content = static_cast<const MessageChatCreate *>(m->content.get()); auto content = static_cast<const MessageChatCreate *>(message_content);
dependencies.user_ids.insert(content->participant_user_ids.begin(), content->participant_user_ids.end()); dependencies.user_ids.insert(content->participant_user_ids.begin(), content->participant_user_ids.end());
break; break;
} }
@ -16748,26 +16737,26 @@ void MessagesManager::add_message_dependencies(Dependencies &dependencies, Dialo
case MessageContentType::ChatDeleteHistory: case MessageContentType::ChatDeleteHistory:
break; break;
case MessageContentType::ChatAddUsers: { case MessageContentType::ChatAddUsers: {
auto content = static_cast<const MessageChatAddUsers *>(m->content.get()); auto content = static_cast<const MessageChatAddUsers *>(message_content);
dependencies.user_ids.insert(content->user_ids.begin(), content->user_ids.end()); dependencies.user_ids.insert(content->user_ids.begin(), content->user_ids.end());
break; break;
} }
case MessageContentType::ChatJoinedByLink: case MessageContentType::ChatJoinedByLink:
break; break;
case MessageContentType::ChatDeleteUser: { case MessageContentType::ChatDeleteUser: {
auto content = static_cast<const MessageChatDeleteUser *>(m->content.get()); auto content = static_cast<const MessageChatDeleteUser *>(message_content);
dependencies.user_ids.insert(content->user_id); dependencies.user_ids.insert(content->user_id);
break; break;
} }
case MessageContentType::ChatMigrateTo: { case MessageContentType::ChatMigrateTo: {
auto content = static_cast<const MessageChatMigrateTo *>(m->content.get()); auto content = static_cast<const MessageChatMigrateTo *>(message_content);
dependencies.channel_ids.insert(content->migrated_to_channel_id); dependencies.channel_ids.insert(content->migrated_to_channel_id);
break; break;
} }
case MessageContentType::ChannelCreate: case MessageContentType::ChannelCreate:
break; break;
case MessageContentType::ChannelMigrateFrom: { case MessageContentType::ChannelMigrateFrom: {
auto content = static_cast<const MessageChannelMigrateFrom *>(m->content.get()); auto content = static_cast<const MessageChannelMigrateFrom *>(message_content);
dependencies.chat_ids.insert(content->migrated_from_chat_id); dependencies.chat_ids.insert(content->migrated_from_chat_id);
break; break;
} }
@ -16803,7 +16792,23 @@ void MessagesManager::add_message_dependencies(Dependencies &dependencies, Dialo
UNREACHABLE(); UNREACHABLE();
break; break;
} }
add_formatted_text_dependencies(dependencies, get_message_content_text(m->content.get())); add_formatted_text_dependencies(dependencies, get_message_content_text(message_content));
}
void MessagesManager::add_message_dependencies(Dependencies &dependencies, DialogId dialog_id, const Message *m) {
dependencies.user_ids.insert(m->sender_user_id);
dependencies.user_ids.insert(m->via_bot_user_id);
if (m->forward_info != nullptr) {
dependencies.user_ids.insert(m->forward_info->sender_user_id);
if (m->forward_info->dialog_id.is_valid() && dependencies.dialog_ids.insert(m->forward_info->dialog_id).second) {
add_dialog_dependencies(dependencies, m->forward_info->dialog_id);
}
if (m->forward_info->from_dialog_id.is_valid() &&
dependencies.dialog_ids.insert(m->forward_info->from_dialog_id).second) {
add_dialog_dependencies(dependencies, m->forward_info->from_dialog_id);
}
}
add_message_content_dependencies(dependencies, m->content.get());
} }
void MessagesManager::add_dialog_dependencies(Dependencies &dependencies, DialogId dialog_id) { void MessagesManager::add_dialog_dependencies(Dependencies &dependencies, DialogId dialog_id) {

View File

@ -2738,6 +2738,8 @@ class MessagesManager : public Actor {
static void dump_debug_message_op(const Dialog *d, int priority = 0); static void dump_debug_message_op(const Dialog *d, int priority = 0);
static void add_message_content_dependencies(Dependencies &dependencies, const MessageContent *message_content);
static void add_message_dependencies(Dependencies &dependencies, DialogId dialog_id, const Message *m); static void add_message_dependencies(Dependencies &dependencies, DialogId dialog_id, const Message *m);
static void add_dialog_dependencies(Dependencies &dependencies, DialogId dialog_id); static void add_dialog_dependencies(Dependencies &dependencies, DialogId dialog_id);