Add removeChatActionBar.

GitOrigin-RevId: 865c60b541cdfdc1465ab4814e1ca8c2c9ff0c49
This commit is contained in:
levlam 2019-10-11 03:28:41 +03:00
parent 62db4169a2
commit 825cb0dd0b
7 changed files with 50 additions and 3 deletions

View File

@ -3907,6 +3907,9 @@ 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;
//@description Reports a chat to the Telegram moderators. Supported only for supergroups, channels, or private chats with bots, since other chats can't be checked by moderators @chat_id Chat identifier @reason The reason for reporting the chat @message_ids Identifiers of reported messages, if any
reportChat chat_id:int53 reason:ChatReportReason message_ids:vector<int53> = Ok;

Binary file not shown.

View File

@ -3223,7 +3223,9 @@ class UpdatePeerSettingsQuery : public Td::ResultHandler {
dialog_id_ = dialog_id;
auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read);
CHECK(input_peer != nullptr);
if (input_peer == nullptr) {
return promise_.set_value(Unit());
}
if (is_spam_dialog) {
send_query(
@ -6508,6 +6510,35 @@ void MessagesManager::change_dialog_report_spam_state(DialogId dialog_id, bool i
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) {
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) {
return promise.set_error(Status::Error(3, "Can't update chat action bar"));
}
if (!d->can_report_spam && !d->can_add_contact && !d->can_block_user && !d->can_share_phone_number &&
!d->can_report_location) {
return promise.set_value(Unit());
}
d->can_report_spam = false;
d->can_add_contact = false;
d->can_block_user = false;
d->can_share_phone_number = false;
d->can_report_location = false;
on_dialog_updated(dialog_id, "remove_dialog_action_bar");
change_dialog_report_spam_state_on_server(dialog_id, false, 0, std::move(promise));
}
class MessagesManager::ChangeDialogReportSpamStateOnServerLogEvent {
public:
DialogId dialog_id_;
@ -6551,8 +6582,8 @@ void MessagesManager::change_dialog_report_spam_state_on_server(DialogId dialog_
if (is_spam_dialog) {
return td_->create_handler<ReportEncryptedSpamQuery>(std::move(promise))->send(dialog_id);
} else {
promise.set_value(Unit());
return;
auto user_id = td_->contacts_manager_->get_secret_chat_user_id(dialog_id.get_secret_chat_id());
return td_->create_handler<UpdatePeerSettingsQuery>(std::move(promise))->send(DialogId(user_id), false);
}
case DialogType::None:
default:

View File

@ -667,6 +667,8 @@ class MessagesManager : public Actor {
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,
const vector<MessageId> &message_ids, Promise<Unit> &&promise);

View File

@ -6688,6 +6688,12 @@ void Td::on_request(uint64 id, const td_api::changeChatReportSpamState &request)
std::move(promise));
}
void Td::on_request(uint64 id, const td_api::removeChatActionBar &request) {
CHECK_IS_USER();
CREATE_OK_REQUEST_PROMISE();
messages_manager_->remove_dialog_action_bar(DialogId(request.chat_id_), std::move(promise));
}
void Td::on_request(uint64 id, td_api::reportChat &request) {
CHECK_IS_USER();
CREATE_OK_REQUEST_PROMISE();

View File

@ -848,6 +848,8 @@ class Td final : public NetQueryCallback {
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);
void on_request(uint64 id, td_api::getChatStatisticsUrl &request);

View File

@ -3626,6 +3626,9 @@ class CliClient final : public Actor {
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)));
} else if (op == "rc") {
string chat_id;
string reason_str;