Replace getBlockedChats with getBlockedMessageSenders.

GitOrigin-RevId: 044f70ab823b8302dddc8b7a128f19514306272a
This commit is contained in:
levlam 2020-10-18 02:10:58 +03:00
parent 0834d6164b
commit 27f63e9e2e
7 changed files with 42 additions and 16 deletions

View File

@ -624,6 +624,10 @@ messageSenderUser user_id:int32 = MessageSender;
messageSenderChat chat_id:int53 = MessageSender;
//@description Represents a list of message senders @total_count Approximate total count of messages senders found @senders List of message senders
messageSenders total_count:int32 senders:vector<MessageSender> = MessageSenders;
//@class MessageForwardOrigin @description Contains information about the origin of a forwarded message
//@description The message was originally sent by a known user @sender_user_id Identifier of the user that originally sent the message
@ -4246,8 +4250,8 @@ toggleMessageSenderIsBlocked sender:MessageSender is_blocked:Bool = Ok;
//@report_spam Pass true if the sender must be reported to the Telegram moderators
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;
//@description Returns users and chats that were blocked by the current user @offset Number of users and chats to skip in the result; must be non-negative @limit The maximum number of users and chats to return; up to 100
getBlockedMessageSenders offset:int32 limit:int32 = MessageSenders;
//@description Adds a user to the contact list or edits an existing contact by their user identifier @contact The contact to add or edit; phone number can be empty and needs to be specified only if known, vCard is ignored

Binary file not shown.

View File

@ -5545,6 +5545,13 @@ td_api::object_ptr<td_api::MessageSender> MessagesManager::get_message_sender_ob
td_->contacts_manager_->get_user_id_object(user_id, "get_message_sender_object"));
}
td_api::object_ptr<td_api::MessageSender> MessagesManager::get_message_sender_object(DialogId dialog_id) const {
if (dialog_id.get_type() == DialogType::User) {
return get_message_sender_object(dialog_id.get_user_id(), DialogId());
}
return get_message_sender_object(UserId(), dialog_id);
}
BufferSlice MessagesManager::get_dialog_database_value(const Dialog *d) {
// can't use log_event_store, because it tries to parse stored Dialog
LogEventStorerCalcLength storer_calc_length;
@ -15810,11 +15817,19 @@ void MessagesManager::on_get_blocked_dialogs(int32 offset, int32 limit, int64 ra
for (auto &blocked_peer : blocked_peers) {
CHECK(blocked_peer != nullptr);
DialogId dialog_id(blocked_peer->peer_id_);
force_create_dialog(dialog_id, "on_get_blocked_dialogs");
if (have_dialog(dialog_id)) {
result.push_back(dialog_id);
if (dialog_id.get_type() == DialogType::User) {
if (td_->contacts_manager_->have_user(dialog_id.get_user_id())) {
result.push_back(dialog_id);
} else {
LOG(ERROR) << "Have no info about " << dialog_id.get_user_id();
}
} else {
LOG(ERROR) << "Have no info about " << dialog_id;
force_create_dialog(dialog_id, "on_get_blocked_dialogs");
if (have_dialog(dialog_id)) {
result.push_back(dialog_id);
} else {
LOG(ERROR) << "Have no info about " << dialog_id;
}
}
}
if (!result.empty() && offset + result.size() > static_cast<size_t>(total_count)) {

View File

@ -192,6 +192,8 @@ class MessagesManager : public Actor {
td_api::object_ptr<td_api::MessageSender> get_message_sender_object(UserId user_id, DialogId dialog_id) const;
td_api::object_ptr<td_api::MessageSender> get_message_sender_object(DialogId dialog_id) const;
static vector<MessageId> get_message_ids(const vector<int64> &input_message_ids);
static vector<int32> get_server_message_ids(const vector<MessageId> &message_ids);

View File

@ -2094,23 +2094,27 @@ class GetChatEventLogRequest : public RequestOnceActor {
}
};
class GetBlockedChatsRequest : public RequestActor<> {
class GetBlockedMessageSendersRequest : public RequestActor<> {
int32 offset_;
int32 limit_;
int64 random_id_;
std::pair<int32, vector<DialogId>> dialog_ids_;
std::pair<int32, vector<DialogId>> message_senders_;
void do_run(Promise<Unit> &&promise) override {
dialog_ids_ = td->messages_manager_->get_blocked_dialogs(offset_, limit_, random_id_, std::move(promise));
message_senders_ = td->messages_manager_->get_blocked_dialogs(offset_, limit_, random_id_, std::move(promise));
}
void do_send_result() override {
send_result(MessagesManager::get_chats_object(dialog_ids_));
auto senders =
transform(message_senders_.second, [messages_manager = td->messages_manager_.get()](DialogId dialog_id) {
return messages_manager->get_message_sender_object(dialog_id);
});
send_result(td_api::make_object<td_api::messageSenders>(message_senders_.first, std::move(senders)));
}
public:
GetBlockedChatsRequest(ActorShared<Td> td, uint64 request_id, int32 offset, int32 limit)
GetBlockedMessageSendersRequest(ActorShared<Td> td, uint64 request_id, int32 offset, int32 limit)
: RequestActor(std::move(td), request_id), offset_(offset), limit_(limit), random_id_(0) {
}
};
@ -6421,9 +6425,9 @@ void Td::on_request(uint64 id, const td_api::blockMessageSenderFromReplies &requ
std::move(promise));
}
void Td::on_request(uint64 id, const td_api::getBlockedChats &request) {
void Td::on_request(uint64 id, const td_api::getBlockedMessageSenders &request) {
CHECK_IS_USER();
CREATE_REQUEST(GetBlockedChatsRequest, request.offset_, request.limit_);
CREATE_REQUEST(GetBlockedMessageSendersRequest, request.offset_, request.limit_);
}
void Td::on_request(uint64 id, td_api::addContact &request) {

View File

@ -789,7 +789,7 @@ class Td final : public NetQueryCallback {
void on_request(uint64 id, const td_api::blockMessageSenderFromReplies &request);
void on_request(uint64 id, const td_api::getBlockedChats &request);
void on_request(uint64 id, const td_api::getBlockedMessageSenders &request);
void on_request(uint64 id, td_api::addContact &request);

View File

@ -2312,7 +2312,7 @@ class CliClient final : public Actor {
send_request(td_api::make_object<td_api::getDeepLinkInfo>(args));
} else if (op == "tme") {
send_request(td_api::make_object<td_api::getRecentlyVisitedTMeUrls>(args));
} else if (op == "gbc") {
} else if (op == "gbms") {
string offset;
string limit;
@ -2323,7 +2323,8 @@ class CliClient final : public Actor {
if (limit.empty()) {
limit = "10";
}
send_request(td_api::make_object<td_api::getBlockedChats>(to_integer<int32>(offset), to_integer<int32>(limit)));
send_request(
td_api::make_object<td_api::getBlockedMessageSenders>(to_integer<int32>(offset), to_integer<int32>(limit)));
} else if (op == "gu") {
send_request(td_api::make_object<td_api::getUser>(as_user_id(args)));
} else if (op == "gsu") {