Fix formatting.

GitOrigin-RevId: d9c6ce7fd301a1871fea0f1b19ffdeae8328edfb
This commit is contained in:
levlam 2018-06-28 22:20:48 +03:00
parent 0cd2e5be7e
commit 2f60d194cb
4 changed files with 44 additions and 55 deletions

View File

@ -5844,8 +5844,7 @@ void ContactsManager::save_secret_chat(SecretChat *c, SecretChatId secret_chat_i
if (c->logevent_id == 0) { if (c->logevent_id == 0) {
c->logevent_id = binlog_add(G()->td_db()->get_binlog(), LogEvent::HandlerType::SecretChatInfos, storer); c->logevent_id = binlog_add(G()->td_db()->get_binlog(), LogEvent::HandlerType::SecretChatInfos, storer);
} else { } else {
binlog_rewrite(G()->td_db()->get_binlog(), c->logevent_id, LogEvent::HandlerType::SecretChatInfos, binlog_rewrite(G()->td_db()->get_binlog(), c->logevent_id, LogEvent::HandlerType::SecretChatInfos, storer);
storer);
} }
} }

View File

@ -6696,8 +6696,8 @@ void MessagesManager::change_dialog_report_spam_state_on_server(DialogId dialog_
logevent.is_spam_dialog_ = is_spam_dialog; logevent.is_spam_dialog_ = is_spam_dialog;
auto storer = LogEventStorerImpl<ChangeDialogReportSpamStateOnServerLogEvent>(logevent); auto storer = LogEventStorerImpl<ChangeDialogReportSpamStateOnServerLogEvent>(logevent);
logevent_id = binlog_add(G()->td_db()->get_binlog(), logevent_id =
LogEvent::HandlerType::ChangeDialogReportSpamStateOnServer, storer); binlog_add(G()->td_db()->get_binlog(), LogEvent::HandlerType::ChangeDialogReportSpamStateOnServer, storer);
} }
auto new_promise = get_erase_logevent_promise(logevent_id, std::move(promise)); auto new_promise = get_erase_logevent_promise(logevent_id, std::move(promise));
@ -8283,8 +8283,7 @@ void MessagesManager::delete_messages_from_server(DialogId dialog_id, vector<Mes
logevent.revoke_ = revoke; logevent.revoke_ = revoke;
auto storer = LogEventStorerImpl<DeleteMessagesFromServerLogEvent>(logevent); auto storer = LogEventStorerImpl<DeleteMessagesFromServerLogEvent>(logevent);
logevent_id = logevent_id = binlog_add(G()->td_db()->get_binlog(), LogEvent::HandlerType::DeleteMessagesFromServer, storer);
binlog_add(G()->td_db()->get_binlog(), LogEvent::HandlerType::DeleteMessagesFromServer, storer);
} }
auto new_promise = get_erase_logevent_promise(logevent_id, std::move(promise)); auto new_promise = get_erase_logevent_promise(logevent_id, std::move(promise));
@ -8421,8 +8420,7 @@ void MessagesManager::delete_dialog_history_from_server(DialogId dialog_id, Mess
logevent.remove_from_dialog_list_ = remove_from_dialog_list; logevent.remove_from_dialog_list_ = remove_from_dialog_list;
auto storer = LogEventStorerImpl<DeleteDialogHistoryFromServerLogEvent>(logevent); auto storer = LogEventStorerImpl<DeleteDialogHistoryFromServerLogEvent>(logevent);
logevent_id = logevent_id = binlog_add(G()->td_db()->get_binlog(), LogEvent::HandlerType::DeleteDialogHistoryFromServer, storer);
binlog_add(G()->td_db()->get_binlog(), LogEvent::HandlerType::DeleteDialogHistoryFromServer, storer);
} }
auto new_promise = get_erase_logevent_promise(logevent_id, std::move(promise)); auto new_promise = get_erase_logevent_promise(logevent_id, std::move(promise));
@ -8620,8 +8618,8 @@ void MessagesManager::delete_all_channel_messages_from_user_on_server(ChannelId
logevent.user_id_ = user_id; logevent.user_id_ = user_id;
auto storer = LogEventStorerImpl<DeleteAllChannelMessagesFromUserOnServerLogEvent>(logevent); auto storer = LogEventStorerImpl<DeleteAllChannelMessagesFromUserOnServerLogEvent>(logevent);
logevent_id = binlog_add(G()->td_db()->get_binlog(), logevent_id =
LogEvent::HandlerType::DeleteAllChannelMessagesFromUserOnServer, storer); binlog_add(G()->td_db()->get_binlog(), LogEvent::HandlerType::DeleteAllChannelMessagesFromUserOnServer, storer);
} }
td_->create_handler<DeleteUserHistoryQuery>(get_erase_logevent_promise(logevent_id, std::move(promise))) td_->create_handler<DeleteUserHistoryQuery>(get_erase_logevent_promise(logevent_id, std::move(promise)))
@ -8822,8 +8820,7 @@ void MessagesManager::read_all_dialog_mentions_on_server(DialogId dialog_id, uin
logevent.dialog_id_ = dialog_id; logevent.dialog_id_ = dialog_id;
auto storer = LogEventStorerImpl<ReadAllDialogMentionsOnServerLogEvent>(logevent); auto storer = LogEventStorerImpl<ReadAllDialogMentionsOnServerLogEvent>(logevent);
logevent_id = logevent_id = binlog_add(G()->td_db()->get_binlog(), LogEvent::HandlerType::ReadAllDialogMentionsOnServer, storer);
binlog_add(G()->td_db()->get_binlog(), LogEvent::HandlerType::ReadAllDialogMentionsOnServer, storer);
} }
LOG(INFO) << "Read all mentions on server in " << dialog_id; LOG(INFO) << "Read all mentions on server in " << dialog_id;
@ -12577,8 +12574,8 @@ Status MessagesManager::set_dialog_draft_message(DialogId dialog_id,
logevent.dialog_id_ = dialog_id; logevent.dialog_id_ = dialog_id;
auto storer = LogEventStorerImpl<SaveDialogDraftMessageOnServerLogEvent>(logevent); auto storer = LogEventStorerImpl<SaveDialogDraftMessageOnServerLogEvent>(logevent);
if (d->save_draft_message_logevent_id == 0) { if (d->save_draft_message_logevent_id == 0) {
d->save_draft_message_logevent_id = binlog_add( d->save_draft_message_logevent_id =
G()->td_db()->get_binlog(), LogEvent::HandlerType::SaveDialogDraftMessageOnServer, storer); binlog_add(G()->td_db()->get_binlog(), LogEvent::HandlerType::SaveDialogDraftMessageOnServer, storer);
LOG(INFO) << "Add draft logevent " << d->save_draft_message_logevent_id; LOG(INFO) << "Add draft logevent " << d->save_draft_message_logevent_id;
} else { } else {
auto new_logevent_id = binlog_rewrite(G()->td_db()->get_binlog(), d->save_draft_message_logevent_id, auto new_logevent_id = binlog_rewrite(G()->td_db()->get_binlog(), d->save_draft_message_logevent_id,
@ -12712,8 +12709,7 @@ void MessagesManager::toggle_dialog_is_pinned_on_server(DialogId dialog_id, bool
logevent.is_pinned_ = is_pinned; logevent.is_pinned_ = is_pinned;
auto storer = LogEventStorerImpl<ToggleDialogIsPinnedOnServerLogEvent>(logevent); auto storer = LogEventStorerImpl<ToggleDialogIsPinnedOnServerLogEvent>(logevent);
logevent_id = logevent_id = binlog_add(G()->td_db()->get_binlog(), LogEvent::HandlerType::ToggleDialogIsPinnedOnServer, storer);
binlog_add(G()->td_db()->get_binlog(), LogEvent::HandlerType::ToggleDialogIsPinnedOnServer, storer);
} }
td_->create_handler<ToggleDialogPinQuery>(get_erase_logevent_promise(logevent_id))->send(dialog_id, is_pinned); td_->create_handler<ToggleDialogPinQuery>(get_erase_logevent_promise(logevent_id))->send(dialog_id, is_pinned);
@ -12810,8 +12806,7 @@ void MessagesManager::reorder_pinned_dialogs_on_server(const vector<DialogId> &d
logevent.dialog_ids_ = dialog_ids; logevent.dialog_ids_ = dialog_ids;
auto storer = LogEventStorerImpl<ReorderPinnedDialogsOnServerLogEvent>(logevent); auto storer = LogEventStorerImpl<ReorderPinnedDialogsOnServerLogEvent>(logevent);
logevent_id = logevent_id = binlog_add(G()->td_db()->get_binlog(), LogEvent::HandlerType::ReorderPinnedDialogsOnServer, storer);
binlog_add(G()->td_db()->get_binlog(), LogEvent::HandlerType::ReorderPinnedDialogsOnServer, storer);
} }
td_->create_handler<ReorderPinnedDialogsQuery>(get_erase_logevent_promise(logevent_id))->send(dialog_ids); td_->create_handler<ReorderPinnedDialogsQuery>(get_erase_logevent_promise(logevent_id))->send(dialog_ids);
@ -12868,8 +12863,8 @@ void MessagesManager::toggle_dialog_is_marked_as_unread_on_server(DialogId dialo
logevent.is_marked_as_unread_ = is_marked_as_unread; logevent.is_marked_as_unread_ = is_marked_as_unread;
auto storer = LogEventStorerImpl<ToggleDialogIsMarkedAsUnreadOnServerLogEvent>(logevent); auto storer = LogEventStorerImpl<ToggleDialogIsMarkedAsUnreadOnServerLogEvent>(logevent);
logevent_id = binlog_add(G()->td_db()->get_binlog(), logevent_id =
LogEvent::HandlerType::ToggleDialogIsMarkedAsUnreadOnServer, storer); binlog_add(G()->td_db()->get_binlog(), LogEvent::HandlerType::ToggleDialogIsMarkedAsUnreadOnServer, storer);
} }
td_->create_handler<ToggleDialogUnreadMarkQuery>(get_erase_logevent_promise(logevent_id)) td_->create_handler<ToggleDialogUnreadMarkQuery>(get_erase_logevent_promise(logevent_id))
@ -12923,8 +12918,7 @@ void MessagesManager::update_dialog_notification_settings_on_server(DialogId dia
G()->td_db()->get_binlog(), LogEvent::HandlerType::UpdateDialogNotificationSettingsOnServer, storer); G()->td_db()->get_binlog(), LogEvent::HandlerType::UpdateDialogNotificationSettingsOnServer, storer);
LOG(INFO) << "Add notification settings logevent " << d->save_notification_settings_logevent_id; LOG(INFO) << "Add notification settings logevent " << d->save_notification_settings_logevent_id;
} else { } else {
auto new_logevent_id = auto new_logevent_id = binlog_rewrite(G()->td_db()->get_binlog(), d->save_notification_settings_logevent_id,
binlog_rewrite(G()->td_db()->get_binlog(), d->save_notification_settings_logevent_id,
LogEvent::HandlerType::UpdateDialogNotificationSettingsOnServer, storer); LogEvent::HandlerType::UpdateDialogNotificationSettingsOnServer, storer);
LOG(INFO) << "Rewrite notification settings logevent " << d->save_notification_settings_logevent_id << " with " LOG(INFO) << "Rewrite notification settings logevent " << d->save_notification_settings_logevent_id << " with "
<< new_logevent_id; << new_logevent_id;
@ -13279,8 +13273,7 @@ void MessagesManager::read_message_contents_on_server(DialogId dialog_id, vector
logevent.message_ids_ = message_ids; logevent.message_ids_ = message_ids;
auto storer = LogEventStorerImpl<ReadMessageContentsOnServerLogEvent>(logevent); auto storer = LogEventStorerImpl<ReadMessageContentsOnServerLogEvent>(logevent);
logevent_id = logevent_id = binlog_add(G()->td_db()->get_binlog(), LogEvent::HandlerType::ReadMessageContentsOnServer, storer);
binlog_add(G()->td_db()->get_binlog(), LogEvent::HandlerType::ReadMessageContentsOnServer, storer);
} }
auto promise = get_erase_logevent_promise(logevent_id); auto promise = get_erase_logevent_promise(logevent_id);
@ -13693,8 +13686,8 @@ void MessagesManager::update_scope_notification_settings_on_server(NotificationS
logevent.scope_ = scope; logevent.scope_ = scope;
auto storer = LogEventStorerImpl<UpdateScopeNotificationSettingsOnServerLogEvent>(logevent); auto storer = LogEventStorerImpl<UpdateScopeNotificationSettingsOnServerLogEvent>(logevent);
logevent_id = binlog_add(G()->td_db()->get_binlog(), logevent_id =
LogEvent::HandlerType::UpdateScopeNotificationSettingsOnServer, storer); binlog_add(G()->td_db()->get_binlog(), LogEvent::HandlerType::UpdateScopeNotificationSettingsOnServer, storer);
} }
LOG(INFO) << "Update " << scope << " notification settings on server with logevent " << logevent_id; LOG(INFO) << "Update " << scope << " notification settings on server with logevent " << logevent_id;
@ -13735,8 +13728,8 @@ void MessagesManager::reset_all_notification_settings_on_server(uint64 logevent_
if (logevent_id == 0) { if (logevent_id == 0) {
ResetAllNotificationSettingsOnServerLogEvent logevent; ResetAllNotificationSettingsOnServerLogEvent logevent;
auto storer = LogEventStorerImpl<ResetAllNotificationSettingsOnServerLogEvent>(logevent); auto storer = LogEventStorerImpl<ResetAllNotificationSettingsOnServerLogEvent>(logevent);
logevent_id = binlog_add(G()->td_db()->get_binlog(), logevent_id =
LogEvent::HandlerType::ResetAllNotificationSettingsOnServer, storer); binlog_add(G()->td_db()->get_binlog(), LogEvent::HandlerType::ResetAllNotificationSettingsOnServer, storer);
} }
LOG(INFO) << "Reset all notification settings"; LOG(INFO) << "Reset all notification settings";
@ -17061,8 +17054,7 @@ void MessagesManager::save_send_message_logevent(DialogId dialog_id, Message *m)
auto logevent = SendMessageLogEvent(dialog_id, m); auto logevent = SendMessageLogEvent(dialog_id, m);
auto storer = LogEventStorerImpl<SendMessageLogEvent>(logevent); auto storer = LogEventStorerImpl<SendMessageLogEvent>(logevent);
CHECK(m->send_message_logevent_id == 0); CHECK(m->send_message_logevent_id == 0);
m->send_message_logevent_id = m->send_message_logevent_id = binlog_add(G()->td_db()->get_binlog(), LogEvent::HandlerType::SendMessage, storer);
binlog_add(G()->td_db()->get_binlog(), LogEvent::HandlerType::SendMessage, storer);
} }
void MessagesManager::do_send_message(DialogId dialog_id, Message *m, vector<int> bad_parts) { void MessagesManager::do_send_message(DialogId dialog_id, Message *m, vector<int> bad_parts) {
@ -19230,8 +19222,7 @@ uint64 MessagesManager::save_send_screenshot_taken_notification_message_logevent
logevent.dialog_id = dialog_id; logevent.dialog_id = dialog_id;
logevent.m_in = m; logevent.m_in = m;
auto storer = LogEventStorerImpl<SendScreenshotTakenNotificationMessageLogEvent>(logevent); auto storer = LogEventStorerImpl<SendScreenshotTakenNotificationMessageLogEvent>(logevent);
return binlog_add(G()->td_db()->get_binlog(), LogEvent::HandlerType::SendScreenshotTakenNotificationMessage, return binlog_add(G()->td_db()->get_binlog(), LogEvent::HandlerType::SendScreenshotTakenNotificationMessage, storer);
storer);
} }
void MessagesManager::do_send_screenshot_taken_notification_message(DialogId dialog_id, const Message *m, void MessagesManager::do_send_screenshot_taken_notification_message(DialogId dialog_id, const Message *m,
@ -19980,8 +19971,7 @@ void MessagesManager::on_send_message_file_part_missing(int64 random_id, int bad
auto logevent = SendMessageLogEvent(dialog_id, m); auto logevent = SendMessageLogEvent(dialog_id, m);
auto storer = LogEventStorerImpl<SendMessageLogEvent>(logevent); auto storer = LogEventStorerImpl<SendMessageLogEvent>(logevent);
CHECK(m->send_message_logevent_id != 0); CHECK(m->send_message_logevent_id != 0);
binlog_rewrite(G()->td_db()->get_binlog(), m->send_message_logevent_id, LogEvent::HandlerType::SendMessage, binlog_rewrite(G()->td_db()->get_binlog(), m->send_message_logevent_id, LogEvent::HandlerType::SendMessage, storer);
storer);
} }
do_send_message(dialog_id, m, {bad_part}); do_send_message(dialog_id, m, {bad_part});
@ -25290,8 +25280,7 @@ void MessagesManager::get_channel_difference(DialogId dialog_id, int32 pts, bool
auto access_hash = static_cast<const telegram_api::inputChannel &>(*input_channel).access_hash_; auto access_hash = static_cast<const telegram_api::inputChannel &>(*input_channel).access_hash_;
auto logevent = GetChannelDifferenceLogEvent(channel_id, access_hash); auto logevent = GetChannelDifferenceLogEvent(channel_id, access_hash);
auto storer = LogEventStorerImpl<GetChannelDifferenceLogEvent>(logevent); auto storer = LogEventStorerImpl<GetChannelDifferenceLogEvent>(logevent);
auto logevent_id = auto logevent_id = binlog_add(G()->td_db()->get_binlog(), LogEvent::HandlerType::GetChannelDifference, storer);
binlog_add(G()->td_db()->get_binlog(), LogEvent::HandlerType::GetChannelDifference, storer);
get_channel_difference_to_logevent_id_.emplace(dialog_id, logevent_id); get_channel_difference_to_logevent_id_.emplace(dialog_id, logevent_id);
} }

View File

@ -82,8 +82,7 @@ void SecretChatActor::create_chat(int32 user_id, int64 user_access_hash, int32 r
event->user_id = user_id; event->user_id = user_id;
event->user_access_hash = user_access_hash; event->user_access_hash = user_access_hash;
event->random_id = random_id; event->random_id = random_id;
event->set_logevent_id( event->set_logevent_id(binlog_add(context_->binlog(), LogEvent::HandlerType::SecretChats, create_storer(*event)));
binlog_add(context_->binlog(), LogEvent::HandlerType::SecretChats, create_storer(*event)));
do_create_chat_impl(std::move(event)); do_create_chat_impl(std::move(event));
promise.set_value(SecretChatId(random_id)); promise.set_value(SecretChatId(random_id));
loop(); loop();
@ -708,8 +707,7 @@ void SecretChatActor::cancel_chat(Promise<> promise) {
auto event = std::make_unique<logevent::CloseSecretChat>(); auto event = std::make_unique<logevent::CloseSecretChat>();
event->chat_id = auth_state_.id; event->chat_id = auth_state_.id;
event->set_logevent_id( event->set_logevent_id(binlog_add(context_->binlog(), LogEvent::HandlerType::SecretChats, create_storer(*event)));
binlog_add(context_->binlog(), LogEvent::HandlerType::SecretChats, create_storer(*event)));
auto on_sync = PromiseCreator::lambda( auto on_sync = PromiseCreator::lambda(
[actor_id = actor_id(this), event = std::move(event), promise = std::move(promise)](Result<Unit> result) mutable { [actor_id = actor_id(this), event = std::move(event), promise = std::move(promise)](Result<Unit> result) mutable {
@ -1087,8 +1085,7 @@ void SecretChatActor::do_outbound_message_impl(std::unique_ptr<logevent::Outboun
auto logevent_id = state->message->logevent_id(); auto logevent_id = state->message->logevent_id();
if (logevent_id == 0) { if (logevent_id == 0) {
logevent_id = logevent_id = binlog_add(context_->binlog(), LogEvent::HandlerType::SecretChats, create_storer(*state->message));
binlog_add(context_->binlog(), LogEvent::HandlerType::SecretChats, create_storer(*state->message));
LOG(INFO) << "Outbound secret message [save_logevent] start " << tag("logevent_id", logevent_id); LOG(INFO) << "Outbound secret message [save_logevent] start " << tag("logevent_id", logevent_id);
context_->binlog()->force_sync(std::move(save_logevent_finish)); context_->binlog()->force_sync(std::move(save_logevent_finish));
state->message->set_logevent_id(logevent_id); state->message->set_logevent_id(logevent_id);
@ -1176,8 +1173,8 @@ Status SecretChatActor::do_inbound_message_decrypted_pending(std::unique_ptr<log
if (logevent_id == 0) { if (logevent_id == 0) {
message->is_pending = true; message->is_pending = true;
message->set_logevent_id(binlog_add(context_->binlog(), LogEvent::HandlerType::SecretChats, message->set_logevent_id(binlog_add(context_->binlog(), LogEvent::HandlerType::SecretChats, create_storer(*message),
create_storer(*message), std::move(qts_promise))); std::move(qts_promise)));
LOG(INFO) << "Inbound PENDING secret message [save_logevent] start (do not expect finish) " LOG(INFO) << "Inbound PENDING secret message [save_logevent] start (do not expect finish) "
<< tag("logevent_id", message->logevent_id()); << tag("logevent_id", message->logevent_id());
} else { } else {

View File

@ -61,14 +61,18 @@ TEST(DB, binlog_encryption) {
{ {
Binlog binlog; Binlog binlog;
binlog.init(binlog_name.str(), [](const BinlogEvent &x) {}).ensure(); binlog.init(binlog_name.str(), [](const BinlogEvent &x) {}).ensure();
binlog.add_raw_event(BinlogEvent::create_raw(binlog.next_id(), 1, 0, create_storer("AAAA")), BinlogDebugInfo{__FILE__, __LINE__}); binlog.add_raw_event(BinlogEvent::create_raw(binlog.next_id(), 1, 0, create_storer("AAAA")),
binlog.add_raw_event(BinlogEvent::create_raw(binlog.next_id(), 1, 0, create_storer("BBBB")), BinlogDebugInfo{__FILE__, __LINE__}); BinlogDebugInfo{__FILE__, __LINE__});
binlog.add_raw_event(BinlogEvent::create_raw(binlog.next_id(), 1, 0, create_storer(long_data)), BinlogDebugInfo{__FILE__, __LINE__}); binlog.add_raw_event(BinlogEvent::create_raw(binlog.next_id(), 1, 0, create_storer("BBBB")),
BinlogDebugInfo{__FILE__, __LINE__});
binlog.add_raw_event(BinlogEvent::create_raw(binlog.next_id(), 1, 0, create_storer(long_data)),
BinlogDebugInfo{__FILE__, __LINE__});
LOG(INFO) << "SET PASSWORD"; LOG(INFO) << "SET PASSWORD";
binlog.change_key(cucumber); binlog.change_key(cucumber);
binlog.change_key(hello); binlog.change_key(hello);
LOG(INFO) << "OK"; LOG(INFO) << "OK";
binlog.add_raw_event(BinlogEvent::create_raw(binlog.next_id(), 1, 0, create_storer("CCCC")), BinlogDebugInfo{__FILE__, __LINE__}); binlog.add_raw_event(BinlogEvent::create_raw(binlog.next_id(), 1, 0, create_storer("CCCC")),
BinlogDebugInfo{__FILE__, __LINE__});
binlog.close().ensure(); binlog.close().ensure();
} }