Add td_api::deleteSavedMessagesTopicHistory.
This commit is contained in:
parent
40f8bffec8
commit
93370af38d
@ -7172,6 +7172,9 @@ getSavedMessagesTopics offset:string limit:int32 = FoundSavedMessagesTopics;
|
||||
//-For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit
|
||||
getSavedMessagesTopicHistory saved_messages_topic:SavedMessagesTopic from_message_id:int53 offset:int32 limit:int32 = Messages;
|
||||
|
||||
//@description Deletes all messages in a Saved Messages topic @saved_messages_topic Saved Messages topic which messages will be deleted
|
||||
deleteSavedMessagesTopicHistory saved_messages_topic:SavedMessagesTopic = Ok;
|
||||
|
||||
|
||||
//@description Returns a list of common group chats with a given user. Chats are sorted by their type and creation date
|
||||
//@user_id User identifier
|
||||
|
@ -261,7 +261,7 @@ class GetSavedHistoryQuery final : public Td::ResultHandler {
|
||||
|
||||
void send(SavedMessagesTopicId saved_messages_topic_id, MessageId from_message_id, int32 offset, int32 limit) {
|
||||
saved_messages_topic_id_ = saved_messages_topic_id;
|
||||
telegram_api::object_ptr<telegram_api::InputPeer> saved_input_peer = saved_messages_topic_id.get_input_peer(td_);
|
||||
auto saved_input_peer = saved_messages_topic_id.get_input_peer(td_);
|
||||
CHECK(saved_input_peer != nullptr);
|
||||
send_query(G()->net_query_creator().create(telegram_api::messages_getSavedHistory(
|
||||
std::move(saved_input_peer), from_message_id.get_server_message_id().get(), 0, offset, limit, 0, 0, 0)));
|
||||
@ -2463,6 +2463,36 @@ class DeleteChannelHistoryQuery final : public Td::ResultHandler {
|
||||
}
|
||||
};
|
||||
|
||||
class DeleteSavedHistoryQuery final : public Td::ResultHandler {
|
||||
Promise<AffectedHistory> promise_;
|
||||
|
||||
public:
|
||||
explicit DeleteSavedHistoryQuery(Promise<AffectedHistory> &&promise) : promise_(std::move(promise)) {
|
||||
}
|
||||
|
||||
void send(SavedMessagesTopicId saved_messages_topic_id) {
|
||||
auto saved_input_peer = saved_messages_topic_id.get_input_peer(td_);
|
||||
CHECK(saved_input_peer != nullptr);
|
||||
|
||||
int32 flags = 0;
|
||||
send_query(G()->net_query_creator().create(telegram_api::messages_deleteSavedHistory(
|
||||
flags, std::move(saved_input_peer), std::numeric_limits<int32>::max(), 0, 0)));
|
||||
}
|
||||
|
||||
void on_result(BufferSlice packet) final {
|
||||
auto result_ptr = fetch_result<telegram_api::messages_deleteSavedHistory>(packet);
|
||||
if (result_ptr.is_error()) {
|
||||
return on_error(result_ptr.move_as_error());
|
||||
}
|
||||
|
||||
promise_.set_value(AffectedHistory(result_ptr.move_as_ok()));
|
||||
}
|
||||
|
||||
void on_error(Status status) final {
|
||||
promise_.set_error(std::move(status));
|
||||
}
|
||||
};
|
||||
|
||||
class DeleteMessagesByDateQuery final : public Td::ResultHandler {
|
||||
Promise<AffectedHistory> promise_;
|
||||
DialogId dialog_id_;
|
||||
@ -16117,10 +16147,10 @@ void MessagesManager::get_saved_messages_topic_history(SavedMessagesTopicId save
|
||||
return promise.set_error(Status::Error(400, "Parameter offset must be greater than or equal to -limit"));
|
||||
}
|
||||
|
||||
auto my_dialog_id = td_->dialog_manager_->get_my_dialog_id();
|
||||
if (!saved_messages_topic_id.is_valid()) {
|
||||
return promise.set_error(Status::Error(400, "Invalid Saved Messages topic specified"));
|
||||
}
|
||||
auto my_dialog_id = td_->dialog_manager_->get_my_dialog_id();
|
||||
TRY_STATUS_PROMISE(promise, saved_messages_topic_id.is_valid_in(td_, my_dialog_id));
|
||||
|
||||
if (from_message_id == MessageId() || from_message_id.get() > MessageId::max().get()) {
|
||||
@ -16134,6 +16164,21 @@ void MessagesManager::get_saved_messages_topic_history(SavedMessagesTopicId save
|
||||
->send(saved_messages_topic_id, from_message_id, offset, limit);
|
||||
}
|
||||
|
||||
void MessagesManager::delete_saved_messages_topic_history(SavedMessagesTopicId saved_messages_topic_id,
|
||||
Promise<Unit> &&promise) {
|
||||
if (!saved_messages_topic_id.is_valid()) {
|
||||
return promise.set_error(Status::Error(400, "Invalid Saved Messages topic specified"));
|
||||
}
|
||||
auto my_dialog_id = td_->dialog_manager_->get_my_dialog_id();
|
||||
TRY_STATUS_PROMISE(promise, saved_messages_topic_id.is_valid_in(td_, my_dialog_id));
|
||||
|
||||
AffectedHistoryQuery query = [td = td_, saved_messages_topic_id](DialogId dialog_id,
|
||||
Promise<AffectedHistory> &&query_promise) {
|
||||
td->create_handler<DeleteSavedHistoryQuery>(std::move(query_promise))->send(saved_messages_topic_id);
|
||||
};
|
||||
run_affected_history_query_until_complete(my_dialog_id, std::move(query), true, std::move(promise));
|
||||
}
|
||||
|
||||
vector<DialogId> MessagesManager::search_public_dialogs(const string &query, Promise<Unit> &&promise) {
|
||||
LOG(INFO) << "Search public chats with query = \"" << query << '"';
|
||||
|
||||
|
@ -541,6 +541,8 @@ class MessagesManager final : public Actor {
|
||||
int32 offset, int32 limit,
|
||||
Promise<td_api::object_ptr<td_api::messages>> &&promise);
|
||||
|
||||
void delete_saved_messages_topic_history(SavedMessagesTopicId saved_messages_topic_id, Promise<Unit> &&promise);
|
||||
|
||||
vector<DialogId> search_public_dialogs(const string &query, Promise<Unit> &&promise);
|
||||
|
||||
std::pair<int32, vector<DialogId>> search_dialogs(const string &query, int32 limit, Promise<Unit> &&promise);
|
||||
|
@ -5042,6 +5042,13 @@ void Td::on_request(uint64 id, const td_api::getSavedMessagesTopicHistory &reque
|
||||
request.limit_, std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::deleteSavedMessagesTopicHistory &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
messages_manager_->delete_saved_messages_topic_history(SavedMessagesTopicId(this, request.saved_messages_topic_),
|
||||
std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::searchPublicChat &request) {
|
||||
CLEAN_INPUT_STRING(request.username_);
|
||||
CREATE_REQUEST(SearchPublicChatRequest, request.username_);
|
||||
|
@ -677,6 +677,8 @@ class Td final : public Actor {
|
||||
|
||||
void on_request(uint64 id, const td_api::getSavedMessagesTopicHistory &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::deleteSavedMessagesTopicHistory &request);
|
||||
|
||||
void on_request(uint64 id, td_api::searchPublicChat &request);
|
||||
|
||||
void on_request(uint64 id, td_api::searchPublicChats &request);
|
||||
|
@ -2764,6 +2764,8 @@ class CliClient final : public Actor {
|
||||
get_args(args, from_message_id, offset, limit);
|
||||
send_request(td_api::make_object<td_api::getSavedMessagesTopicHistory>(get_saved_messages_topic(),
|
||||
from_message_id, offset, as_limit(limit)));
|
||||
} else if (op == "dsmth" && args.empty()) {
|
||||
send_request(td_api::make_object<td_api::deleteSavedMessagesTopicHistory>(get_saved_messages_topic()));
|
||||
} else if (op == "gcc" || op == "GetCommonChats") {
|
||||
UserId user_id;
|
||||
ChatId offset_chat_id;
|
||||
|
Loading…
Reference in New Issue
Block a user