Add MessageOrigin::add_user_ids/add_channel_ids.

This commit is contained in:
levlam 2023-10-09 19:20:53 +03:00
parent c05b5ba3e5
commit 8da2eba168
3 changed files with 21 additions and 5 deletions

View File

@ -108,6 +108,18 @@ void MessageOrigin::add_dependencies(Dependencies &dependencies) const {
dependencies.add_dialog_and_dependencies(sender_dialog_id_);
}
void MessageOrigin::add_user_ids(vector<UserId> &user_ids) const {
if (sender_user_id_.is_valid()) {
user_ids.push_back(sender_user_id_);
}
}
void MessageOrigin::add_channel_ids(vector<ChannelId> &channel_ids) const {
if (sender_dialog_id_.get_type() == DialogType::Channel) {
channel_ids.push_back(sender_dialog_id_.get_channel_id());
}
}
bool operator==(const MessageOrigin &lhs, const MessageOrigin &rhs) {
return lhs.sender_user_id_ == rhs.sender_user_id_ && lhs.sender_dialog_id_ == rhs.sender_dialog_id_ &&
lhs.message_id_ == rhs.message_id_ && lhs.author_signature_ == rhs.author_signature_ &&

View File

@ -6,6 +6,7 @@
//
#pragma once
#include "td/telegram/ChannelId.h"
#include "td/telegram/DialogId.h"
#include "td/telegram/MessageId.h"
#include "td/telegram/td_api.h"
@ -53,6 +54,10 @@ struct MessageOrigin {
void add_dependencies(Dependencies &dependencies) const;
void add_user_ids(vector<UserId> &user_ids) const;
void add_channel_ids(vector<ChannelId> &channel_ids) const;
friend bool operator==(const MessageOrigin &lhs, const MessageOrigin &rhs);
friend StringBuilder &operator<<(StringBuilder &string_builder, const MessageOrigin &origin);

View File

@ -13100,8 +13100,8 @@ vector<UserId> MessagesManager::get_message_user_ids(const Message *m) const {
if (m->via_bot_user_id.is_valid()) {
user_ids.push_back(m->via_bot_user_id);
}
if (m->forward_info != nullptr && m->forward_info->origin.sender_user_id_.is_valid()) {
user_ids.push_back(m->forward_info->origin.sender_user_id_);
if (m->forward_info != nullptr) {
m->forward_info->origin.add_user_ids(user_ids);
}
append(user_ids, get_message_content_min_user_ids(td_, m->content.get()));
return user_ids;
@ -13112,9 +13112,8 @@ vector<ChannelId> MessagesManager::get_message_channel_ids(const Message *m) {
if (m->sender_dialog_id.is_valid() && m->sender_dialog_id.get_type() == DialogType::Channel) {
channel_ids.push_back(m->sender_dialog_id.get_channel_id());
}
if (m->forward_info != nullptr && m->forward_info->origin.sender_dialog_id_.is_valid() &&
m->forward_info->origin.sender_dialog_id_.get_type() == DialogType::Channel) {
channel_ids.push_back(m->forward_info->origin.sender_dialog_id_.get_channel_id());
if (m->forward_info != nullptr) {
m->forward_info->origin.add_channel_ids(channel_ids);
}
if (m->forward_info != nullptr && m->forward_info->from_dialog_id.is_valid() &&
m->forward_info->from_dialog_id.get_type() == DialogType::Channel) {