Allow to pass message thread identifier to readAllChatReactions.
This commit is contained in:
parent
df561b7822
commit
75739dd0ea
@ -5507,11 +5507,11 @@ getExternalLinkInfo link:string = LoginUrlInfo;
|
||||
getExternalLink link:string allow_write_access:Bool = HttpUrl;
|
||||
|
||||
|
||||
//@description Marks all mentions in a chat as read @chat_id Chat identifier @message_thread_id If not 0, a message thread identifier in mentions are marked as read; for forum supergroups only
|
||||
//@description Marks all mentions in a chat as read @chat_id Chat identifier @message_thread_id If not 0, a message thread identifier in which mentions are marked as read; for forum supergroups only
|
||||
readAllChatMentions chat_id:int53 message_thread_id:int53 = Ok;
|
||||
|
||||
//@description Marks all reactions in a chat as read @chat_id Chat identifier
|
||||
readAllChatReactions chat_id:int53 = Ok;
|
||||
//@description Marks all reactions in a chat as read @chat_id Chat identifier @message_thread_id If not 0, a message thread identifier in which reactions are marked as read; for forum supergroups only
|
||||
readAllChatReactions chat_id:int53 message_thread_id:int53 = Ok;
|
||||
|
||||
|
||||
//@description Returns an existing chat corresponding to a given user @user_id User identifier @force Pass true to create the chat without a network request. In this case all information about the chat except its type, title and photo can be incorrect
|
||||
|
@ -3267,7 +3267,7 @@ class ReadReactionsQuery final : public Td::ResultHandler {
|
||||
explicit ReadReactionsQuery(Promise<AffectedHistory> &&promise) : promise_(std::move(promise)) {
|
||||
}
|
||||
|
||||
void send(DialogId dialog_id) {
|
||||
void send(DialogId dialog_id, MessageId top_thread_message_id) {
|
||||
dialog_id_ = dialog_id;
|
||||
|
||||
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Read);
|
||||
@ -3276,8 +3276,13 @@ class ReadReactionsQuery final : public Td::ResultHandler {
|
||||
}
|
||||
|
||||
int32 flags = 0;
|
||||
send_query(G()->net_query_creator().create(telegram_api::messages_readReactions(flags, std::move(input_peer), 0),
|
||||
{{dialog_id}}));
|
||||
if (top_thread_message_id.is_valid()) {
|
||||
flags |= telegram_api::messages_readReactions::TOP_MSG_ID_MASK;
|
||||
}
|
||||
send_query(G()->net_query_creator().create(
|
||||
telegram_api::messages_readReactions(flags, std::move(input_peer),
|
||||
top_thread_message_id.get_server_message_id().get()),
|
||||
{{dialog_id}}));
|
||||
}
|
||||
|
||||
void on_result(BufferSlice packet) final {
|
||||
@ -12126,17 +12131,32 @@ void MessagesManager::read_all_dialog_mentions_on_server(DialogId dialog_id, uin
|
||||
get_erase_log_event_promise(log_event_id, std::move(promise)));
|
||||
}
|
||||
|
||||
void MessagesManager::read_all_dialog_reactions(DialogId dialog_id, Promise<Unit> &&promise) {
|
||||
void MessagesManager::read_all_dialog_reactions(DialogId dialog_id, MessageId top_thread_message_id,
|
||||
Promise<Unit> &&promise) {
|
||||
Dialog *d = get_dialog_force(dialog_id, "read_all_dialog_reactions");
|
||||
if (d == nullptr) {
|
||||
return promise.set_error(Status::Error(400, "Chat not found"));
|
||||
}
|
||||
|
||||
LOG(INFO) << "Receive readAllChatReactions request in " << dialog_id << " with " << d->unread_reaction_count
|
||||
<< " unread reactions";
|
||||
TRY_STATUS_PROMISE(promise, can_use_top_thread_message_id(d, top_thread_message_id, MessageId()));
|
||||
|
||||
if (!have_input_peer(dialog_id, AccessRights::Read)) {
|
||||
return promise.set_error(Status::Error(400, "Chat is not accessible"));
|
||||
}
|
||||
|
||||
if (top_thread_message_id.is_valid()) {
|
||||
LOG(INFO) << "Receive readAllChatReactions request in thread of " << top_thread_message_id << " in " << dialog_id;
|
||||
AffectedHistoryQuery query = [td = td_, top_thread_message_id](DialogId dialog_id,
|
||||
Promise<AffectedHistory> &&query_promise) {
|
||||
td->create_handler<ReadReactionsQuery>(std::move(query_promise))->send(dialog_id, top_thread_message_id);
|
||||
};
|
||||
run_affected_history_query_until_complete(dialog_id, std::move(query), true, std::move(promise));
|
||||
return;
|
||||
} else {
|
||||
LOG(INFO) << "Receive readAllChatReactions request in " << dialog_id << " with " << d->unread_reaction_count
|
||||
<< " unread reactions";
|
||||
}
|
||||
|
||||
if (dialog_id.get_type() == DialogType::SecretChat) {
|
||||
CHECK(d->unread_reaction_count == 0);
|
||||
return promise.set_value(Unit());
|
||||
@ -12204,7 +12224,7 @@ void MessagesManager::read_all_dialog_reactions_on_server(DialogId dialog_id, ui
|
||||
}
|
||||
|
||||
AffectedHistoryQuery query = [td = td_](DialogId dialog_id, Promise<AffectedHistory> &&query_promise) {
|
||||
td->create_handler<ReadReactionsQuery>(std::move(query_promise))->send(dialog_id);
|
||||
td->create_handler<ReadReactionsQuery>(std::move(query_promise))->send(dialog_id, MessageId());
|
||||
};
|
||||
run_affected_history_query_until_complete(dialog_id, std::move(query), false,
|
||||
get_erase_log_event_promise(log_event_id, std::move(promise)));
|
||||
|
@ -414,7 +414,7 @@ class MessagesManager final : public Actor {
|
||||
|
||||
void read_all_dialog_mentions(DialogId dialog_id, MessageId top_thread_message_id, Promise<Unit> &&promise);
|
||||
|
||||
void read_all_dialog_reactions(DialogId dialog_id, Promise<Unit> &&promise);
|
||||
void read_all_dialog_reactions(DialogId dialog_id, MessageId top_thread_message_id, Promise<Unit> &&promise);
|
||||
|
||||
Status add_recently_found_dialog(DialogId dialog_id) TD_WARN_UNUSED_RESULT;
|
||||
|
||||
|
@ -5335,7 +5335,8 @@ void Td::on_request(uint64 id, const td_api::readAllChatMentions &request) {
|
||||
void Td::on_request(uint64 id, const td_api::readAllChatReactions &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
messages_manager_->read_all_dialog_reactions(DialogId(request.chat_id_), std::move(promise));
|
||||
messages_manager_->read_all_dialog_reactions(DialogId(request.chat_id_), MessageId(request.message_thread_id_),
|
||||
std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::getChatAvailableMessageSenders &request) {
|
||||
|
@ -4758,8 +4758,9 @@ class CliClient final : public Actor {
|
||||
send_request(td_api::make_object<td_api::readAllChatMentions>(chat_id, as_message_thread_id(message_thread_id)));
|
||||
} else if (op == "racr") {
|
||||
ChatId chat_id;
|
||||
get_args(args, chat_id);
|
||||
send_request(td_api::make_object<td_api::readAllChatReactions>(chat_id));
|
||||
string message_thread_id;
|
||||
get_args(args, chat_id, message_thread_id);
|
||||
send_request(td_api::make_object<td_api::readAllChatReactions>(chat_id, as_message_thread_id(message_thread_id)));
|
||||
} else if (op == "tre") {
|
||||
send_request(td_api::make_object<td_api::testReturnError>(
|
||||
args.empty() ? nullptr : td_api::make_object<td_api::error>(-1, args)));
|
||||
|
Loading…
Reference in New Issue
Block a user