// // Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024 // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // #pragma once #include "td/telegram/MessageContentType.h" #include "td/telegram/td_api.h" #include "td/utils/common.h" #include "td/utils/StringBuilder.h" #include "td/utils/tl_helpers.h" #include namespace td { class MessageSelfDestructType { int32 ttl_ = 0; friend bool operator==(const MessageSelfDestructType &lhs, const MessageSelfDestructType &rhs); public: MessageSelfDestructType() = default; template ::value>> MessageSelfDestructType(T ttl) = delete; MessageSelfDestructType(int32 ttl, bool allow_immediate) : ttl_(ttl) { if (!allow_immediate && is_immediate()) { ttl_ = 0x7FFFFFFE; } } bool is_valid() const; bool is_empty() const; bool is_immediate() const; bool is_secret_message_content(MessageContentType content_type); void ensure_at_least(int32 ttl); static Result get_message_self_destruct_type( td_api::object_ptr &&self_destruct_type); td_api::object_ptr get_message_self_desctruct_type_object() const; int32 get_input_ttl() const; template void store(StorerT &storer) const { td::store(ttl_, storer); } template void parse(ParserT &parser) { td::parse(ttl_, parser); } }; bool operator==(const MessageSelfDestructType &lhs, const MessageSelfDestructType &rhs); inline bool operator!=(const MessageSelfDestructType &lhs, const MessageSelfDestructType &rhs) { return !(lhs == rhs); } StringBuilder &operator<<(StringBuilder &string_builder, const MessageSelfDestructType &message_self_destruct_type); } // namespace td