Support RepliedMessageInfo in *FromMessage.

This commit is contained in:
levlam 2023-10-27 01:41:15 +03:00
parent 9260d38618
commit 5b9731a974
4 changed files with 45 additions and 1 deletions

View File

@ -3602,6 +3602,7 @@ std::pair<InputGroupCallId, bool> get_message_content_group_call_info(const Mess
}
vector<UserId> get_message_content_min_user_ids(const Td *td, const MessageContent *message_content) {
CHECK(message_content != nullptr);
switch (message_content->get_type()) {
case MessageContentType::Text: {
const auto *content = static_cast<const MessageText *>(message_content);
@ -3710,6 +3711,7 @@ vector<UserId> get_message_content_min_user_ids(const Td *td, const MessageConte
case MessageContentType::Dice:
break;
case MessageContentType::ProximityAlertTriggered:
// not supported server-side
break;
case MessageContentType::GroupCall:
break;
@ -3765,7 +3767,11 @@ vector<UserId> get_message_content_min_user_ids(const Td *td, const MessageConte
}
vector<ChannelId> get_message_content_min_channel_ids(const Td *td, const MessageContent *message_content) {
CHECK(message_content != nullptr);
switch (message_content->get_type()) {
case MessageContentType::ProximityAlertTriggered:
// not supported server-side
break;
case MessageContentType::Giveaway: {
const auto *content = static_cast<const MessageGiveaway *>(message_content);
return content->giveaway_parameters.get_channel_ids();

View File

@ -13145,6 +13145,9 @@ vector<UserId> MessagesManager::get_message_user_ids(const Message *m) const {
m->forward_info->origin.add_user_ids(user_ids);
}
append(user_ids, get_message_content_min_user_ids(td_, m->content.get()));
if (!m->replied_message_info.is_empty()) {
append(user_ids, m->replied_message_info.get_min_user_ids(td_));
}
return user_ids;
}
@ -13161,6 +13164,9 @@ vector<ChannelId> MessagesManager::get_message_channel_ids(const Message *m) con
channel_ids.push_back(m->forward_info->from_dialog_id.get_channel_id());
}
append(channel_ids, get_message_content_min_channel_ids(td_, m->content.get()));
if (!m->replied_message_info.is_empty()) {
append(channel_ids, m->replied_message_info.get_min_channel_ids(td_));
}
return channel_ids;
}

View File

@ -17,8 +17,8 @@
#include "td/telegram/ServerMessageId.h"
#include "td/telegram/StoryId.h"
#include "td/telegram/Td.h"
#include "td/telegram/UserId.h"
#include "td/utils/algorithm.h"
#include "td/utils/logging.h"
namespace td {
@ -218,6 +218,31 @@ bool RepliedMessageInfo::need_reply_changed_warning(
return true;
}
vector<UserId> RepliedMessageInfo::get_min_user_ids(Td *td) const {
vector<UserId> user_ids;
if (dialog_id_.get_type() == DialogType::User) {
user_ids.push_back(dialog_id_.get_user_id());
}
origin_.add_user_ids(user_ids);
// not supported server-side: add_formatted_text_user_ids(user_ids, &quote_);
if (content_ != nullptr) {
append(user_ids, get_message_content_min_user_ids(td, content_.get()));
}
return user_ids;
}
vector<ChannelId> RepliedMessageInfo::get_min_channel_ids(Td *td) const {
vector<ChannelId> channel_ids;
if (dialog_id_.get_type() == DialogType::Channel) {
channel_ids.push_back(dialog_id_.get_channel_id());
}
origin_.add_channel_ids(channel_ids);
if (content_ != nullptr) {
append(channel_ids, get_message_content_min_channel_ids(td, content_.get()));
}
return channel_ids;
}
void RepliedMessageInfo::add_dependencies(Dependencies &dependencies, bool is_bot) const {
dependencies.add_dialog_and_dependencies(dialog_id_);
origin_.add_dependencies(dependencies);

View File

@ -6,14 +6,17 @@
//
#pragma once
#include "td/telegram/ChannelId.h"
#include "td/telegram/DialogId.h"
#include "td/telegram/MessageContent.h"
#include "td/telegram/MessageEntity.h"
#include "td/telegram/MessageFullId.h"
#include "td/telegram/MessageId.h"
#include "td/telegram/MessageInputReplyTo.h"
#include "td/telegram/MessageOrigin.h"
#include "td/telegram/td_api.h"
#include "td/telegram/telegram_api.h"
#include "td/telegram/UserId.h"
#include "td/utils/common.h"
@ -73,6 +76,10 @@ class RepliedMessageInfo {
const RepliedMessageInfo &old_info, const RepliedMessageInfo &new_info, MessageId old_top_thread_message_id,
bool is_yet_unsent, std::function<bool(const RepliedMessageInfo &info)> is_reply_to_deleted_message);
vector<UserId> get_min_user_ids(Td *td) const;
vector<ChannelId> get_min_channel_ids(Td *td) const;
void add_dependencies(Dependencies &dependencies, bool is_bot) const;
td_api::object_ptr<td_api::messageReplyToMessage> get_message_reply_to_message_object(Td *td,