More check_dialog_access usages.
This commit is contained in:
parent
3477fb715e
commit
b04e7fc89e
@ -77,12 +77,7 @@ class SaveAutoSaveSettingsQuery final : public Td::ResultHandler {
|
|||||||
} else {
|
} else {
|
||||||
flags |= telegram_api::account_saveAutoSaveSettings::PEER_MASK;
|
flags |= telegram_api::account_saveAutoSaveSettings::PEER_MASK;
|
||||||
input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Read);
|
input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Read);
|
||||||
if (input_peer == nullptr) {
|
CHECK(input_peer != nullptr);
|
||||||
if (dialog_id.get_type() == DialogType::SecretChat) {
|
|
||||||
return on_error(Status::Error(400, "Can't set autosave settings for secret chats"));
|
|
||||||
}
|
|
||||||
return on_error(Status::Error(400, "Can't access the chat"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
send_query(G()->net_query_creator().create(
|
send_query(G()->net_query_creator().create(
|
||||||
telegram_api::account_saveAutoSaveSettings(flags, false /*ignored*/, false /*ignored*/, false /*ignored*/,
|
telegram_api::account_saveAutoSaveSettings(flags, false /*ignored*/, false /*ignored*/, false /*ignored*/,
|
||||||
@ -483,9 +478,8 @@ void AutosaveManager::set_autosave_settings(td_api::object_ptr<td_api::AutosaveS
|
|||||||
break;
|
break;
|
||||||
case td_api::autosaveSettingsScopeChat::ID:
|
case td_api::autosaveSettingsScopeChat::ID:
|
||||||
dialog_id = DialogId(static_cast<const td_api::autosaveSettingsScopeChat *>(scope.get())->chat_id_);
|
dialog_id = DialogId(static_cast<const td_api::autosaveSettingsScopeChat *>(scope.get())->chat_id_);
|
||||||
if (!td_->dialog_manager_->have_dialog_force(dialog_id, "set_autosave_settings")) {
|
TRY_STATUS_PROMISE(promise, td_->dialog_manager_->check_dialog_access(dialog_id, false, AccessRights::Read,
|
||||||
return promise.set_error(Status::Error(400, "Chat not found"));
|
"set_autosave_settings"));
|
||||||
}
|
|
||||||
old_settings = &settings_.exceptions_[dialog_id];
|
old_settings = &settings_.exceptions_[dialog_id];
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -126,9 +126,7 @@ class ToggleConnectedBotPausedQuery final : public Td::ResultHandler {
|
|||||||
void send(DialogId dialog_id, bool is_paused) {
|
void send(DialogId dialog_id, bool is_paused) {
|
||||||
dialog_id_ = dialog_id;
|
dialog_id_ = dialog_id;
|
||||||
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
|
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
|
||||||
if (input_peer == nullptr) {
|
CHECK(input_peer != nullptr);
|
||||||
return on_error(Status::Error(400, "Have no write access to the chat"));
|
|
||||||
}
|
|
||||||
send_query(G()->net_query_creator().create(
|
send_query(G()->net_query_creator().create(
|
||||||
telegram_api::account_toggleConnectedBotPaused(std::move(input_peer), is_paused), {{"me"}, {dialog_id}}));
|
telegram_api::account_toggleConnectedBotPaused(std::move(input_peer), is_paused), {{"me"}, {dialog_id}}));
|
||||||
}
|
}
|
||||||
@ -162,9 +160,7 @@ class DisablePeerConnectedBotQuery final : public Td::ResultHandler {
|
|||||||
void send(DialogId dialog_id) {
|
void send(DialogId dialog_id) {
|
||||||
dialog_id_ = dialog_id;
|
dialog_id_ = dialog_id;
|
||||||
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
|
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
|
||||||
if (input_peer == nullptr) {
|
CHECK(input_peer != nullptr);
|
||||||
return on_error(Status::Error(400, "Have no write access to the chat"));
|
|
||||||
}
|
|
||||||
send_query(G()->net_query_creator().create(telegram_api::account_disablePeerConnectedBot(std::move(input_peer)),
|
send_query(G()->net_query_creator().create(telegram_api::account_disablePeerConnectedBot(std::move(input_peer)),
|
||||||
{{"me"}, {dialog_id}}));
|
{{"me"}, {dialog_id}}));
|
||||||
}
|
}
|
||||||
@ -329,7 +325,8 @@ class ResolveBusinessChatLinkQuery final : public Td::ResultHandler {
|
|||||||
td_->user_manager_->on_get_users(std::move(ptr->users_), "ResolveBusinessChatLinkQuery");
|
td_->user_manager_->on_get_users(std::move(ptr->users_), "ResolveBusinessChatLinkQuery");
|
||||||
td_->chat_manager_->on_get_chats(std::move(ptr->chats_), "ResolveBusinessChatLinkQuery");
|
td_->chat_manager_->on_get_chats(std::move(ptr->chats_), "ResolveBusinessChatLinkQuery");
|
||||||
|
|
||||||
auto text = get_message_text(td_->user_manager_.get(), std::move(ptr->message_), std::move(ptr->entities_), true, true, 0, false, "ResolveBusinessChatLinkQuery");
|
auto text = get_message_text(td_->user_manager_.get(), std::move(ptr->message_), std::move(ptr->entities_), true,
|
||||||
|
true, 0, false, "ResolveBusinessChatLinkQuery");
|
||||||
if (text.text[0] == '@') {
|
if (text.text[0] == '@') {
|
||||||
text.text = ' ' + text.text;
|
text.text = ' ' + text.text;
|
||||||
for (auto &entity : text.entities) {
|
for (auto &entity : text.entities) {
|
||||||
@ -559,9 +556,9 @@ void BusinessManager::delete_business_connected_bot(UserId bot_user_id, Promise<
|
|||||||
|
|
||||||
void BusinessManager::toggle_business_connected_bot_dialog_is_paused(DialogId dialog_id, bool is_paused,
|
void BusinessManager::toggle_business_connected_bot_dialog_is_paused(DialogId dialog_id, bool is_paused,
|
||||||
Promise<Unit> &&promise) {
|
Promise<Unit> &&promise) {
|
||||||
if (!td_->messages_manager_->have_dialog_force(dialog_id, "toggle_business_connected_bot_dialog_is_paused")) {
|
TRY_STATUS_PROMISE(promise,
|
||||||
return promise.set_error(Status::Error(400, "Chat not found"));
|
td_->dialog_manager_->check_dialog_access(dialog_id, false, AccessRights::Write,
|
||||||
}
|
"toggle_business_connected_bot_dialog_is_paused"));
|
||||||
if (dialog_id.get_type() != DialogType::User) {
|
if (dialog_id.get_type() != DialogType::User) {
|
||||||
return promise.set_error(Status::Error(400, "The chat has no connected bot"));
|
return promise.set_error(Status::Error(400, "The chat has no connected bot"));
|
||||||
}
|
}
|
||||||
@ -570,9 +567,8 @@ void BusinessManager::toggle_business_connected_bot_dialog_is_paused(DialogId di
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BusinessManager::remove_business_connected_bot_from_dialog(DialogId dialog_id, Promise<Unit> &&promise) {
|
void BusinessManager::remove_business_connected_bot_from_dialog(DialogId dialog_id, Promise<Unit> &&promise) {
|
||||||
if (!td_->messages_manager_->have_dialog_force(dialog_id, "remove_business_connected_bot_from_dialog")) {
|
TRY_STATUS_PROMISE(promise, td_->dialog_manager_->check_dialog_access(dialog_id, false, AccessRights::Write,
|
||||||
return promise.set_error(Status::Error(400, "Chat not found"));
|
"remove_business_connected_bot_from_dialog"));
|
||||||
}
|
|
||||||
if (dialog_id.get_type() != DialogType::User) {
|
if (dialog_id.get_type() != DialogType::User) {
|
||||||
return promise.set_error(Status::Error(400, "The chat has no connected bot"));
|
return promise.set_error(Status::Error(400, "The chat has no connected bot"));
|
||||||
}
|
}
|
||||||
|
@ -114,9 +114,7 @@ class ExportChatInviteQuery final : public Td::ResultHandler {
|
|||||||
bool is_permanent) {
|
bool is_permanent) {
|
||||||
dialog_id_ = dialog_id;
|
dialog_id_ = dialog_id;
|
||||||
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
|
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
|
||||||
if (input_peer == nullptr) {
|
CHECK(input_peer != nullptr);
|
||||||
return on_error(Status::Error(400, "Can't access the chat"));
|
|
||||||
}
|
|
||||||
|
|
||||||
int32 flags = 0;
|
int32 flags = 0;
|
||||||
if (expire_date > 0) {
|
if (expire_date > 0) {
|
||||||
@ -180,9 +178,7 @@ class EditChatInviteLinkQuery final : public Td::ResultHandler {
|
|||||||
bool creates_join_request) {
|
bool creates_join_request) {
|
||||||
dialog_id_ = dialog_id;
|
dialog_id_ = dialog_id;
|
||||||
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
|
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
|
||||||
if (input_peer == nullptr) {
|
CHECK(input_peer != nullptr);
|
||||||
return on_error(Status::Error(400, "Can't access the chat"));
|
|
||||||
}
|
|
||||||
|
|
||||||
int32 flags = telegram_api::messages_editExportedChatInvite::EXPIRE_DATE_MASK |
|
int32 flags = telegram_api::messages_editExportedChatInvite::EXPIRE_DATE_MASK |
|
||||||
telegram_api::messages_editExportedChatInvite::USAGE_LIMIT_MASK |
|
telegram_api::messages_editExportedChatInvite::USAGE_LIMIT_MASK |
|
||||||
@ -235,9 +231,7 @@ class GetExportedChatInviteQuery final : public Td::ResultHandler {
|
|||||||
void send(DialogId dialog_id, const string &invite_link) {
|
void send(DialogId dialog_id, const string &invite_link) {
|
||||||
dialog_id_ = dialog_id;
|
dialog_id_ = dialog_id;
|
||||||
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
|
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
|
||||||
if (input_peer == nullptr) {
|
CHECK(input_peer != nullptr);
|
||||||
return on_error(Status::Error(400, "Can't access the chat"));
|
|
||||||
}
|
|
||||||
|
|
||||||
send_query(G()->net_query_creator().create(
|
send_query(G()->net_query_creator().create(
|
||||||
telegram_api::messages_getExportedChatInvite(std::move(input_peer), invite_link)));
|
telegram_api::messages_getExportedChatInvite(std::move(input_peer), invite_link)));
|
||||||
@ -286,9 +280,7 @@ class GetExportedChatInvitesQuery final : public Td::ResultHandler {
|
|||||||
const string &offset_invite_link, int32 limit) {
|
const string &offset_invite_link, int32 limit) {
|
||||||
dialog_id_ = dialog_id;
|
dialog_id_ = dialog_id;
|
||||||
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
|
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
|
||||||
if (input_peer == nullptr) {
|
CHECK(input_peer != nullptr);
|
||||||
return on_error(Status::Error(400, "Can't access the chat"));
|
|
||||||
}
|
|
||||||
|
|
||||||
int32 flags = 0;
|
int32 flags = 0;
|
||||||
if (!offset_invite_link.empty() || offset_date != 0) {
|
if (!offset_invite_link.empty() || offset_date != 0) {
|
||||||
@ -350,9 +342,7 @@ class GetChatAdminWithInvitesQuery final : public Td::ResultHandler {
|
|||||||
void send(DialogId dialog_id) {
|
void send(DialogId dialog_id) {
|
||||||
dialog_id_ = dialog_id;
|
dialog_id_ = dialog_id;
|
||||||
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
|
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
|
||||||
if (input_peer == nullptr) {
|
CHECK(input_peer != nullptr);
|
||||||
return on_error(Status::Error(400, "Can't access the chat"));
|
|
||||||
}
|
|
||||||
|
|
||||||
send_query(G()->net_query_creator().create(telegram_api::messages_getAdminsWithInvites(std::move(input_peer))));
|
send_query(G()->net_query_creator().create(telegram_api::messages_getAdminsWithInvites(std::move(input_peer))));
|
||||||
}
|
}
|
||||||
@ -400,9 +390,7 @@ class GetChatInviteImportersQuery final : public Td::ResultHandler {
|
|||||||
void send(DialogId dialog_id, const string &invite_link, int32 offset_date, UserId offset_user_id, int32 limit) {
|
void send(DialogId dialog_id, const string &invite_link, int32 offset_date, UserId offset_user_id, int32 limit) {
|
||||||
dialog_id_ = dialog_id;
|
dialog_id_ = dialog_id;
|
||||||
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
|
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
|
||||||
if (input_peer == nullptr) {
|
CHECK(input_peer != nullptr);
|
||||||
return on_error(Status::Error(400, "Can't access the chat"));
|
|
||||||
}
|
|
||||||
|
|
||||||
auto r_input_user = td_->user_manager_->get_input_user(offset_user_id);
|
auto r_input_user = td_->user_manager_->get_input_user(offset_user_id);
|
||||||
if (r_input_user.is_error()) {
|
if (r_input_user.is_error()) {
|
||||||
@ -466,9 +454,7 @@ class RevokeChatInviteLinkQuery final : public Td::ResultHandler {
|
|||||||
void send(DialogId dialog_id, const string &invite_link) {
|
void send(DialogId dialog_id, const string &invite_link) {
|
||||||
dialog_id_ = dialog_id;
|
dialog_id_ = dialog_id;
|
||||||
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
|
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
|
||||||
if (input_peer == nullptr) {
|
CHECK(input_peer != nullptr);
|
||||||
return on_error(Status::Error(400, "Can't access the chat"));
|
|
||||||
}
|
|
||||||
|
|
||||||
int32 flags = telegram_api::messages_editExportedChatInvite::REVOKED_MASK;
|
int32 flags = telegram_api::messages_editExportedChatInvite::REVOKED_MASK;
|
||||||
send_query(G()->net_query_creator().create(telegram_api::messages_editExportedChatInvite(
|
send_query(G()->net_query_creator().create(telegram_api::messages_editExportedChatInvite(
|
||||||
@ -541,9 +527,7 @@ class DeleteExportedChatInviteQuery final : public Td::ResultHandler {
|
|||||||
void send(DialogId dialog_id, const string &invite_link) {
|
void send(DialogId dialog_id, const string &invite_link) {
|
||||||
dialog_id_ = dialog_id;
|
dialog_id_ = dialog_id;
|
||||||
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
|
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
|
||||||
if (input_peer == nullptr) {
|
CHECK(input_peer != nullptr);
|
||||||
return on_error(Status::Error(400, "Can't access the chat"));
|
|
||||||
}
|
|
||||||
|
|
||||||
send_query(G()->net_query_creator().create(
|
send_query(G()->net_query_creator().create(
|
||||||
telegram_api::messages_deleteExportedChatInvite(std::move(input_peer), invite_link)));
|
telegram_api::messages_deleteExportedChatInvite(std::move(input_peer), invite_link)));
|
||||||
@ -575,9 +559,7 @@ class DeleteRevokedExportedChatInvitesQuery final : public Td::ResultHandler {
|
|||||||
void send(DialogId dialog_id, tl_object_ptr<telegram_api::InputUser> &&input_user) {
|
void send(DialogId dialog_id, tl_object_ptr<telegram_api::InputUser> &&input_user) {
|
||||||
dialog_id_ = dialog_id;
|
dialog_id_ = dialog_id;
|
||||||
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
|
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
|
||||||
if (input_peer == nullptr) {
|
CHECK(input_peer != nullptr);
|
||||||
return on_error(Status::Error(400, "Can't access the chat"));
|
|
||||||
}
|
|
||||||
|
|
||||||
send_query(G()->net_query_creator().create(
|
send_query(G()->net_query_creator().create(
|
||||||
telegram_api::messages_deleteRevokedExportedChatInvites(std::move(input_peer), std::move(input_user))));
|
telegram_api::messages_deleteRevokedExportedChatInvites(std::move(input_peer), std::move(input_user))));
|
||||||
@ -923,9 +905,8 @@ void DialogInviteLinkManager::remove_dialog_access_by_invite_link(DialogId dialo
|
|||||||
}
|
}
|
||||||
|
|
||||||
Status DialogInviteLinkManager::can_manage_dialog_invite_links(DialogId dialog_id, bool creator_only) {
|
Status DialogInviteLinkManager::can_manage_dialog_invite_links(DialogId dialog_id, bool creator_only) {
|
||||||
if (!td_->dialog_manager_->have_dialog_force(dialog_id, "can_manage_dialog_invite_links")) {
|
TRY_STATUS(td_->dialog_manager_->check_dialog_access(dialog_id, false, AccessRights::Write,
|
||||||
return Status::Error(400, "Chat not found");
|
"can_manage_dialog_invite_links"));
|
||||||
}
|
|
||||||
|
|
||||||
switch (dialog_id.get_type()) {
|
switch (dialog_id.get_type()) {
|
||||||
case DialogType::User:
|
case DialogType::User:
|
||||||
|
@ -97,9 +97,7 @@ class GetChatJoinRequestsQuery final : public Td::ResultHandler {
|
|||||||
invite_link.empty() && query.empty() && offset_date == 0 && !offset_user_id.is_valid() && limit >= 3;
|
invite_link.empty() && query.empty() && offset_date == 0 && !offset_user_id.is_valid() && limit >= 3;
|
||||||
|
|
||||||
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
|
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
|
||||||
if (input_peer == nullptr) {
|
CHECK(input_peer != nullptr);
|
||||||
return on_error(Status::Error(400, "Can't access the chat"));
|
|
||||||
}
|
|
||||||
|
|
||||||
auto r_input_user = td_->user_manager_->get_input_user(offset_user_id);
|
auto r_input_user = td_->user_manager_->get_input_user(offset_user_id);
|
||||||
if (r_input_user.is_error()) {
|
if (r_input_user.is_error()) {
|
||||||
@ -174,9 +172,7 @@ class HideChatJoinRequestQuery final : public Td::ResultHandler {
|
|||||||
void send(DialogId dialog_id, UserId user_id, bool approve) {
|
void send(DialogId dialog_id, UserId user_id, bool approve) {
|
||||||
dialog_id_ = dialog_id;
|
dialog_id_ = dialog_id;
|
||||||
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
|
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
|
||||||
if (input_peer == nullptr) {
|
CHECK(input_peer != nullptr);
|
||||||
return on_error(Status::Error(400, "Can't access the chat"));
|
|
||||||
}
|
|
||||||
|
|
||||||
TRY_RESULT_PROMISE(promise_, input_user, td_->user_manager_->get_input_user(user_id));
|
TRY_RESULT_PROMISE(promise_, input_user, td_->user_manager_->get_input_user(user_id));
|
||||||
|
|
||||||
@ -216,9 +212,7 @@ class HideAllChatJoinRequestsQuery final : public Td::ResultHandler {
|
|||||||
void send(DialogId dialog_id, const string &invite_link, bool approve) {
|
void send(DialogId dialog_id, const string &invite_link, bool approve) {
|
||||||
dialog_id_ = dialog_id;
|
dialog_id_ = dialog_id;
|
||||||
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
|
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Write);
|
||||||
if (input_peer == nullptr) {
|
CHECK(input_peer != nullptr);
|
||||||
return on_error(Status::Error(400, "Can't access the chat"));
|
|
||||||
}
|
|
||||||
|
|
||||||
int32 flags = 0;
|
int32 flags = 0;
|
||||||
if (approve) {
|
if (approve) {
|
||||||
@ -1063,9 +1057,8 @@ void DialogParticipantManager::update_dialog_online_member_count(const vector<Di
|
|||||||
}
|
}
|
||||||
|
|
||||||
Status DialogParticipantManager::can_manage_dialog_join_requests(DialogId dialog_id) {
|
Status DialogParticipantManager::can_manage_dialog_join_requests(DialogId dialog_id) {
|
||||||
if (!td_->dialog_manager_->have_dialog_force(dialog_id, "can_manage_dialog_join_requests")) {
|
TRY_STATUS(td_->dialog_manager_->check_dialog_access(dialog_id, false, AccessRights::Write,
|
||||||
return Status::Error(400, "Chat not found");
|
"can_manage_dialog_join_requests"));
|
||||||
}
|
|
||||||
|
|
||||||
switch (dialog_id.get_type()) {
|
switch (dialog_id.get_type()) {
|
||||||
case DialogType::SecretChat:
|
case DialogType::SecretChat:
|
||||||
|
@ -683,9 +683,8 @@ void StatisticsManager::send_get_channel_stats_query(DcId dc_id, ChannelId chann
|
|||||||
|
|
||||||
void StatisticsManager::get_channel_revenue_statistics(
|
void StatisticsManager::get_channel_revenue_statistics(
|
||||||
DialogId dialog_id, bool is_dark, Promise<td_api::object_ptr<td_api::chatRevenueStatistics>> &&promise) {
|
DialogId dialog_id, bool is_dark, Promise<td_api::object_ptr<td_api::chatRevenueStatistics>> &&promise) {
|
||||||
if (!td_->dialog_manager_->have_dialog_force(dialog_id, "get_channel_revenue_statistics")) {
|
TRY_STATUS_PROMISE(promise, td_->dialog_manager_->check_dialog_access(dialog_id, false, AccessRights::Write,
|
||||||
return promise.set_error(Status::Error(400, "Chat not found"));
|
"get_channel_revenue_statistics"));
|
||||||
}
|
|
||||||
if (!td_->dialog_manager_->is_broadcast_channel(dialog_id)) {
|
if (!td_->dialog_manager_->is_broadcast_channel(dialog_id)) {
|
||||||
return promise.set_error(Status::Error(400, "Chat is not a channel"));
|
return promise.set_error(Status::Error(400, "Chat is not a channel"));
|
||||||
}
|
}
|
||||||
@ -694,9 +693,8 @@ void StatisticsManager::get_channel_revenue_statistics(
|
|||||||
|
|
||||||
void StatisticsManager::get_channel_revenue_withdrawal_url(DialogId dialog_id, const string &password,
|
void StatisticsManager::get_channel_revenue_withdrawal_url(DialogId dialog_id, const string &password,
|
||||||
Promise<string> &&promise) {
|
Promise<string> &&promise) {
|
||||||
if (!td_->dialog_manager_->have_dialog_force(dialog_id, "get_channel_revenue_withdrawal_url")) {
|
TRY_STATUS_PROMISE(promise, td_->dialog_manager_->check_dialog_access(dialog_id, false, AccessRights::Write,
|
||||||
return promise.set_error(Status::Error(400, "Chat not found"));
|
"get_channel_revenue_withdrawal_url"));
|
||||||
}
|
|
||||||
if (!td_->dialog_manager_->is_broadcast_channel(dialog_id)) {
|
if (!td_->dialog_manager_->is_broadcast_channel(dialog_id)) {
|
||||||
return promise.set_error(Status::Error(400, "Chat is not a channel"));
|
return promise.set_error(Status::Error(400, "Chat is not a channel"));
|
||||||
}
|
}
|
||||||
@ -731,9 +729,8 @@ void StatisticsManager::send_get_channel_revenue_withdrawal_url_query(
|
|||||||
void StatisticsManager::get_channel_revenue_transactions(
|
void StatisticsManager::get_channel_revenue_transactions(
|
||||||
DialogId dialog_id, int32 offset, int32 limit,
|
DialogId dialog_id, int32 offset, int32 limit,
|
||||||
Promise<td_api::object_ptr<td_api::chatRevenueTransactions>> &&promise) {
|
Promise<td_api::object_ptr<td_api::chatRevenueTransactions>> &&promise) {
|
||||||
if (!td_->dialog_manager_->have_dialog_force(dialog_id, "get_channel_revenue_transactions")) {
|
TRY_STATUS_PROMISE(promise, td_->dialog_manager_->check_dialog_access(dialog_id, false, AccessRights::Write,
|
||||||
return promise.set_error(Status::Error(400, "Chat not found"));
|
"get_channel_revenue_transactions"));
|
||||||
}
|
|
||||||
if (!td_->dialog_manager_->is_broadcast_channel(dialog_id)) {
|
if (!td_->dialog_manager_->is_broadcast_channel(dialog_id)) {
|
||||||
return promise.set_error(Status::Error(400, "Chat is not a channel"));
|
return promise.set_error(Status::Error(400, "Chat is not a channel"));
|
||||||
}
|
}
|
||||||
|
@ -103,12 +103,10 @@ class ResetTopPeerRatingQuery final : public Td::ResultHandler {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
void send(TopDialogCategory category, DialogId dialog_id) {
|
void send(TopDialogCategory category, DialogId dialog_id) {
|
||||||
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Read);
|
|
||||||
if (input_peer == nullptr) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
dialog_id_ = dialog_id;
|
dialog_id_ = dialog_id;
|
||||||
|
|
||||||
|
auto input_peer = td_->dialog_manager_->get_input_peer(dialog_id, AccessRights::Read);
|
||||||
|
CHECK(input_peer != nullptr);
|
||||||
send_query(G()->net_query_creator().create(
|
send_query(G()->net_query_creator().create(
|
||||||
telegram_api::contacts_resetTopPeerRating(get_input_top_peer_category(category), std::move(input_peer))));
|
telegram_api::contacts_resetTopPeerRating(get_input_top_peer_category(category), std::move(input_peer))));
|
||||||
}
|
}
|
||||||
@ -240,9 +238,8 @@ void TopDialogManager::remove_dialog(TopDialogCategory category, DialogId dialog
|
|||||||
if (category == TopDialogCategory::Size) {
|
if (category == TopDialogCategory::Size) {
|
||||||
return promise.set_error(Status::Error(400, "Top chat category must be non-empty"));
|
return promise.set_error(Status::Error(400, "Top chat category must be non-empty"));
|
||||||
}
|
}
|
||||||
if (!td_->dialog_manager_->have_dialog_force(dialog_id, "remove_dialog")) {
|
TRY_STATUS_PROMISE(promise,
|
||||||
return promise.set_error(Status::Error(400, "Chat not found"));
|
td_->dialog_manager_->check_dialog_access(dialog_id, false, AccessRights::Read, "remove_dialog"));
|
||||||
}
|
|
||||||
CHECK(!td_->auth_manager_->is_bot());
|
CHECK(!td_->auth_manager_->is_bot());
|
||||||
if (!is_enabled_) {
|
if (!is_enabled_) {
|
||||||
return promise.set_value(Unit());
|
return promise.set_value(Unit());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user