Pass ChannelId to can_get_channel_message_statistics.

This commit is contained in:
levlam 2024-03-17 23:47:47 +03:00
parent 5a00fb2ba3
commit 95e86d3cf3
3 changed files with 4 additions and 9 deletions

View File

@ -6989,13 +6989,8 @@ void ContactsManager::get_channel_statistics_dc_id_impl(ChannelId channel_id, bo
promise.set_value(DcId(channel_full->stats_dc_id));
}
bool ContactsManager::can_get_channel_message_statistics(DialogId dialog_id) const {
bool ContactsManager::can_get_channel_message_statistics(ChannelId channel_id) const {
CHECK(!td_->auth_manager_->is_bot());
if (dialog_id.get_type() != DialogType::Channel) {
return false;
}
auto channel_id = dialog_id.get_channel_id();
const Channel *c = get_channel(channel_id);
if (c == nullptr || c->is_megagroup) {
return false;

View File

@ -522,7 +522,7 @@ class ContactsManager final : public Actor {
void get_channel_statistics_dc_id(DialogId dialog_id, bool for_full_statistics, Promise<DcId> &&promise);
bool can_get_channel_message_statistics(DialogId dialog_id) const;
bool can_get_channel_message_statistics(ChannelId channel_id) const;
bool can_get_channel_story_statistics(DialogId dialog_id) const;

View File

@ -9570,14 +9570,14 @@ bool MessagesManager::can_get_message_statistics(MessageFullId message_full_id)
}
bool MessagesManager::can_get_message_statistics(DialogId dialog_id, const Message *m) const {
if (td_->auth_manager_->is_bot()) {
if (td_->auth_manager_->is_bot() || dialog_id.get_type() != DialogType::Channel) {
return false;
}
if (m == nullptr || m->message_id.is_scheduled() || !m->message_id.is_server() || m->view_count == 0 ||
m->had_forward_info || (m->forward_info != nullptr && m->forward_info->get_origin().is_channel_post())) {
return false;
}
return td_->contacts_manager_->can_get_channel_message_statistics(dialog_id);
return td_->contacts_manager_->can_get_channel_message_statistics(dialog_id.get_channel_id());
}
bool MessagesManager::can_delete_channel_message(const DialogParticipantStatus &status, const Message *m, bool is_bot) {