Remove ChatReportSpamState and methods for it.

GitOrigin-RevId: 3de0cb0147ad70e4d540f5a61f1aa08c64423edd
This commit is contained in:
levlam 2019-10-11 03:36:26 +03:00
parent 825cb0dd0b
commit 378ed2c659
7 changed files with 1 additions and 113 deletions

View File

@ -2349,9 +2349,6 @@ connectedWebsite id:int64 domain_name:string bot_user_id:int32 browser:string pl
connectedWebsites websites:vector<connectedWebsite> = ConnectedWebsites;
//@description Contains information about the availability of the "Report spam" action for a chat @can_report_spam True, if a prompt with the "Report spam" action should be shown to the user
chatReportSpamState can_report_spam:Bool = ChatReportSpamState;
//@class ChatReportReason @description Describes the reason why a chat is reported
//@description The chat contains spam messages
@ -3901,12 +3898,6 @@ getAccountTtl = AccountTtl;
deleteAccount reason:string = Ok;
//@description Returns information on whether the current chat can be reported as spam @chat_id Chat identifier
getChatReportSpamState chat_id:int53 = ChatReportSpamState;
//@description Reports to the server whether a chat is a spam chat or not. Can be used only if ChatReportSpamState.can_report_spam is true. After this request, ChatReportSpamState.can_report_spam becomes false forever @chat_id Chat identifier @is_spam_chat If true, the chat will be reported as spam; otherwise it will be marked as not spam
changeChatReportSpamState chat_id:int53 is_spam_chat:Bool = Ok;
//@description Removes a chat action bar without any other action @chat_id Chat identifier
removeChatActionBar chat_id:int53 = Ok;

Binary file not shown.

View File

@ -3176,13 +3176,9 @@ class ResetNotifySettingsQuery : public Td::ResultHandler {
};
class GetPeerSettingsQuery : public Td::ResultHandler {
Promise<Unit> promise_;
DialogId dialog_id_;
public:
explicit GetPeerSettingsQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
}
void send(DialogId dialog_id) {
dialog_id_ = dialog_id;
@ -3200,14 +3196,11 @@ class GetPeerSettingsQuery : public Td::ResultHandler {
}
td->messages_manager_->on_get_peer_settings(dialog_id_, result_ptr.move_as_ok());
promise_.set_value(Unit());
}
void on_error(uint64 id, Status status) override {
LOG(INFO) << "Receive error for get peer settings: " << status;
td->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetPeerSettingsQuery");
promise_.set_error(std::move(status));
}
};
@ -6453,7 +6446,7 @@ void MessagesManager::repair_dialog_action_bar(DialogId dialog_id) {
return;
}
return td_->create_handler<GetPeerSettingsQuery>(Promise<Unit>())->send(dialog_id);
return td_->create_handler<GetPeerSettingsQuery>()->send(dialog_id);
case DialogType::SecretChat:
case DialogType::None:
default:
@ -6461,55 +6454,6 @@ void MessagesManager::repair_dialog_action_bar(DialogId dialog_id) {
}
}
bool MessagesManager::get_dialog_report_spam_state(DialogId dialog_id, Promise<Unit> &&promise) {
Dialog *d = get_dialog_force(dialog_id);
if (d == nullptr) {
promise.set_error(Status::Error(3, "Chat not found"));
return false;
}
if (d->know_can_report_spam) {
promise.set_value(Unit());
return d->can_report_spam;
}
switch (dialog_id.get_type()) {
case DialogType::User:
case DialogType::Chat:
case DialogType::Channel:
td_->create_handler<GetPeerSettingsQuery>(std::move(promise))->send(dialog_id);
return false;
case DialogType::SecretChat:
promise.set_value(Unit());
return false;
case DialogType::None:
default:
UNREACHABLE();
return false;
}
}
void MessagesManager::change_dialog_report_spam_state(DialogId dialog_id, bool is_spam_dialog,
Promise<Unit> &&promise) {
Dialog *d = get_dialog_force(dialog_id);
if (d == nullptr) {
return promise.set_error(Status::Error(3, "Chat not found"));
}
if (!have_input_peer(dialog_id, AccessRights::Read)) {
return promise.set_error(Status::Error(3, "Can't access the chat"));
}
if (!d->know_can_report_spam || !d->can_report_spam) {
return promise.set_error(Status::Error(3, "Can't update chat report spam state"));
}
d->can_report_spam = false;
on_dialog_updated(dialog_id, "change_dialog_report_spam_state");
change_dialog_report_spam_state_on_server(dialog_id, is_spam_dialog, 0, std::move(promise));
}
void MessagesManager::remove_dialog_action_bar(DialogId dialog_id, Promise<Unit> &&promise) {
Dialog *d = get_dialog_force(dialog_id);
if (d == nullptr) {

View File

@ -663,10 +663,6 @@ class MessagesManager : public Actor {
void on_update_scope_notify_settings(NotificationSettingsScope scope,
tl_object_ptr<telegram_api::peerNotifySettings> &&peer_notify_settings);
bool get_dialog_report_spam_state(DialogId dialog_id, Promise<Unit> &&promise);
void change_dialog_report_spam_state(DialogId dialog_id, bool is_spam_dialog, Promise<Unit> &&promise);
void remove_dialog_action_bar(DialogId dialog_id, Promise<Unit> &&promise);
void report_dialog(DialogId dialog_id, const tl_object_ptr<td_api::ChatReportReason> &reason,

View File

@ -2325,25 +2325,6 @@ class GetScopeNotificationSettingsRequest : public RequestActor<> {
}
};
class GetChatReportSpamStateRequest : public RequestActor<> {
DialogId dialog_id_;
bool can_report_spam_ = false;
void do_run(Promise<Unit> &&promise) override {
can_report_spam_ = td->messages_manager_->get_dialog_report_spam_state(dialog_id_, std::move(promise));
}
void do_send_result() override {
send_result(make_tl_object<td_api::chatReportSpamState>(can_report_spam_));
}
public:
GetChatReportSpamStateRequest(ActorShared<Td> td, uint64 request_id, int64 dialog_id)
: RequestActor(std::move(td), request_id), dialog_id_(dialog_id) {
}
};
class GetStickersRequest : public RequestActor<> {
string emoji_;
int32 limit_;
@ -6676,18 +6657,6 @@ void Td::on_request(uint64 id, const td_api::getScopeNotificationSettings &reque
CREATE_REQUEST(GetScopeNotificationSettingsRequest, get_notification_settings_scope(request.scope_));
}
void Td::on_request(uint64 id, const td_api::getChatReportSpamState &request) {
CHECK_IS_USER();
CREATE_REQUEST(GetChatReportSpamStateRequest, request.chat_id_);
}
void Td::on_request(uint64 id, const td_api::changeChatReportSpamState &request) {
CHECK_IS_USER();
CREATE_OK_REQUEST_PROMISE();
messages_manager_->change_dialog_report_spam_state(DialogId(request.chat_id_), request.is_spam_chat_,
std::move(promise));
}
void Td::on_request(uint64 id, const td_api::removeChatActionBar &request) {
CHECK_IS_USER();
CREATE_OK_REQUEST_PROMISE();

View File

@ -844,10 +844,6 @@ class Td final : public NetQueryCallback {
void on_request(uint64 id, const td_api::resetAllNotificationSettings &request);
void on_request(uint64 id, const td_api::getChatReportSpamState &request);
void on_request(uint64 id, const td_api::changeChatReportSpamState &request);
void on_request(uint64 id, const td_api::removeChatActionBar &request);
void on_request(uint64 id, td_api::reportChat &request);

View File

@ -3618,14 +3618,6 @@ class CliClient final : public Actor {
std::tie(group_id, max_notification_id) = split(args);
send_request(td_api::make_object<td_api::removeNotificationGroup>(to_integer<int32>(group_id),
to_integer<int32>(max_notification_id)));
} else if (op == "gcrss") {
send_request(td_api::make_object<td_api::getChatReportSpamState>(as_chat_id(args)));
} else if (op == "ccrss") {
string chat_id;
string is_spam_chat;
std::tie(chat_id, is_spam_chat) = split(args);
send_request(td_api::make_object<td_api::changeChatReportSpamState>(as_chat_id(chat_id), as_bool(is_spam_chat)));
} else if (op == "rcab") {
string chat_id = args;
send_request(td_api::make_object<td_api::removeChatActionBar>(as_chat_id(chat_id)));