Add ResetAuthorizationOnServerLogEvent.
This commit is contained in:
parent
e6fb913798
commit
f2b2f01c33
@ -811,9 +811,37 @@ void AccountManager::get_active_sessions(Promise<td_api::object_ptr<td_api::sess
|
||||
td_->create_handler<GetAuthorizationsQuery>(std::move(promise))->send();
|
||||
}
|
||||
|
||||
class AccountManager::ResetAuthorizationOnServerLogEvent {
|
||||
public:
|
||||
int64 hash_;
|
||||
|
||||
template <class StorerT>
|
||||
void store(StorerT &storer) const {
|
||||
td::store(hash_, storer);
|
||||
}
|
||||
|
||||
template <class ParserT>
|
||||
void parse(ParserT &parser) {
|
||||
td::parse(hash_, parser);
|
||||
}
|
||||
};
|
||||
|
||||
void AccountManager::reset_authorization_on_server(int64 hash, uint64 log_event_id, Promise<Unit> &&promise) {
|
||||
if (log_event_id == 0) {
|
||||
ResetAuthorizationOnServerLogEvent log_event{hash};
|
||||
log_event_id = binlog_add(G()->td_db()->get_binlog(), LogEvent::HandlerType::ResetAuthorizationOnServer,
|
||||
get_log_event_storer(log_event));
|
||||
}
|
||||
|
||||
auto new_promise = get_erase_log_event_promise(log_event_id, std::move(promise));
|
||||
promise = std::move(new_promise); // to prevent self-move
|
||||
|
||||
td_->create_handler<ResetAuthorizationQuery>(std::move(promise))->send(hash);
|
||||
}
|
||||
|
||||
void AccountManager::terminate_session(int64 session_id, Promise<Unit> &&promise) {
|
||||
on_confirm_authorization(session_id);
|
||||
td_->create_handler<ResetAuthorizationQuery>(std::move(promise))->send(session_id);
|
||||
reset_authorization_on_server(session_id, 0, std::move(promise));
|
||||
}
|
||||
|
||||
void AccountManager::terminate_all_other_sessions(Promise<Unit> &&promise) {
|
||||
@ -860,28 +888,20 @@ class AccountManager::ChangeAuthorizationSettingsOnServerLogEvent {
|
||||
}
|
||||
};
|
||||
|
||||
uint64 AccountManager::save_change_authorization_settings_on_server_log_event(
|
||||
int64 hash, bool set_encrypted_requests_disabled, bool encrypted_requests_disabled, bool set_call_requests_disabled,
|
||||
bool call_requests_disabled, bool confirm) {
|
||||
ChangeAuthorizationSettingsOnServerLogEvent log_event{hash,
|
||||
set_encrypted_requests_disabled,
|
||||
encrypted_requests_disabled,
|
||||
set_call_requests_disabled,
|
||||
call_requests_disabled,
|
||||
confirm};
|
||||
return binlog_add(G()->td_db()->get_binlog(), LogEvent::HandlerType::ChangeAuthorizationSettingsOnServer,
|
||||
get_log_event_storer(log_event));
|
||||
}
|
||||
|
||||
void AccountManager::change_authorization_settings_on_server(int64 hash, bool set_encrypted_requests_disabled,
|
||||
bool encrypted_requests_disabled,
|
||||
bool set_call_requests_disabled,
|
||||
bool call_requests_disabled, bool confirm,
|
||||
uint64 log_event_id, Promise<Unit> &&promise) {
|
||||
if (log_event_id == 0) {
|
||||
log_event_id = save_change_authorization_settings_on_server_log_event(
|
||||
hash, set_encrypted_requests_disabled, encrypted_requests_disabled, set_call_requests_disabled,
|
||||
call_requests_disabled, confirm);
|
||||
ChangeAuthorizationSettingsOnServerLogEvent log_event{hash,
|
||||
set_encrypted_requests_disabled,
|
||||
encrypted_requests_disabled,
|
||||
set_call_requests_disabled,
|
||||
call_requests_disabled,
|
||||
confirm};
|
||||
log_event_id = binlog_add(G()->td_db()->get_binlog(), LogEvent::HandlerType::ChangeAuthorizationSettingsOnServer,
|
||||
get_log_event_storer(log_event));
|
||||
}
|
||||
|
||||
auto new_promise = get_erase_log_event_promise(log_event_id, std::move(promise));
|
||||
@ -1061,6 +1081,13 @@ void AccountManager::on_binlog_events(vector<BinlogEvent> &&events) {
|
||||
Auto());
|
||||
break;
|
||||
}
|
||||
case LogEvent::HandlerType::ResetAuthorizationOnServer: {
|
||||
ResetAuthorizationOnServerLogEvent log_event;
|
||||
log_event_parse(log_event, event.get_data()).ensure();
|
||||
|
||||
reset_authorization_on_server(log_event.hash_, event.id_, Auto());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
LOG(FATAL) << "Unsupported log event type " << event.type_;
|
||||
}
|
||||
|
@ -79,6 +79,7 @@ class AccountManager final : public Actor {
|
||||
class UnconfirmedAuthorizations;
|
||||
|
||||
class ChangeAuthorizationSettingsOnServerLogEvent;
|
||||
class ResetAuthorizationOnServerLogEvent;
|
||||
|
||||
void start_up() final;
|
||||
|
||||
@ -98,16 +99,13 @@ class AccountManager final : public Actor {
|
||||
|
||||
void send_update_unconfirmed_session() const;
|
||||
|
||||
uint64 save_change_authorization_settings_on_server_log_event(int64 hash, bool set_encrypted_requests_disabled,
|
||||
bool encrypted_requests_disabled,
|
||||
bool set_call_requests_disabled,
|
||||
bool call_requests_disabled, bool confirm);
|
||||
|
||||
void change_authorization_settings_on_server(int64 hash, bool set_encrypted_requests_disabled,
|
||||
bool encrypted_requests_disabled, bool set_call_requests_disabled,
|
||||
bool call_requests_disabled, bool confirm, uint64 log_event_id,
|
||||
Promise<Unit> &&promise);
|
||||
|
||||
void reset_authorization_on_server(int64 hash, uint64 log_event_id, Promise<Unit> &&promise);
|
||||
|
||||
Td *td_;
|
||||
ActorShared<> parent_;
|
||||
|
||||
|
@ -145,6 +145,7 @@ Status init_binlog(Binlog &binlog, string path, BinlogKeyValue<Binlog> &binlog_p
|
||||
events.save_app_log_events.push_back(event.clone());
|
||||
break;
|
||||
case LogEvent::HandlerType::ChangeAuthorizationSettingsOnServer:
|
||||
case LogEvent::HandlerType::ResetAuthorizationOnServer:
|
||||
events.to_account_manager.push_back(event.clone());
|
||||
break;
|
||||
case LogEvent::HandlerType::BinlogPmcMagic:
|
||||
|
@ -113,6 +113,7 @@ class LogEvent {
|
||||
SendStory = 0x403,
|
||||
EditStory = 0x404,
|
||||
ChangeAuthorizationSettingsOnServer = 0x500,
|
||||
ResetAuthorizationOnServer = 0x501,
|
||||
ConfigPmcMagic = 0x1f18,
|
||||
BinlogPmcMagic = 0x4327
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user