Add SetAuthorizationTtlOnServerLogEvent.
This commit is contained in:
parent
fb859209c1
commit
e65059e540
@ -1012,10 +1012,39 @@ void AccountManager::toggle_session_can_accept_secret_chats(int64 session_id, bo
|
||||
std::move(promise));
|
||||
}
|
||||
|
||||
void AccountManager::set_inactive_session_ttl_days(int32 authorization_ttl_days, Promise<Unit> &&promise) {
|
||||
class AccountManager::SetAuthorizationTtlOnServerLogEvent {
|
||||
public:
|
||||
int32 authorization_ttl_days_;
|
||||
|
||||
template <class StorerT>
|
||||
void store(StorerT &storer) const {
|
||||
td::store(authorization_ttl_days_, storer);
|
||||
}
|
||||
|
||||
template <class ParserT>
|
||||
void parse(ParserT &parser) {
|
||||
td::parse(authorization_ttl_days_, parser);
|
||||
}
|
||||
};
|
||||
|
||||
void AccountManager::set_authorization_ttl_on_server(int32 authorization_ttl_days, uint64 log_event_id,
|
||||
Promise<Unit> &&promise) {
|
||||
if (log_event_id == 0) {
|
||||
SetAuthorizationTtlOnServerLogEvent log_event{authorization_ttl_days};
|
||||
log_event_id = binlog_add(G()->td_db()->get_binlog(), LogEvent::HandlerType::SetAuthorizationTtlOnServer,
|
||||
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<SetAuthorizationTtlQuery>(std::move(promise))->send(authorization_ttl_days);
|
||||
}
|
||||
|
||||
void AccountManager::set_inactive_session_ttl_days(int32 authorization_ttl_days, Promise<Unit> &&promise) {
|
||||
set_authorization_ttl_on_server(authorization_ttl_days, 0, std::move(promise));
|
||||
}
|
||||
|
||||
void AccountManager::get_connected_websites(Promise<td_api::object_ptr<td_api::connectedWebsites>> &&promise) {
|
||||
td_->create_handler<GetWebAuthorizationsQuery>(std::move(promise))->send();
|
||||
}
|
||||
@ -1183,6 +1212,13 @@ void AccountManager::on_binlog_events(vector<BinlogEvent> &&events) {
|
||||
set_account_ttl_on_server(log_event.account_ttl_, event.id_, Auto());
|
||||
break;
|
||||
}
|
||||
case LogEvent::HandlerType::SetAuthorizationTtlOnServer: {
|
||||
SetAuthorizationTtlOnServerLogEvent log_event;
|
||||
log_event_parse(log_event, event.get_data()).ensure();
|
||||
|
||||
set_authorization_ttl_on_server(log_event.authorization_ttl_days_, event.id_, Auto());
|
||||
break;
|
||||
}
|
||||
case LogEvent::HandlerType::SetDefaultHistoryTtlOnServer: {
|
||||
SetDefaultHistoryTtlOnServerLogEvent log_event;
|
||||
log_event_parse(log_event, event.get_data()).ensure();
|
||||
|
@ -82,6 +82,7 @@ class AccountManager final : public Actor {
|
||||
class ResetAuthorizationOnServerLogEvent;
|
||||
class ResetAuthorizationsOnServerLogEvent;
|
||||
class SetAccountTtlOnServerLogEvent;
|
||||
class SetAuthorizationTtlOnServerLogEvent;
|
||||
class SetDefaultHistoryTtlOnServerLogEvent;
|
||||
|
||||
void start_up() final;
|
||||
@ -113,6 +114,8 @@ class AccountManager final : public Actor {
|
||||
|
||||
void set_account_ttl_on_server(int32 account_ttl, uint64 log_event_id, Promise<Unit> &&promise);
|
||||
|
||||
void set_authorization_ttl_on_server(int32 authorization_ttl_days, uint64 log_event_id, Promise<Unit> &&promise);
|
||||
|
||||
void set_default_history_ttl_on_server(int32 message_ttl, uint64 log_event_id, Promise<Unit> &&promise);
|
||||
|
||||
Td *td_;
|
||||
|
@ -149,6 +149,7 @@ Status init_binlog(Binlog &binlog, string path, BinlogKeyValue<Binlog> &binlog_p
|
||||
case LogEvent::HandlerType::ResetAuthorizationsOnServer:
|
||||
case LogEvent::HandlerType::SetDefaultHistoryTtlOnServer:
|
||||
case LogEvent::HandlerType::SetAccountTtlOnServer:
|
||||
case LogEvent::HandlerType::SetAuthorizationTtlOnServer:
|
||||
events.to_account_manager.push_back(event.clone());
|
||||
break;
|
||||
case LogEvent::HandlerType::BinlogPmcMagic:
|
||||
|
@ -117,6 +117,7 @@ class LogEvent {
|
||||
ResetAuthorizationsOnServer = 0x502,
|
||||
SetDefaultHistoryTtlOnServer = 0x503,
|
||||
SetAccountTtlOnServer = 0x504,
|
||||
SetAuthorizationTtlOnServer = 0x505,
|
||||
ConfigPmcMagic = 0x1f18,
|
||||
BinlogPmcMagic = 0x4327
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user