From 4594885e61b8f1329f965cb6b1ce449174768e1e Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 17 Jul 2018 06:46:27 +0300 Subject: [PATCH] Update layer 82: chatReportReasonCopyright, clearAllDraftMessages. GitOrigin-RevId: 79d9adf61a17b11996eeecfa94c205d1cdc34a51 --- td/generate/scheme/td_api.tl | 7 +++++ td/generate/scheme/td_api.tlo | Bin 129368 -> 129500 bytes td/generate/scheme/telegram_api.tl | 6 ++-- td/generate/scheme/telegram_api.tlo | Bin 161940 -> 162284 bytes td/telegram/MessagesManager.cpp | 46 ++++++++++++++++++++++++++++ td/telegram/MessagesManager.h | 2 ++ td/telegram/Td.cpp | 6 ++++ td/telegram/Td.h | 2 ++ td/telegram/cli.cpp | 4 +++ 9 files changed, 71 insertions(+), 2 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index ac5e62b76..f3f960aa9 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -1838,6 +1838,9 @@ chatReportReasonViolence = ChatReportReason; //@description The chat contains pornographic messages chatReportReasonPornography = ChatReportReason; +//@description The chat contains copyrighted content +chatReportReasonCopyright = ChatReportReason; + //@description A custom reason provided by the user @text Report text chatReportReasonCustom text:string = ChatReportReason; @@ -2725,6 +2728,10 @@ searchChatMembers chat_id:int53 query:string limit:int32 = ChatMembers; getChatAdministrators chat_id:int53 = Users; +//@description Clears draft messages in all chats +clearAllDraftMessages = Ok; + + //@description Returns the notification settings for chats of a given type @scope Types of chats for which to return the notification settings information getScopeNotificationSettings scope:NotificationSettingsScope = ScopeNotificationSettings; diff --git a/td/generate/scheme/td_api.tlo b/td/generate/scheme/td_api.tlo index d72152a79cc1c86790964dd9aec419bb43d5b6a6..64f58903c4d79cd820d2af8588cfa8aa954ee54e 100644 GIT binary patch delta 298 zcmccdiT%!J_6;U%lEHp`2?EX;i6ud)1^GolGO;*6kAZ=Kb#fu2_~sNg8EM9#&5erD zMiL;EH;)PV03{iUoY{0ZY}*ck#3p|U*1;`l5uy`=ODD)A5V$JG6|>;pB`e8fGPc5E)uai-2`<_}x7gtu0DGbxk+B4cuFWA8-u|4K6;~!H1 Dm*-^g delta 198 zcmccfnf=Bm_6;U%qMs+kLZf;bJHj)6T zx_L~6ZI8)!0$fVs^Iq1zQg q8SjWPDsKOq#mFqY-Jy=r#g!GLlwrD{1Ec+9g|i&nFC1p%F#`bSLPzTW diff --git a/td/generate/scheme/telegram_api.tl b/td/generate/scheme/telegram_api.tl index 01bce570c..0d925f9d0 100644 --- a/td/generate/scheme/telegram_api.tl +++ b/td/generate/scheme/telegram_api.tl @@ -200,6 +200,7 @@ inputReportReasonSpam#58dbcab8 = ReportReason; inputReportReasonViolence#1e22c78d = ReportReason; inputReportReasonPornography#2e59d922 = ReportReason; inputReportReasonOther#e1746d0a text:string = ReportReason; +inputReportReasonCopyright#9b89f93a = ReportReason; userFull#f220f3f flags:# blocked:flags.0?true phone_calls_available:flags.4?true phone_calls_private:flags.5?true user:User about:flags.1?string link:contacts.Link profile_photo:flags.2?Photo notify_settings:PeerNotifySettings bot_info:flags.3?BotInfo common_chats_count:int = UserFull; @@ -351,7 +352,7 @@ config#3213dbba flags:# phonecalls_enabled:flags.1?true default_p2p_contacts:fla nearestDc#8e1a1775 country:string this_dc:int nearest_dc:int = NearestDc; -help.appUpdate#8987f311 id:int critical:Bool url:string text:string = help.AppUpdate; +help.appUpdate#1da7158f flags:# popup:flags.0?true id:int version:string text:string entities:Vector document:flags.1?Document url:flags.2?string = help.AppUpdate; help.noAppUpdate#c45a6536 = help.AppUpdate; help.inviteText#18cb9f78 message:string = help.InviteText; @@ -1089,6 +1090,7 @@ messages.searchStickerSets#c2b7d08b flags:# exclude_featured:flags.0?true q:stri messages.getSplitRanges#1cff7e08 = Vector; messages.markDialogUnread#c286d98f flags:# unread:flags.0?true peer:InputDialogPeer = Bool; messages.getDialogUnreadMarks#22e24e22 = Vector; +messages.clearAllDrafts#7e58ee9c = Bool; updates.getState#edd4882a = updates.State; updates.getDifference#25939651 flags:# pts:int pts_total_limit:flags.0?int date:int qts:int = updates.Difference; @@ -1110,7 +1112,7 @@ upload.getFileHashes#c7025931 location:InputFileLocation offset:int = Vector = Bool; help.getInviteText#4d392343 = help.InviteText; help.getSupport#9cdf08cd = help.Support; diff --git a/td/generate/scheme/telegram_api.tlo b/td/generate/scheme/telegram_api.tlo index c971d061ad9002006356da84b5f814aa5571438e..6fdacbf59b14076f31290f13bf1ccc00e89f24dd 100644 GIT binary patch delta 492 zcmbR8k@L-G&J6-$g6a;jLOemK1^GoKL8*zw`FWFV8KpPdh|S<)*;(-S=H?p;0i298 zH*0F;e~|#Gy?IQ?hXDwRoY{0ZY}*ck#HMeMW7NSd`$dk?0Jp4-Jfj8+$dt(!jvIJ@ z7$D<8;Hn%~jMdN1*;1K#1*JgOA>8PkUr=WE|=xYNX;qG zODre|El5c$No4?eYqG#;gXvEeFq%vjI4?MvH;{jNgD8{0WSd5r$sZ~OriUzK)S0aF zN@Q}6nZ)!L;Y_H2=uh{v-_HC#rdU0$*I%N+cL?4EZwdk z$RxufGv{4Iop^3)adBdLYO!8&PHJM2V@{4sQDRz2@pOX^j4Io0WSO?8BUvlr%G6*C E09MwiYybcN delta 361 zcmaF!nRCiV&J6-$qOv=$bn*nH7UUO|1f?bx=jSmnFtAK^WE9_QBQ}GJMSa>`-_17^ z0yr6GY}VAu{~`fWfAg4-4^SCHku#ePhi%(Ikl6GMa*R5-WxvQV8sL_-k!RFk0hu!S z!f^vIWBUVnMu%z%!O!iTd>N@Z1$v1E1)&8gi6yBFASX?4sASaO*wNE#<}j*AfYhS979_TP#~j88OGf_fg4Y<2bAxT1cAZgS`=5u5 sZ}bhOJ=9$%2(~pnwZsu_G1z9TrdbFv$?$BSBFD5v9bs0E8&iWZ0A6u}wg3PC diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 811e6ec5a..0b59f611e 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -905,6 +905,39 @@ class SaveDraftMessageQuery : public Td::ResultHandler { } }; +class ClearAllDraftsQuery : public Td::ResultHandler { + Promise promise_; + + public: + explicit ClearAllDraftsQuery(Promise &&promise) : promise_(std::move(promise)) { + } + + void send() { + send_query(G()->net_query_creator().create(create_storer(telegram_api::messages_clearAllDrafts()))); + } + + void on_result(uint64 id, BufferSlice packet) override { + auto result_ptr = fetch_result(packet); + if (result_ptr.is_error()) { + return on_error(id, result_ptr.move_as_error()); + } + + bool result = result_ptr.move_as_ok(); + if (!result) { + LOG(INFO) << "Receive false for clearAllDrafts"; + } else { + LOG(INFO) << "All draft messages has been cleared"; + } + + promise_.set_value(Unit()); + } + + void on_error(uint64 id, Status status) override { + LOG(ERROR) << "Receive error for ClearAllDraftsQuery: " << status; + promise_.set_error(std::move(status)); + } +}; + class ToggleDialogPinQuery : public Td::ResultHandler { Promise promise_; DialogId dialog_id_; @@ -6807,6 +6840,9 @@ void MessagesManager::report_dialog(DialogId dialog_id, const tl_object_ptr(); break; + case td_api::chatReportReasonCopyright::ID: + report_reason = make_tl_object(); + break; case td_api::chatReportReasonCustom::ID: { auto other_reason = static_cast(reason.get()); auto text = other_reason->text_; @@ -12725,6 +12761,16 @@ void MessagesManager::on_saved_dialog_draft_message(DialogId dialog_id, uint64 g } } +void MessagesManager::clear_all_draft_messages(Promise &&promise) { + for (auto &dialog : dialogs_) { + Dialog *d = dialog.second.get(); + if (d->dialog_id.get_type() == DialogType::SecretChat) { + update_dialog_draft_message(d, nullptr, false, true); + } + } + td_->create_handler(std::move(promise))->send(); +} + int32 MessagesManager::get_pinned_dialogs_limit() { int32 limit = G()->shared_config().get_option_integer("pinned_chat_count_max"); if (limit <= 0) { diff --git a/td/telegram/MessagesManager.h b/td/telegram/MessagesManager.h index 948ff6ed6..a68e4a96a 100644 --- a/td/telegram/MessagesManager.h +++ b/td/telegram/MessagesManager.h @@ -1231,6 +1231,8 @@ class MessagesManager : public Actor { Status set_dialog_draft_message(DialogId dialog_id, tl_object_ptr &&draft_message) TD_WARN_UNUSED_RESULT; + void clear_all_draft_messages(Promise &&promise); + Status toggle_dialog_is_pinned(DialogId dialog_id, bool is_pinned) TD_WARN_UNUSED_RESULT; Status toggle_dialog_is_marked_as_unread(DialogId dialog_id, bool is_marked_as_unread) TD_WARN_UNUSED_RESULT; diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index b265f8a57..3ad924c3c 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -5473,6 +5473,12 @@ void Td::on_request(uint64 id, td_api::getChatEventLog &request) { request.limit_, std::move(request.filters_), std::move(request.user_ids_)); } +void Td::on_request(uint64 id, const td_api::clearAllDraftMessages &request) { + CHECK_IS_USER(); + CREATE_OK_REQUEST_PROMISE(); + messages_manager_->clear_all_draft_messages(std::move(promise)); +} + void Td::on_request(uint64 id, const td_api::downloadFile &request) { auto priority = request.priority_; if (!(1 <= priority && priority <= 32)) { diff --git a/td/telegram/Td.h b/td/telegram/Td.h index 43629f232..478b2baac 100644 --- a/td/telegram/Td.h +++ b/td/telegram/Td.h @@ -607,6 +607,8 @@ class Td final : public NetQueryCallback { void on_request(uint64 id, td_api::getChatEventLog &request); + void on_request(uint64 id, const td_api::clearAllDraftMessages &request); + void on_request(uint64 id, const td_api::downloadFile &request); void on_request(uint64 id, const td_api::cancelDownloadFile &request); diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index 67cad2455..ac1228d61 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -2256,6 +2256,8 @@ class CliClient final : public Actor { make_tl_object(as_formatted_text(message, std::move(entities)), true, false)); } send_request(make_tl_object(as_chat_id(chat_id), std::move(draft_message))); + } else if (op == "cadm") { + send_request(make_tl_object()); } else if (op == "tcip") { string chat_id; string is_pinned; @@ -3157,6 +3159,8 @@ class CliClient final : public Actor { reason = make_tl_object(); } else if (reason_str == "porno") { reason = make_tl_object(); + } else if (reason_str == "copyright") { + reason = make_tl_object(); } else { reason = make_tl_object(reason_str); }