Rename blockChatFromReplies to blockMessageSenderFromReplies.

GitOrigin-RevId: 820cbd60145c339c6cf5a7d319ff540ce03861e2
This commit is contained in:
levlam 2020-10-18 01:26:36 +03:00
parent 2915129cd8
commit 62fbb88969
9 changed files with 44 additions and 38 deletions

View File

@ -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;

Binary file not shown.

View File

@ -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<Unit> &&promise) {
void MessagesManager::block_message_sender_from_replies(MessageId message_id, bool delete_message,
bool delete_all_messages, bool report_spam,
Promise<Unit> &&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<int64> 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<Unit> &&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<Unit> &&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<BlockFromRepliesQuery>(get_erase_log_event_promise(log_event_id, std::move(promise)))
@ -34924,12 +34928,13 @@ void MessagesManager::on_binlog_events(vector<BinlogEvent> &&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: {

View File

@ -561,8 +561,8 @@ class MessagesManager : public Actor {
std::pair<int32, vector<DialogId>> get_common_dialogs(UserId user_id, DialogId offset_dialog_id, int32 limit,
bool force, Promise<Unit> &&promise);
void block_dialog_from_replies(MessageId message_id, bool delete_message, bool delete_all_messages, bool report_spam,
Promise<Unit> &&promise);
void block_message_sender_from_replies(MessageId message_id, bool delete_message, bool delete_all_messages,
bool report_spam, Promise<Unit> &&promise);
std::pair<int32, vector<DialogId>> get_blocked_dialogs(int32 offset, int32 limit, int64 &random_id,
Promise<Unit> &&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<Unit> &&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<Unit> &&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<Unit> &&promise);
void delete_all_channel_messages_from_user_on_server(ChannelId channel_id, UserId user_id, uint64 log_event_id,
Promise<Unit> &&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);

View File

@ -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) {

View File

@ -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);

View File

@ -114,7 +114,7 @@ Status init_binlog(Binlog &binlog, string path, BinlogKeyValue<Binlog> &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:

View File

@ -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<td_api::toggleChatIsBlocked>(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<td_api::blockChatFromReplies>(
send_request(td_api::make_object<td_api::blockMessageSenderFromReplies>(
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;

View File

@ -98,7 +98,7 @@ class LogEvent {
DeleteScheduledMessagesFromServer = 0x117,
ToggleDialogIsBlockedOnServer = 0x118,
ReadMessageThreadHistoryOnServer = 0x119,
BlockDialogFromRepliesOnServer = 0x120,
BlockMessageSenderFromRepliesOnServer = 0x120,
GetChannelDifference = 0x140,
AddMessagePushNotification = 0x200,
EditMessagePushNotification = 0x201,