Add td_api::getDefaultMessageTtl.
This commit is contained in:
parent
2e163cfa7b
commit
db5a7bb198
@ -6600,6 +6600,9 @@ deleteAccount reason:string password:string = Ok;
|
||||
//@description Changes the default message Time To Live setting (self-destruct timer) for new chats @ttl New account TTL; must be from 0 up to 365 * 86400 and be divisible by 86400
|
||||
setDefaultMessageTtl ttl:messageTtl = Ok;
|
||||
|
||||
//@description Returns default message Time To Live setting (self-destruct timer) for new chats
|
||||
getDefaultMessageTtl = MessageTtl;
|
||||
|
||||
|
||||
//@description Removes a chat action bar without any other action @chat_id Chat identifier
|
||||
removeChatActionBar chat_id:int53 = Ok;
|
||||
|
@ -139,6 +139,34 @@ class SetDefaultHistoryTtlQuery final : public Td::ResultHandler {
|
||||
}
|
||||
};
|
||||
|
||||
class GetDefaultHistoryTtlQuery final : public Td::ResultHandler {
|
||||
Promise<int32> promise_;
|
||||
|
||||
public:
|
||||
explicit GetDefaultHistoryTtlQuery(Promise<int32> &&promise) : promise_(std::move(promise)) {
|
||||
}
|
||||
|
||||
void send() {
|
||||
send_query(G()->net_query_creator().create(telegram_api::messages_getDefaultHistoryTTL()));
|
||||
}
|
||||
|
||||
void on_result(BufferSlice packet) final {
|
||||
auto result_ptr = fetch_result<telegram_api::messages_getDefaultHistoryTTL>(packet);
|
||||
if (result_ptr.is_error()) {
|
||||
return on_error(result_ptr.move_as_error());
|
||||
}
|
||||
|
||||
auto ptr = result_ptr.move_as_ok();
|
||||
LOG(INFO) << "Receive result for GetDefaultHistoryTtlQuery: " << to_string(ptr);
|
||||
|
||||
promise_.set_value(std::move(ptr->period_));
|
||||
}
|
||||
|
||||
void on_error(Status status) final {
|
||||
promise_.set_error(std::move(status));
|
||||
}
|
||||
};
|
||||
|
||||
class SetAccountTtlQuery final : public Td::ResultHandler {
|
||||
Promise<Unit> promise_;
|
||||
|
||||
@ -565,6 +593,10 @@ void set_default_message_ttl(Td *td, int32 message_ttl, Promise<Unit> &&promise)
|
||||
td->create_handler<SetDefaultHistoryTtlQuery>(std::move(promise))->send(message_ttl);
|
||||
}
|
||||
|
||||
void get_default_message_ttl(Td *td, Promise<int32> &&promise) {
|
||||
td->create_handler<GetDefaultHistoryTtlQuery>(std::move(promise))->send();
|
||||
}
|
||||
|
||||
void set_account_ttl(Td *td, int32 account_ttl, Promise<Unit> &&promise) {
|
||||
td->create_handler<SetAccountTtlQuery>(std::move(promise))->send(account_ttl);
|
||||
}
|
||||
|
@ -18,6 +18,8 @@ class Td;
|
||||
|
||||
void set_default_message_ttl(Td *td, int32 message_ttl, Promise<Unit> &&promise);
|
||||
|
||||
void get_default_message_ttl(Td *td, Promise<int32> &&promise);
|
||||
|
||||
void set_account_ttl(Td *td, int32 account_ttl, Promise<Unit> &&promise);
|
||||
|
||||
void get_account_ttl(Td *td, Promise<int32> &&promise);
|
||||
|
@ -4462,6 +4462,19 @@ void Td::on_request(uint64 id, td_api::setUserPrivacySettingRules &request) {
|
||||
std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::getDefaultMessageTtl &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_REQUEST_PROMISE();
|
||||
auto query_promise = PromiseCreator::lambda([promise = std::move(promise)](Result<int32> result) mutable {
|
||||
if (result.is_error()) {
|
||||
promise.set_error(result.move_as_error());
|
||||
} else {
|
||||
promise.set_value(td_api::make_object<td_api::messageTtl>(result.ok()));
|
||||
}
|
||||
});
|
||||
get_default_message_ttl(this, std::move(query_promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::setDefaultMessageTtl &request) {
|
||||
CHECK_IS_USER();
|
||||
if (request.ttl_ == nullptr) {
|
||||
|
@ -470,6 +470,8 @@ class Td final : public Actor {
|
||||
|
||||
void on_request(uint64 id, td_api::setUserPrivacySettingRules &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::getDefaultMessageTtl &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::setDefaultMessageTtl &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::getAccountTtl &request);
|
||||
|
@ -2522,6 +2522,8 @@ class CliClient final : public Actor {
|
||||
int32 ttl;
|
||||
get_args(args, ttl);
|
||||
send_request(td_api::make_object<td_api::setDefaultMessageTtl>(td_api::make_object<td_api::messageTtl>(ttl)));
|
||||
} else if (op == "gdmttl") {
|
||||
send_request(td_api::make_object<td_api::getDefaultMessageTtl>());
|
||||
} else if (op == "sattl") {
|
||||
int32 days;
|
||||
get_args(args, days);
|
||||
|
Loading…
Reference in New Issue
Block a user