Do not return error for delete messages and close in closed secret chats.

GitOrigin-RevId: c63a155a6fe056dfcbe6204b5ca25de95eb1f23f
This commit is contained in:
levlam 2018-07-25 16:21:53 +03:00
parent 86c9234388
commit cf1ece71a0

View File

@ -407,6 +407,10 @@ void SecretChatActor::send_open_message(int64 random_id, Promise<> promise) {
}
void SecretChatActor::delete_message(int64 random_id, Promise<> promise) {
if (auth_state_.state == State::Closed) {
promise.set_value(Unit());
return;
}
if (close_flag_) {
promise.set_error(Status::Error(400, "Chat is closed"));
return;
@ -419,6 +423,10 @@ void SecretChatActor::delete_message(int64 random_id, Promise<> promise) {
}
void SecretChatActor::delete_messages(std::vector<int64> random_ids, Promise<> promise) {
if (auth_state_.state == State::Closed) {
promise.set_value(Unit());
return;
}
if (close_flag_) {
promise.set_error(Status::Error(400, "Chat is closed"));
return;
@ -431,6 +439,10 @@ void SecretChatActor::delete_messages(std::vector<int64> random_ids, Promise<> p
std::move(promise));
}
void SecretChatActor::delete_all_messages(Promise<> promise) {
if (auth_state_.state == State::Closed) {
promise.set_value(Unit());
return;
}
if (close_flag_) {
promise.set_error(Status::Error(400, "Chat is closed"));
return;
@ -695,7 +707,7 @@ void SecretChatActor::on_fatal_error(Status status) {
void SecretChatActor::cancel_chat(Promise<> promise) {
if (close_flag_) {
promise.set_error(Status::Error(400, "Chat is already closing"));
promise.set_value(Unit());
return;
}
close_flag_ = true;