From 62fbb88969210576213f67d4393cfcea759d2d22 Mon Sep 17 00:00:00 2001 From: levlam Date: Sun, 18 Oct 2020 01:26:36 +0300 Subject: [PATCH] Rename blockChatFromReplies to blockMessageSenderFromReplies. GitOrigin-RevId: 820cbd60145c339c6cf5a7d319ff540ce03861e2 --- td/generate/scheme/td_api.tl | 2 +- td/generate/scheme/td_api.tlo | Bin 183824 -> 183832 bytes td/telegram/MessagesManager.cpp | 49 ++++++++++++++++++-------------- td/telegram/MessagesManager.h | 14 ++++----- td/telegram/Td.cpp | 7 +++-- td/telegram/Td.h | 2 +- td/telegram/TdDb.cpp | 2 +- td/telegram/cli.cpp | 4 +-- td/telegram/logevent/LogEvent.h | 2 +- 9 files changed, 44 insertions(+), 38 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 9ebf37532..76fd33bb9 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -4244,7 +4244,7 @@ sendCallDebugInformation call_id:int32 debug_information:string = Ok; //@delete_message Pass true if the message must be deleted //@delete_all_messages Pass true if all messages from the same sender must be deleted //@report_spam Pass true if the sender must be reported to the Telegram moderators -blockChatFromReplies message_id:int53 delete_message:Bool delete_all_messages:Bool report_spam:Bool = Ok; +blockMessageSenderFromReplies message_id:int53 delete_message:Bool delete_all_messages:Bool report_spam:Bool = Ok; //@description Returns chats that were blocked by the current user @offset Number of chats to skip in the result; must be non-negative @limit The maximum number of chats to return; up to 100 getBlockedChats offset:int32 limit:int32 = Chats; diff --git a/td/generate/scheme/td_api.tlo b/td/generate/scheme/td_api.tlo index f458a0dc76b75f95c528af827dff30ead528335c..b5bb32777fefd220afebe3ef4269a8339f82da61 100644 GIT binary patch delta 69 zcmV-L0J{H>oC}zo3xI?Hv;vqJEsOP?w;f_^Z)0msWpi_3XJu1mZe(S0Msja$Qe|*# bX=QT&0BOGM)Y--oOaznRk1Mz683HJ@>b@OE delta 46 zcmbO+hkL>t?uHh|Ele{crIsWaoDoUN$xqI9&PXhAE6UFeN-fCAOf6>EzDtrRZVLdN Cj}fE* diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index b97e13f94..9ba993f74 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -15659,8 +15659,9 @@ void MessagesManager::on_get_common_dialogs(UserId user_id, int32 offset_chat_id common_dialogs.total_count = total_count; } -void MessagesManager::block_dialog_from_replies(MessageId message_id, bool delete_message, bool delete_all_messages, - bool report_spam, Promise &&promise) { +void MessagesManager::block_message_sender_from_replies(MessageId message_id, bool delete_message, + bool delete_all_messages, bool report_spam, + Promise &&promise) { auto dialog_id = DialogId(ContactsManager::get_replies_bot_user_id()); Dialog *d = get_dialog_force(dialog_id); if (d == nullptr) { @@ -15670,7 +15671,7 @@ void MessagesManager::block_dialog_from_replies(MessageId message_id, bool delet return promise.set_error(Status::Error(400, "Not enough rights")); } - auto *m = get_message_force(d, message_id, "block_dialog_from_replies"); + auto *m = get_message_force(d, message_id, "block_message_sender_from_replies"); if (m == nullptr) { return promise.set_error(Status::Error(400, "Message not found")); } @@ -15685,7 +15686,7 @@ void MessagesManager::block_dialog_from_replies(MessageId message_id, bool delet bool need_update_dialog_pos = false; vector deleted_message_ids; if (delete_message) { - auto p = this->delete_message(d, message_id, true, &need_update_dialog_pos, "block_dialog_from_replies"); + auto p = this->delete_message(d, message_id, true, &need_update_dialog_pos, "block_message_sender_from_replies"); CHECK(p.get() == m); deleted_message_ids.push_back(p->message_id.get()); } @@ -15696,22 +15697,23 @@ void MessagesManager::block_dialog_from_replies(MessageId message_id, bool delet }); for (auto user_message_id : message_ids) { - auto p = this->delete_message(d, user_message_id, true, &need_update_dialog_pos, "block_dialog_from_replies 2"); + auto p = this->delete_message(d, user_message_id, true, &need_update_dialog_pos, + "block_message_sender_from_replies 2"); deleted_message_ids.push_back(p->message_id.get()); } } if (need_update_dialog_pos) { - send_update_chat_last_message(d, "block_dialog_from_replies"); + send_update_chat_last_message(d, "block_message_sender_from_replies"); } send_update_delete_messages(dialog_id, std::move(deleted_message_ids), true, false); - block_dialog_from_replies_on_server(message_id, delete_message, delete_all_messages, report_spam, 0, - std::move(promise)); + block_message_sender_from_replies_on_server(message_id, delete_message, delete_all_messages, report_spam, 0, + std::move(promise)); } -class MessagesManager::BlockDialogFromRepliesOnServerLogEvent { +class MessagesManager::BlockMessageSenderFromRepliesOnServerLogEvent { public: MessageId message_id_; bool delete_message_; @@ -15741,19 +15743,21 @@ class MessagesManager::BlockDialogFromRepliesOnServerLogEvent { } }; -uint64 MessagesManager::save_block_dialog_from_replies_on_server_log_event(MessageId message_id, bool delete_message, - bool delete_all_messages, bool report_spam) { - BlockDialogFromRepliesOnServerLogEvent log_event{message_id, delete_message, delete_all_messages, report_spam}; - return binlog_add(G()->td_db()->get_binlog(), LogEvent::HandlerType::BlockDialogFromRepliesOnServer, +uint64 MessagesManager::save_block_message_sender_from_replies_on_server_log_event(MessageId message_id, + bool delete_message, + bool delete_all_messages, + bool report_spam) { + BlockMessageSenderFromRepliesOnServerLogEvent log_event{message_id, delete_message, delete_all_messages, report_spam}; + return binlog_add(G()->td_db()->get_binlog(), LogEvent::HandlerType::BlockMessageSenderFromRepliesOnServer, get_log_event_storer(log_event)); } -void MessagesManager::block_dialog_from_replies_on_server(MessageId message_id, bool delete_message, - bool delete_all_messages, bool report_spam, - uint64 log_event_id, Promise &&promise) { +void MessagesManager::block_message_sender_from_replies_on_server(MessageId message_id, bool delete_message, + bool delete_all_messages, bool report_spam, + uint64 log_event_id, Promise &&promise) { if (log_event_id == 0) { - log_event_id = save_block_dialog_from_replies_on_server_log_event(message_id, delete_message, delete_all_messages, - report_spam); + log_event_id = save_block_message_sender_from_replies_on_server_log_event(message_id, delete_message, + delete_all_messages, report_spam); } td_->create_handler(get_erase_log_event_promise(log_event_id, std::move(promise))) @@ -34924,12 +34928,13 @@ void MessagesManager::on_binlog_events(vector &&events) { log_event.revoke_, true, event.id_, Auto()); break; } - case LogEvent::HandlerType::BlockDialogFromRepliesOnServer: { - BlockDialogFromRepliesOnServerLogEvent log_event; + case LogEvent::HandlerType::BlockMessageSenderFromRepliesOnServer: { + BlockMessageSenderFromRepliesOnServerLogEvent log_event; log_event_parse(log_event, event.data_).ensure(); - block_dialog_from_replies_on_server(log_event.message_id_, log_event.delete_message_, - log_event.delete_all_messages_, log_event.report_spam_, event.id_, Auto()); + block_message_sender_from_replies_on_server(log_event.message_id_, log_event.delete_message_, + log_event.delete_all_messages_, log_event.report_spam_, event.id_, + Auto()); break; } case LogEvent::HandlerType::DeleteAllChannelMessagesFromUserOnServer: { diff --git a/td/telegram/MessagesManager.h b/td/telegram/MessagesManager.h index 2b6df2a0c..029b9cc28 100644 --- a/td/telegram/MessagesManager.h +++ b/td/telegram/MessagesManager.h @@ -561,8 +561,8 @@ class MessagesManager : public Actor { std::pair> get_common_dialogs(UserId user_id, DialogId offset_dialog_id, int32 limit, bool force, Promise &&promise); - void block_dialog_from_replies(MessageId message_id, bool delete_message, bool delete_all_messages, bool report_spam, - Promise &&promise); + void block_message_sender_from_replies(MessageId message_id, bool delete_message, bool delete_all_messages, + bool report_spam, Promise &&promise); std::pair> get_blocked_dialogs(int32 offset, int32 limit, int64 &random_id, Promise &&promise); @@ -1611,7 +1611,7 @@ class MessagesManager : public Actor { } }; - class BlockDialogFromRepliesOnServerLogEvent; + class BlockMessageSenderFromRepliesOnServerLogEvent; class ChangeDialogReportSpamStateOnServerLogEvent; class DeleteAllChannelMessagesFromUserOnServerLogEvent; class DeleteDialogHistoryFromServerLogEvent; @@ -1905,8 +1905,8 @@ class MessagesManager : public Actor { void delete_dialog_history_from_server(DialogId dialog_id, MessageId max_message_id, bool remove_from_dialog_list, bool revoke, bool allow_error, uint64 log_event_id, Promise &&promise); - void block_dialog_from_replies_on_server(MessageId message_id, bool delete_message, bool delete_all_messages, - bool report_spam, uint64 log_event_id, Promise &&promise); + void block_message_sender_from_replies_on_server(MessageId message_id, bool delete_message, bool delete_all_messages, + bool report_spam, uint64 log_event_id, Promise &&promise); void delete_all_channel_messages_from_user_on_server(ChannelId channel_id, UserId user_id, uint64 log_event_id, Promise &&promise); @@ -2879,8 +2879,8 @@ class MessagesManager : public Actor { uint64 save_delete_dialog_history_from_server_log_event(DialogId dialog_id, MessageId max_message_id, bool remove_from_dialog_list, bool revoke); - uint64 save_block_dialog_from_replies_on_server_log_event(MessageId message_id, bool delete_message, - bool delete_all_messages, bool report_spam); + uint64 save_block_message_sender_from_replies_on_server_log_event(MessageId message_id, bool delete_message, + bool delete_all_messages, bool report_spam); uint64 save_delete_all_channel_messages_from_user_on_server_log_event(ChannelId channel_id, UserId user_id); diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index b04ae819e..4465e013a 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -6413,11 +6413,12 @@ void Td::on_request(uint64 id, const td_api::deleteFile &request) { "td_api::deleteFile"); } -void Td::on_request(uint64 id, const td_api::blockChatFromReplies &request) { +void Td::on_request(uint64 id, const td_api::blockMessageSenderFromReplies &request) { CHECK_IS_USER(); CREATE_OK_REQUEST_PROMISE(); - messages_manager_->block_dialog_from_replies(MessageId(request.message_id_), request.delete_message_, - request.delete_all_messages_, request.report_spam_, std::move(promise)); + messages_manager_->block_message_sender_from_replies(MessageId(request.message_id_), request.delete_message_, + request.delete_all_messages_, request.report_spam_, + std::move(promise)); } void Td::on_request(uint64 id, const td_api::getBlockedChats &request) { diff --git a/td/telegram/Td.h b/td/telegram/Td.h index cbed223c8..86a61fb93 100644 --- a/td/telegram/Td.h +++ b/td/telegram/Td.h @@ -787,7 +787,7 @@ class Td final : public NetQueryCallback { void on_request(uint64 id, const td_api::deleteFile &request); - void on_request(uint64 id, const td_api::blockChatFromReplies &request); + void on_request(uint64 id, const td_api::blockMessageSenderFromReplies &request); void on_request(uint64 id, const td_api::getBlockedChats &request); diff --git a/td/telegram/TdDb.cpp b/td/telegram/TdDb.cpp index f828a04a9..7990932b9 100644 --- a/td/telegram/TdDb.cpp +++ b/td/telegram/TdDb.cpp @@ -114,7 +114,7 @@ Status init_binlog(Binlog &binlog, string path, BinlogKeyValue &binlog_p case LogEvent::HandlerType::DeleteScheduledMessagesFromServer: case LogEvent::HandlerType::ToggleDialogIsBlockedOnServer: case LogEvent::HandlerType::ReadMessageThreadHistoryOnServer: - case LogEvent::HandlerType::BlockDialogFromRepliesOnServer: + case LogEvent::HandlerType::BlockMessageSenderFromRepliesOnServer: events.to_messages_manager.push_back(event.clone()); break; case LogEvent::HandlerType::AddMessagePushNotification: diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index dd77bf381..0e0af2721 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -2944,7 +2944,7 @@ class CliClient final : public Actor { string is_blocked; std::tie(chat_id, is_blocked) = split(args); send_request(td_api::make_object(as_chat_id(chat_id), as_bool(is_blocked))); - } else if (op == "bcfr") { + } else if (op == "bmsfr") { string message_id; string delete_message; string delete_all_messages; @@ -2952,7 +2952,7 @@ class CliClient final : public Actor { std::tie(message_id, args) = split(args); std::tie(delete_message, args) = split(args); std::tie(delete_all_messages, report_spam) = split(args); - send_request(td_api::make_object( + send_request(td_api::make_object( as_message_id(message_id), as_bool(delete_message), as_bool(delete_all_messages), as_bool(report_spam))); } else if (op == "tcddn") { string chat_id; diff --git a/td/telegram/logevent/LogEvent.h b/td/telegram/logevent/LogEvent.h index 73a25dc7b..f0685f193 100644 --- a/td/telegram/logevent/LogEvent.h +++ b/td/telegram/logevent/LogEvent.h @@ -98,7 +98,7 @@ class LogEvent { DeleteScheduledMessagesFromServer = 0x117, ToggleDialogIsBlockedOnServer = 0x118, ReadMessageThreadHistoryOnServer = 0x119, - BlockDialogFromRepliesOnServer = 0x120, + BlockMessageSenderFromRepliesOnServer = 0x120, GetChannelDifference = 0x140, AddMessagePushNotification = 0x200, EditMessagePushNotification = 0x201,