Silence expected error.

GitOrigin-RevId: 1a9c9390b385e63ad91807ee6ed02e088b060154
This commit is contained in:
levlam 2020-04-07 03:06:25 +03:00
parent 4334f5e63a
commit 9df4c5dcf9

View File

@ -2951,14 +2951,16 @@ class SetTypingQuery : public Td::ResultHandler {
class DeleteMessagesQuery : public Td::ResultHandler { class DeleteMessagesQuery : public Td::ResultHandler {
Promise<Unit> promise_; Promise<Unit> promise_;
DialogId dialog_id_;
int32 query_count_; int32 query_count_;
public: public:
explicit DeleteMessagesQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) { explicit DeleteMessagesQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
} }
void send(vector<MessageId> &&message_ids, bool revoke) { void send(DialogId dialog_id, vector<MessageId> &&message_ids, bool revoke) {
LOG(INFO) << "Send deleteMessagesQuery to delete " << format::as_array(message_ids); LOG(INFO) << "Send deleteMessagesQuery to delete " << format::as_array(message_ids) << " in " << dialog_id;
dialog_id_ = dialog_id;
int32 flags = 0; int32 flags = 0;
if (revoke) { if (revoke) {
flags |= telegram_api::messages_deleteMessages::REVOKE_MASK; flags |= telegram_api::messages_deleteMessages::REVOKE_MASK;
@ -2997,7 +2999,8 @@ class DeleteMessagesQuery : public Td::ResultHandler {
} }
void on_error(uint64 id, Status status) override { void on_error(uint64 id, Status status) override {
if (!G()->is_expected_error(status)) { if (!G()->is_expected_error(status) &&
(dialog_id_.get_type() == DialogType::User || status.message() != "MESSAGE_DELETE_FORBIDDEN")) {
LOG(ERROR) << "Receive error for delete messages: " << status; LOG(ERROR) << "Receive error for delete messages: " << status;
} }
promise_.set_error(std::move(status)); promise_.set_error(std::move(status));
@ -8737,7 +8740,7 @@ void MessagesManager::delete_messages_from_server(DialogId dialog_id, vector<Mes
switch (dialog_id.get_type()) { switch (dialog_id.get_type()) {
case DialogType::User: case DialogType::User:
case DialogType::Chat: case DialogType::Chat:
td_->create_handler<DeleteMessagesQuery>(std::move(promise))->send(std::move(message_ids), revoke); td_->create_handler<DeleteMessagesQuery>(std::move(promise))->send(dialog_id, std::move(message_ids), revoke);
break; break;
case DialogType::Channel: case DialogType::Channel:
td_->create_handler<DeleteChannelMessagesQuery>(std::move(promise)) td_->create_handler<DeleteChannelMessagesQuery>(std::move(promise))