Update layer 82: chatReportReasonCopyright, clearAllDraftMessages.

GitOrigin-RevId: 79d9adf61a17b11996eeecfa94c205d1cdc34a51
This commit is contained in:
levlam 2018-07-17 06:46:27 +03:00
parent e819a0ed56
commit 4594885e61
9 changed files with 71 additions and 2 deletions

View File

@ -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;

Binary file not shown.

View File

@ -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<MessageEntity> 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<MessageRange>;
messages.markDialogUnread#c286d98f flags:# unread:flags.0?true peer:InputDialogPeer = Bool;
messages.getDialogUnreadMarks#22e24e22 = Vector<DialogPeer>;
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<Fil
help.getConfig#c4f9186b = Config;
help.getNearestDc#1fb33026 = NearestDc;
help.getAppUpdate#ae2de196 = help.AppUpdate;
help.getAppUpdate#522d5a7d source:string = help.AppUpdate;
help.saveAppLog#6f02f748 events:Vector<InputAppEvent> = Bool;
help.getInviteText#4d392343 = help.InviteText;
help.getSupport#9cdf08cd = help.Support;

Binary file not shown.

View File

@ -905,6 +905,39 @@ class SaveDraftMessageQuery : public Td::ResultHandler {
}
};
class ClearAllDraftsQuery : public Td::ResultHandler {
Promise<Unit> promise_;
public:
explicit ClearAllDraftsQuery(Promise<Unit> &&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<telegram_api::messages_clearAllDrafts>(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<Unit> promise_;
DialogId dialog_id_;
@ -6807,6 +6840,9 @@ void MessagesManager::report_dialog(DialogId dialog_id, const tl_object_ptr<td_a
case td_api::chatReportReasonPornography::ID:
report_reason = make_tl_object<telegram_api::inputReportReasonPornography>();
break;
case td_api::chatReportReasonCopyright::ID:
report_reason = make_tl_object<telegram_api::inputReportReasonCopyright>();
break;
case td_api::chatReportReasonCustom::ID: {
auto other_reason = static_cast<const td_api::chatReportReasonCustom *>(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<Unit> &&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<ClearAllDraftsQuery>(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) {

View File

@ -1231,6 +1231,8 @@ class MessagesManager : public Actor {
Status set_dialog_draft_message(DialogId dialog_id,
tl_object_ptr<td_api::draftMessage> &&draft_message) TD_WARN_UNUSED_RESULT;
void clear_all_draft_messages(Promise<Unit> &&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;

View File

@ -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)) {

View File

@ -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);

View File

@ -2256,6 +2256,8 @@ class CliClient final : public Actor {
make_tl_object<td_api::inputMessageText>(as_formatted_text(message, std::move(entities)), true, false));
}
send_request(make_tl_object<td_api::setChatDraftMessage>(as_chat_id(chat_id), std::move(draft_message)));
} else if (op == "cadm") {
send_request(make_tl_object<td_api::clearAllDraftMessages>());
} else if (op == "tcip") {
string chat_id;
string is_pinned;
@ -3157,6 +3159,8 @@ class CliClient final : public Actor {
reason = make_tl_object<td_api::chatReportReasonViolence>();
} else if (reason_str == "porno") {
reason = make_tl_object<td_api::chatReportReasonPornography>();
} else if (reason_str == "copyright") {
reason = make_tl_object<td_api::chatReportReasonCopyright>();
} else {
reason = make_tl_object<td_api::chatReportReasonCustom>(reason_str);
}