Allow to specify message_ids in td_api::reportSpam.
GitOrigin-RevId: c77dcd89e58c38ac218204230620513c2cdda60d
This commit is contained in:
parent
1e0a051439
commit
b5036975b8
@ -1,6 +1,6 @@
|
|||||||
cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
|
cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
|
||||||
|
|
||||||
project(TDLib VERSION 1.1.3 LANGUAGES CXX C)
|
project(TDLib VERSION 1.1.4 LANGUAGES CXX C)
|
||||||
|
|
||||||
option(TD_ENABLE_JNI "Use \"ON\" to enable JNI-compatible TDLib API.")
|
option(TD_ENABLE_JNI "Use \"ON\" to enable JNI-compatible TDLib API.")
|
||||||
option(TD_ENABLE_DOTNET "Use \"ON\" to enable generation of C++/CLI or C++/CX TDLib API bindings.")
|
option(TD_ENABLE_DOTNET "Use \"ON\" to enable generation of C++/CLI or C++/CX TDLib API bindings.")
|
||||||
|
@ -107,7 +107,7 @@ target_link_libraries(YourTarget PRIVATE Td::TdStatic)
|
|||||||
|
|
||||||
Or you could install `TDLib` and then reference it in your CMakeLists.txt like this:
|
Or you could install `TDLib` and then reference it in your CMakeLists.txt like this:
|
||||||
```
|
```
|
||||||
find_package(Td 1.1.3 REQUIRED)
|
find_package(Td 1.1.4 REQUIRED)
|
||||||
target_link_libraries(YourTarget PRIVATE Td::TdStatic)
|
target_link_libraries(YourTarget PRIVATE Td::TdStatic)
|
||||||
```
|
```
|
||||||
See [example/cpp/CMakeLists.txt](https://github.com/tdlib/td/tree/master/example/cpp/CMakeLists.txt).
|
See [example/cpp/CMakeLists.txt](https://github.com/tdlib/td/tree/master/example/cpp/CMakeLists.txt).
|
||||||
|
@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
|
|||||||
|
|
||||||
project(TdExample VERSION 1.0 LANGUAGES CXX)
|
project(TdExample VERSION 1.0 LANGUAGES CXX)
|
||||||
|
|
||||||
find_package(Td 1.1.3 REQUIRED)
|
find_package(Td 1.1.4 REQUIRED)
|
||||||
|
|
||||||
add_executable(tdjson_example tdjson_example.cpp)
|
add_executable(tdjson_example tdjson_example.cpp)
|
||||||
target_link_libraries(tdjson_example PRIVATE Td::TdJson)
|
target_link_libraries(tdjson_example PRIVATE Td::TdJson)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011">
|
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011">
|
||||||
<Metadata>
|
<Metadata>
|
||||||
<Identity Id="TDLib.UWP" Version="1.1.3" Language="en-US" Publisher="Telegram team" />
|
<Identity Id="TDLib.UWP" Version="1.1.4" Language="en-US" Publisher="Telegram team" />
|
||||||
<DisplayName>TDLib for Universal Windows Platform</DisplayName>
|
<DisplayName>TDLib for Universal Windows Platform</DisplayName>
|
||||||
<Description>TDLib is a library for building Telegram clients</Description>
|
<Description>TDLib is a library for building Telegram clients</Description>
|
||||||
<MoreInfo>https://core.telegram.org/tdlib</MoreInfo>
|
<MoreInfo>https://core.telegram.org/tdlib</MoreInfo>
|
||||||
|
@ -2758,8 +2758,8 @@ getChatReportSpamState chat_id:int53 = ChatReportSpamState;
|
|||||||
//@description Used to let the server know whether a chat is spam or not. Can be used only if ChatReportSpamState.can_report_spam is true. After this request, ChatReportSpamState.can_report_spam becomes false forever @chat_id Chat identifier @is_spam_chat If true, the chat will be reported as spam; otherwise it will be marked as not spam
|
//@description Used to let the server know whether a chat is spam or not. Can be used only if ChatReportSpamState.can_report_spam is true. After this request, ChatReportSpamState.can_report_spam becomes false forever @chat_id Chat identifier @is_spam_chat If true, the chat will be reported as spam; otherwise it will be marked as not spam
|
||||||
changeChatReportSpamState chat_id:int53 is_spam_chat:Bool = Ok;
|
changeChatReportSpamState chat_id:int53 is_spam_chat:Bool = Ok;
|
||||||
|
|
||||||
//@description Reports a chat to the Telegram moderators. Supported only for supergroups, channels, or private chats with bots, since other chats can't be checked by moderators @chat_id Chat identifier @reason The reason for reporting the chat
|
//@description Reports a chat to the Telegram moderators. Supported only for supergroups, channels, or private chats with bots, since other chats can't be checked by moderators @chat_id Chat identifier @reason The reason for reporting the chat @message_ids Identifiers of reported messages, if any
|
||||||
reportChat chat_id:int53 reason:ChatReportReason = Ok;
|
reportChat chat_id:int53 reason:ChatReportReason message_ids:vector<int53> = Ok;
|
||||||
|
|
||||||
|
|
||||||
//@description Returns storage usage statistics @chat_limit Maximum number of chats with the largest storage usage for which separate statistics should be returned. All other chats will be grouped in entries with chat_id == 0. If the chat info database is not used, the chat_limit is ignored and is always set to 0
|
//@description Returns storage usage statistics @chat_limit Maximum number of chats with the largest storage usage for which separate statistics should be returned. All other chats will be grouped in entries with chat_id == 0. If the chat info database is not used, the chat_limit is ignored and is always set to 0
|
||||||
|
Binary file not shown.
@ -3125,17 +3125,26 @@ class ReportPeerQuery : public Td::ResultHandler {
|
|||||||
explicit ReportPeerQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
|
explicit ReportPeerQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void send(DialogId dialog_id, tl_object_ptr<telegram_api::ReportReason> &&report_reason) {
|
void send(DialogId dialog_id, tl_object_ptr<telegram_api::ReportReason> &&report_reason,
|
||||||
|
const vector<MessageId> &message_ids) {
|
||||||
dialog_id_ = dialog_id;
|
dialog_id_ = dialog_id;
|
||||||
|
|
||||||
auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read);
|
auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read);
|
||||||
CHECK(input_peer != nullptr);
|
CHECK(input_peer != nullptr);
|
||||||
|
|
||||||
|
if (message_ids.empty()) {
|
||||||
send_query(G()->net_query_creator().create(
|
send_query(G()->net_query_creator().create(
|
||||||
create_storer(telegram_api::account_reportPeer(std::move(input_peer), std::move(report_reason)))));
|
create_storer(telegram_api::account_reportPeer(std::move(input_peer), std::move(report_reason)))));
|
||||||
|
} else {
|
||||||
|
send_query(G()->net_query_creator().create(create_storer(telegram_api::messages_report(
|
||||||
|
std::move(input_peer), MessagesManager::get_server_message_ids(message_ids), std::move(report_reason)))));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_result(uint64 id, BufferSlice packet) override {
|
void on_result(uint64 id, BufferSlice packet) override {
|
||||||
|
static_assert(
|
||||||
|
std::is_same<telegram_api::account_reportPeer::ReturnType, telegram_api::messages_report::ReturnType>::value,
|
||||||
|
"");
|
||||||
auto result_ptr = fetch_result<telegram_api::account_reportPeer>(packet);
|
auto result_ptr = fetch_result<telegram_api::account_reportPeer>(packet);
|
||||||
if (result_ptr.is_error()) {
|
if (result_ptr.is_error()) {
|
||||||
return on_error(id, result_ptr.move_as_error());
|
return on_error(id, result_ptr.move_as_error());
|
||||||
@ -6060,7 +6069,7 @@ void MessagesManager::change_dialog_report_spam_state(DialogId dialog_id, bool i
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MessagesManager::report_dialog(DialogId dialog_id, const tl_object_ptr<td_api::ChatReportReason> &reason,
|
void MessagesManager::report_dialog(DialogId dialog_id, const tl_object_ptr<td_api::ChatReportReason> &reason,
|
||||||
Promise<Unit> &&promise) {
|
const vector<MessageId> &message_ids, Promise<Unit> &&promise) {
|
||||||
Dialog *d = get_dialog_force(dialog_id);
|
Dialog *d = get_dialog_force(dialog_id);
|
||||||
if (d == nullptr) {
|
if (d == nullptr) {
|
||||||
return promise.set_error(Status::Error(3, "Chat not found"));
|
return promise.set_error(Status::Error(3, "Chat not found"));
|
||||||
@ -6093,6 +6102,13 @@ void MessagesManager::report_dialog(DialogId dialog_id, const tl_object_ptr<td_a
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vector<MessageId> server_message_ids;
|
||||||
|
for (auto message_id : message_ids) {
|
||||||
|
if (message_id.is_valid() && message_id.is_server()) {
|
||||||
|
server_message_ids.push_back(message_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tl_object_ptr<telegram_api::ReportReason> report_reason;
|
tl_object_ptr<telegram_api::ReportReason> report_reason;
|
||||||
switch (reason->get_id()) {
|
switch (reason->get_id()) {
|
||||||
case td_api::chatReportReasonSpam::ID:
|
case td_api::chatReportReasonSpam::ID:
|
||||||
@ -6119,7 +6135,8 @@ void MessagesManager::report_dialog(DialogId dialog_id, const tl_object_ptr<td_a
|
|||||||
}
|
}
|
||||||
CHECK(report_reason != nullptr);
|
CHECK(report_reason != nullptr);
|
||||||
|
|
||||||
td_->create_handler<ReportPeerQuery>(std::move(promise))->send(dialog_id, std::move(report_reason));
|
td_->create_handler<ReportPeerQuery>(std::move(promise))
|
||||||
|
->send(dialog_id, std::move(report_reason), server_message_ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessagesManager::on_get_peer_settings(DialogId dialog_id,
|
void MessagesManager::on_get_peer_settings(DialogId dialog_id,
|
||||||
|
@ -1268,7 +1268,7 @@ class MessagesManager : public Actor {
|
|||||||
void change_dialog_report_spam_state(DialogId dialog_id, bool is_spam_dialog, Promise<Unit> &&promise);
|
void change_dialog_report_spam_state(DialogId dialog_id, bool is_spam_dialog, Promise<Unit> &&promise);
|
||||||
|
|
||||||
void report_dialog(DialogId dialog_id, const tl_object_ptr<td_api::ChatReportReason> &reason,
|
void report_dialog(DialogId dialog_id, const tl_object_ptr<td_api::ChatReportReason> &reason,
|
||||||
Promise<Unit> &&promise);
|
const vector<MessageId> &message_ids, Promise<Unit> &&promise);
|
||||||
|
|
||||||
void on_get_peer_settings(DialogId dialog_id, tl_object_ptr<telegram_api::peerSettings> &&peer_settings);
|
void on_get_peer_settings(DialogId dialog_id, tl_object_ptr<telegram_api::peerSettings> &&peer_settings);
|
||||||
|
|
||||||
|
@ -2707,15 +2707,19 @@ class ChangeChatReportSpamStateRequest : public RequestOnceActor {
|
|||||||
class ReportChatRequest : public RequestOnceActor {
|
class ReportChatRequest : public RequestOnceActor {
|
||||||
DialogId dialog_id_;
|
DialogId dialog_id_;
|
||||||
tl_object_ptr<td_api::ChatReportReason> reason_;
|
tl_object_ptr<td_api::ChatReportReason> reason_;
|
||||||
|
vector<MessageId> message_ids_;
|
||||||
|
|
||||||
void do_run(Promise<Unit> &&promise) override {
|
void do_run(Promise<Unit> &&promise) override {
|
||||||
td->messages_manager_->report_dialog(dialog_id_, reason_, std::move(promise));
|
td->messages_manager_->report_dialog(dialog_id_, reason_, message_ids_, std::move(promise));
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ReportChatRequest(ActorShared<Td> td, uint64 request_id, int64 dialog_id,
|
ReportChatRequest(ActorShared<Td> td, uint64 request_id, int64 dialog_id,
|
||||||
tl_object_ptr<td_api::ChatReportReason> reason)
|
tl_object_ptr<td_api::ChatReportReason> reason, const vector<int64> &message_ids)
|
||||||
: RequestOnceActor(std::move(td), request_id), dialog_id_(dialog_id), reason_(std::move(reason)) {
|
: RequestOnceActor(std::move(td), request_id)
|
||||||
|
, dialog_id_(dialog_id)
|
||||||
|
, reason_(std::move(reason))
|
||||||
|
, message_ids_(MessagesManager::get_message_ids(message_ids)) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -6353,7 +6357,7 @@ void Td::on_request(uint64 id, const td_api::changeChatReportSpamState &request)
|
|||||||
void Td::on_request(uint64 id, td_api::reportChat &request) {
|
void Td::on_request(uint64 id, td_api::reportChat &request) {
|
||||||
CHECK_AUTH();
|
CHECK_AUTH();
|
||||||
CHECK_IS_USER();
|
CHECK_IS_USER();
|
||||||
CREATE_REQUEST(ReportChatRequest, request.chat_id_, std::move(request.reason_));
|
CREATE_REQUEST(ReportChatRequest, request.chat_id_, std::move(request.reason_), request.message_ids_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Td::on_request(uint64 id, td_api::setNotificationSettings &request) {
|
void Td::on_request(uint64 id, td_api::setNotificationSettings &request) {
|
||||||
|
@ -192,7 +192,7 @@ class Td final : public NetQueryCallback {
|
|||||||
static td_api::object_ptr<td_api::Object> static_request(td_api::object_ptr<td_api::Function> function);
|
static td_api::object_ptr<td_api::Object> static_request(td_api::object_ptr<td_api::Function> function);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static constexpr const char *tdlib_version = "1.1.3";
|
static constexpr const char *tdlib_version = "1.1.4";
|
||||||
static constexpr int64 ONLINE_ALARM_ID = 0;
|
static constexpr int64 ONLINE_ALARM_ID = 0;
|
||||||
static constexpr int32 ONLINE_TIMEOUT = 240;
|
static constexpr int32 ONLINE_TIMEOUT = 240;
|
||||||
static constexpr int64 PING_SERVER_ALARM_ID = -1;
|
static constexpr int64 PING_SERVER_ALARM_ID = -1;
|
||||||
|
@ -404,8 +404,8 @@ class CliClient final : public Actor {
|
|||||||
return to_integer<int64>(str);
|
return to_integer<int64>(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
static vector<int64> as_message_ids(Slice message_ids_string, char delimiter = ' ') {
|
static vector<int64> as_message_ids(Slice message_ids, char delimiter = ' ') {
|
||||||
return transform(full_split(message_ids_string, delimiter), as_message_id);
|
return transform(full_split(message_ids, delimiter), as_message_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 as_user_id(Slice str) const {
|
int32 as_user_id(Slice str) const {
|
||||||
@ -1899,23 +1899,23 @@ class CliClient final : public Actor {
|
|||||||
send_request(make_tl_object<td_api::deleteFile>(as_file_id(file_id)));
|
send_request(make_tl_object<td_api::deleteFile>(as_file_id(file_id)));
|
||||||
} else if (op == "dm") {
|
} else if (op == "dm") {
|
||||||
string chat_id;
|
string chat_id;
|
||||||
string message_ids_string;
|
string message_ids;
|
||||||
string revoke;
|
string revoke;
|
||||||
std::tie(chat_id, args) = split(args);
|
std::tie(chat_id, args) = split(args);
|
||||||
std::tie(message_ids_string, revoke) = split(args);
|
std::tie(message_ids, revoke) = split(args);
|
||||||
|
|
||||||
send_request(make_tl_object<td_api::deleteMessages>(as_chat_id(chat_id), as_message_ids(message_ids_string, ','),
|
send_request(make_tl_object<td_api::deleteMessages>(as_chat_id(chat_id), as_message_ids(message_ids, ','),
|
||||||
as_bool(revoke)));
|
as_bool(revoke)));
|
||||||
} else if (op == "fm" || op == "fmg") {
|
} else if (op == "fm" || op == "fmg") {
|
||||||
string chat_id;
|
string chat_id;
|
||||||
string from_chat_id;
|
string from_chat_id;
|
||||||
string message_ids_string;
|
string message_ids;
|
||||||
std::tie(chat_id, args) = split(args);
|
std::tie(chat_id, args) = split(args);
|
||||||
std::tie(from_chat_id, message_ids_string) = split(args);
|
std::tie(from_chat_id, message_ids) = split(args);
|
||||||
|
|
||||||
auto chat = as_chat_id(chat_id);
|
auto chat = as_chat_id(chat_id);
|
||||||
send_request(make_tl_object<td_api::forwardMessages>(
|
send_request(make_tl_object<td_api::forwardMessages>(chat, as_chat_id(from_chat_id), as_message_ids(message_ids),
|
||||||
chat, as_chat_id(from_chat_id), as_message_ids(message_ids_string), false, false, op == "fmg"));
|
false, false, op == "fmg"));
|
||||||
} else if (op == "csc" || op == "CreateSecretChat") {
|
} else if (op == "csc" || op == "CreateSecretChat") {
|
||||||
send_request(make_tl_object<td_api::createSecretChat>(to_integer<int32>(args)));
|
send_request(make_tl_object<td_api::createSecretChat>(to_integer<int32>(args)));
|
||||||
} else if (op == "cnsc" || op == "CreateNewSecretChat") {
|
} else if (op == "cnsc" || op == "CreateNewSecretChat") {
|
||||||
@ -2728,10 +2728,10 @@ class CliClient final : public Actor {
|
|||||||
send_request(make_tl_object<td_api::removeRecentHashtag>(hashtag));
|
send_request(make_tl_object<td_api::removeRecentHashtag>(hashtag));
|
||||||
} else if (op == "view") {
|
} else if (op == "view") {
|
||||||
string chat_id;
|
string chat_id;
|
||||||
string message_ids_string;
|
string message_ids;
|
||||||
std::tie(chat_id, message_ids_string) = split(args);
|
std::tie(chat_id, message_ids) = split(args);
|
||||||
|
|
||||||
send_request(make_tl_object<td_api::viewMessages>(as_chat_id(chat_id), as_message_ids(message_ids_string), true));
|
send_request(make_tl_object<td_api::viewMessages>(as_chat_id(chat_id), as_message_ids(message_ids), true));
|
||||||
} else if (op == "omc") {
|
} else if (op == "omc") {
|
||||||
string chat_id;
|
string chat_id;
|
||||||
string message_id;
|
string message_id;
|
||||||
@ -2774,7 +2774,9 @@ class CliClient final : public Actor {
|
|||||||
} else if (op == "rc") {
|
} else if (op == "rc") {
|
||||||
string chat_id;
|
string chat_id;
|
||||||
string reason_str;
|
string reason_str;
|
||||||
std::tie(chat_id, reason_str) = split(args);
|
string message_ids;
|
||||||
|
std::tie(chat_id, args) = split(args);
|
||||||
|
std::tie(reason_str, message_ids) = split(args);
|
||||||
|
|
||||||
tl_object_ptr<td_api::ChatReportReason> reason;
|
tl_object_ptr<td_api::ChatReportReason> reason;
|
||||||
if (reason_str == "spam") {
|
if (reason_str == "spam") {
|
||||||
@ -2787,16 +2789,17 @@ class CliClient final : public Actor {
|
|||||||
reason = make_tl_object<td_api::chatReportReasonCustom>(reason_str);
|
reason = make_tl_object<td_api::chatReportReasonCustom>(reason_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
send_request(make_tl_object<td_api::reportChat>(as_chat_id(chat_id), std::move(reason)));
|
send_request(
|
||||||
|
make_tl_object<td_api::reportChat>(as_chat_id(chat_id), std::move(reason), as_message_ids(message_ids)));
|
||||||
} else if (op == "rsgs" || op == "rchs") {
|
} else if (op == "rsgs" || op == "rchs") {
|
||||||
string supergroup_id;
|
string supergroup_id;
|
||||||
string user_id;
|
string user_id;
|
||||||
string message_ids_string;
|
string message_ids;
|
||||||
std::tie(supergroup_id, args) = split(args);
|
std::tie(supergroup_id, args) = split(args);
|
||||||
std::tie(user_id, message_ids_string) = split(args);
|
std::tie(user_id, message_ids) = split(args);
|
||||||
|
|
||||||
send_request(make_tl_object<td_api::reportSupergroupSpam>(to_integer<int32>(supergroup_id), as_user_id(user_id),
|
send_request(make_tl_object<td_api::reportSupergroupSpam>(to_integer<int32>(supergroup_id), as_user_id(user_id),
|
||||||
as_message_ids(message_ids_string)));
|
as_message_ids(message_ids)));
|
||||||
} else if (op == "gdiff") {
|
} else if (op == "gdiff") {
|
||||||
send_request(make_tl_object<td_api::testGetDifference>());
|
send_request(make_tl_object<td_api::testGetDifference>());
|
||||||
} else if (op == "cproxy") {
|
} else if (op == "cproxy") {
|
||||||
|
Loading…
Reference in New Issue
Block a user