Fix some secret chat actions on closing.
GitOrigin-RevId: 055965d9dd24f42c16826d18c88ef1205d9b808e
This commit is contained in:
parent
9882a8a619
commit
7fd2a81a38
@ -8523,10 +8523,8 @@ void MessagesManager::delete_dialog_history_from_server(DialogId dialog_id, Mess
|
||||
->send(dialog_id.get_channel_id(), max_message_id, allow_error);
|
||||
break;
|
||||
case DialogType::SecretChat:
|
||||
// TODO: use promise
|
||||
send_closure(G()->secret_chats_manager(), &SecretChatsManager::delete_all_messages,
|
||||
dialog_id.get_secret_chat_id(), Promise<>());
|
||||
promise.set_value(Unit());
|
||||
dialog_id.get_secret_chat_id(), std::move(promise));
|
||||
break;
|
||||
case DialogType::None:
|
||||
default:
|
||||
|
@ -36,9 +36,11 @@
|
||||
#define G GLOBAL_SHOULD_NOT_BE_USED_HERE
|
||||
|
||||
namespace td {
|
||||
|
||||
inline TLObjectStorer<secret_api::Object> create_storer(const secret_api::Object &object) {
|
||||
return TLObjectStorer<secret_api::Object>(object);
|
||||
}
|
||||
|
||||
class SecretImpl {
|
||||
public:
|
||||
explicit SecretImpl(const Storer &data) : data(data) {
|
||||
@ -52,6 +54,7 @@ class SecretImpl {
|
||||
private:
|
||||
const Storer &data;
|
||||
};
|
||||
|
||||
SecretChatActor::SecretChatActor(int32 id, std::unique_ptr<Context> context, bool can_be_empty)
|
||||
: context_(std::move(context)), can_be_empty_(can_be_empty) {
|
||||
auth_state_.id = id;
|
||||
@ -87,8 +90,13 @@ void SecretChatActor::create_chat(int32 user_id, int64 user_access_hash, int32 r
|
||||
promise.set_value(SecretChatId(random_id));
|
||||
loop();
|
||||
}
|
||||
|
||||
void SecretChatActor::on_result_resendable(NetQueryPtr net_query, Promise<NetQueryPtr> promise) {
|
||||
LOG(INFO) << "on_result_resendable: " << net_query;
|
||||
LOG(INFO) << "on_result_resendable: " << net_query << " " << close_flag_;
|
||||
if (context_->close_flag()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto key = UniqueId::extract_key(net_query->id());
|
||||
if (close_flag_) {
|
||||
if (key == static_cast<uint8>(QueryType::DiscardEncryption)) {
|
||||
@ -103,7 +111,8 @@ void SecretChatActor::on_result_resendable(NetQueryPtr net_query, Promise<NetQue
|
||||
case static_cast<uint8>(QueryType::EncryptedChat):
|
||||
return on_update_chat(std::move(net_query));
|
||||
case static_cast<uint8>(QueryType::Message):
|
||||
return on_outbound_send_message_result(std::move(net_query), std::move(promise)), Status::OK();
|
||||
on_outbound_send_message_result(std::move(net_query), std::move(promise));
|
||||
return Status::OK();
|
||||
case static_cast<uint8>(QueryType::ReadHistory):
|
||||
return on_read_history(std::move(net_query));
|
||||
case static_cast<uint8>(QueryType::Ignore):
|
||||
@ -114,18 +123,21 @@ void SecretChatActor::on_result_resendable(NetQueryPtr net_query, Promise<NetQue
|
||||
|
||||
loop();
|
||||
}
|
||||
|
||||
void SecretChatActor::replay_close_chat(std::unique_ptr<logevent::CloseSecretChat> event) {
|
||||
if (close_flag_) {
|
||||
return;
|
||||
}
|
||||
do_close_chat_impl(std::move(event));
|
||||
}
|
||||
|
||||
void SecretChatActor::replay_create_chat(std::unique_ptr<logevent::CreateSecretChat> event) {
|
||||
if (close_flag_) {
|
||||
return;
|
||||
}
|
||||
do_create_chat_impl(std::move(event));
|
||||
}
|
||||
|
||||
void SecretChatActor::add_inbound_message(std::unique_ptr<logevent::InboundSecretMessage> message) {
|
||||
SCOPE_EXIT {
|
||||
if (message) {
|
||||
|
@ -43,9 +43,7 @@
|
||||
|
||||
namespace td {
|
||||
class BinlogInterface;
|
||||
class DhCache;
|
||||
class NetQueryCreator;
|
||||
class SequenceDispatcher;
|
||||
|
||||
class SecretChatActor : public NetQueryCallback {
|
||||
public:
|
||||
|
@ -275,11 +275,12 @@ class InboundSecretMessage : public LogEventHelper<InboundSecretMessage, SecretC
|
||||
}
|
||||
|
||||
StringBuilder &print(StringBuilder &sb) const override {
|
||||
return sb << "[Logevent InboundSecretMessage " << tag("id", logevent_id())
|
||||
<< tag("auth_key_id", format::as_hex(auth_key_id)) << tag("message_id", message_id)
|
||||
<< tag("my_in_seq_no", my_in_seq_no) << tag("my_out_seq_no", my_out_seq_no)
|
||||
<< tag("his_in_seq_no", his_in_seq_no) << tag("message", to_string(decrypted_message_layer))
|
||||
<< tag("is_pending", is_pending) << format::cond(has_encrypted_file, tag("file", file)) << "]";
|
||||
return sb << "[Logevent InboundSecretMessage " << tag("id", logevent_id()) << tag("qts", qts)
|
||||
<< tag("chat_id", chat_id) << tag("date", date) << tag("auth_key_id", format::as_hex(auth_key_id))
|
||||
<< tag("message_id", message_id) << tag("my_in_seq_no", my_in_seq_no)
|
||||
<< tag("my_out_seq_no", my_out_seq_no) << tag("his_in_seq_no", his_in_seq_no)
|
||||
<< tag("message", to_string(decrypted_message_layer)) << tag("is_pending", is_pending)
|
||||
<< format::cond(has_encrypted_file, tag("file", file)) << "]";
|
||||
}
|
||||
};
|
||||
|
||||
@ -376,11 +377,11 @@ class OutboundSecretMessage : public LogEventHelper<OutboundSecretMessage, Secre
|
||||
}
|
||||
|
||||
StringBuilder &print(StringBuilder &sb) const override {
|
||||
return sb << "[Logevent OutboundSecretMessage " << tag("id", logevent_id()) << tag("is_sent", is_sent)
|
||||
<< tag("is_service", is_service) << tag("is_rewritable", is_rewritable) << tag("is_external", is_external)
|
||||
<< tag("message_id", message_id) << tag("random_id", random_id) << tag("my_in_seq_no", my_in_seq_no)
|
||||
<< tag("my_out_seq_no", my_out_seq_no) << tag("his_in_seq_no", his_in_seq_no) << tag("file", file)
|
||||
<< tag("action", to_string(action)) << "]";
|
||||
return sb << "[Logevent OutboundSecretMessage " << tag("id", logevent_id()) << tag("chat_id", chat_id)
|
||||
<< tag("is_sent", is_sent) << tag("is_service", is_service) << tag("is_rewritable", is_rewritable)
|
||||
<< tag("is_external", is_external) << tag("message_id", message_id) << tag("random_id", random_id)
|
||||
<< tag("my_in_seq_no", my_in_seq_no) << tag("my_out_seq_no", my_out_seq_no)
|
||||
<< tag("his_in_seq_no", his_in_seq_no) << tag("file", file) << tag("action", to_string(action)) << "]";
|
||||
}
|
||||
};
|
||||
|
||||
@ -430,7 +431,8 @@ class CreateSecretChat : public LogEventHelper<CreateSecretChat, SecretChatEvent
|
||||
}
|
||||
|
||||
StringBuilder &print(StringBuilder &sb) const override {
|
||||
return sb << "[Logevent CreateSecretChat " << tag("id", logevent_id()) << tag("chat_id", random_id) << "]";
|
||||
return sb << "[Logevent CreateSecretChat " << tag("id", logevent_id()) << tag("chat_id", random_id)
|
||||
<< tag("user_id", user_id) << "]";
|
||||
}
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user