Rename message_ttl_setting to message_ttl.

This commit is contained in:
levlam 2021-12-21 14:06:15 +03:00
parent 81cebe39eb
commit 4e29d0e232
13 changed files with 122 additions and 123 deletions

View File

@ -361,7 +361,7 @@ set(TDLIB_SOURCE
td/telegram/MessageSearchFilter.cpp td/telegram/MessageSearchFilter.cpp
td/telegram/MessageSender.cpp td/telegram/MessageSender.cpp
td/telegram/MessagesManager.cpp td/telegram/MessagesManager.cpp
td/telegram/MessageTtlSetting.cpp td/telegram/MessageTtl.cpp
td/telegram/misc.cpp td/telegram/misc.cpp
td/telegram/net/AuthDataShared.cpp td/telegram/net/AuthDataShared.cpp
td/telegram/net/ConnectionCreator.cpp td/telegram/net/ConnectionCreator.cpp
@ -566,7 +566,7 @@ set(TDLIB_SOURCE
td/telegram/MessageSearchFilter.h td/telegram/MessageSearchFilter.h
td/telegram/MessageSender.h td/telegram/MessageSender.h
td/telegram/MessagesManager.h td/telegram/MessagesManager.h
td/telegram/MessageTtlSetting.h td/telegram/MessageTtl.h
td/telegram/misc.h td/telegram/misc.h
td/telegram/net/AuthDataShared.h td/telegram/net/AuthDataShared.h
td/telegram/net/ConnectionCreator.h td/telegram/net/ConnectionCreator.h

View File

@ -982,7 +982,7 @@ videoChat group_call_id:int32 has_participants:Bool default_participant_id:Messa
//@last_read_outbox_message_id Identifier of the last read outgoing message //@last_read_outbox_message_id Identifier of the last read outgoing message
//@unread_mention_count Number of unread messages with a mention/reply in the chat //@unread_mention_count Number of unread messages with a mention/reply in the chat
//@notification_settings Notification settings for this chat //@notification_settings Notification settings for this chat
//@message_ttl_setting Current message Time To Live setting (self-destruct timer) for the chat; 0 if not defined. TTL is counted from the time message or its content is viewed in secret chats and from the send date in other chats //@message_ttl Current message Time To Live setting (self-destruct timer) for the chat; 0 if not defined. TTL is counted from the time message or its content is viewed in secret chats and from the send date in other chats
//@theme_name If non-empty, name of a theme, set for the chat //@theme_name If non-empty, name of a theme, set for the chat
//@action_bar Information about actions which must be possible to do through the chat action bar; may be null //@action_bar Information about actions which must be possible to do through the chat action bar; may be null
//@video_chat Information about video chat of the chat //@video_chat Information about video chat of the chat
@ -990,7 +990,7 @@ videoChat group_call_id:int32 has_participants:Bool default_participant_id:Messa
//@reply_markup_message_id Identifier of the message from which reply markup needs to be used; 0 if there is no default custom reply markup in the chat //@reply_markup_message_id Identifier of the message from which reply markup needs to be used; 0 if there is no default custom reply markup in the chat
//@draft_message A draft of a message in the chat; may be null //@draft_message A draft of a message in the chat; may be null
//@client_data Application-specific data associated with the chat. (For example, the chat scroll position or local chat notification settings can be stored here.) Persistent if the message database is used //@client_data Application-specific data associated with the chat. (For example, the chat scroll position or local chat notification settings can be stored here.) Persistent if the message database is used
chat id:int53 type:ChatType title:string photo:chatPhotoInfo permissions:chatPermissions last_message:message positions:vector<chatPosition> message_sender_id:MessageSender has_protected_content:Bool is_marked_as_unread:Bool is_blocked:Bool has_scheduled_messages:Bool can_be_deleted_only_for_self:Bool can_be_deleted_for_all_users:Bool can_be_reported:Bool default_disable_notification:Bool unread_count:int32 last_read_inbox_message_id:int53 last_read_outbox_message_id:int53 unread_mention_count:int32 notification_settings:chatNotificationSettings message_ttl_setting:int32 theme_name:string action_bar:ChatActionBar video_chat:videoChat pending_join_requests:chatJoinRequestsInfo reply_markup_message_id:int53 draft_message:draftMessage client_data:string = Chat; chat id:int53 type:ChatType title:string photo:chatPhotoInfo permissions:chatPermissions last_message:message positions:vector<chatPosition> message_sender_id:MessageSender has_protected_content:Bool is_marked_as_unread:Bool is_blocked:Bool has_scheduled_messages:Bool can_be_deleted_only_for_self:Bool can_be_deleted_for_all_users:Bool can_be_reported:Bool default_disable_notification:Bool unread_count:int32 last_read_inbox_message_id:int53 last_read_outbox_message_id:int53 unread_mention_count:int32 notification_settings:chatNotificationSettings message_ttl:int32 theme_name:string action_bar:ChatActionBar video_chat:videoChat pending_join_requests:chatJoinRequestsInfo reply_markup_message_id:int53 draft_message:draftMessage client_data:string = Chat;
//@description Represents a list of chats @total_count Approximate total count of chats found @chat_ids List of chat identifiers //@description Represents a list of chats @total_count Approximate total count of chats found @chat_ids List of chat identifiers
chats total_count:int32 chat_ids:vector<int53> = Chats; chats total_count:int32 chat_ids:vector<int53> = Chats;
@ -1842,7 +1842,7 @@ messageScreenshotTaken = MessageContent;
//@description A theme in the chat has been changed @theme_name If non-empty, name of a new theme, set for the chat. Otherwise chat theme was reset to the default one //@description A theme in the chat has been changed @theme_name If non-empty, name of a new theme, set for the chat. Otherwise chat theme was reset to the default one
messageChatSetTheme theme_name:string = MessageContent; messageChatSetTheme theme_name:string = MessageContent;
//@description The TTL (Time To Live) setting for messages in the chat has been changed @ttl New message TTL setting //@description The TTL (Time To Live) setting for messages in the chat has been changed @ttl New message TTL
messageChatSetTtl ttl:int32 = MessageContent; messageChatSetTtl ttl:int32 = MessageContent;
//@description A non-standard action has happened in the chat @text Message text to be shown in the chat //@description A non-standard action has happened in the chat @text Message text to be shown in the chat
@ -2594,8 +2594,8 @@ chatEventLinkedChatChanged old_linked_chat_id:int53 new_linked_chat_id:int53 = C
//@description The slow_mode_delay setting of a supergroup was changed @old_slow_mode_delay Previous value of slow_mode_delay, in seconds @new_slow_mode_delay New value of slow_mode_delay, in seconds //@description The slow_mode_delay setting of a supergroup was changed @old_slow_mode_delay Previous value of slow_mode_delay, in seconds @new_slow_mode_delay New value of slow_mode_delay, in seconds
chatEventSlowModeDelayChanged old_slow_mode_delay:int32 new_slow_mode_delay:int32 = ChatEventAction; chatEventSlowModeDelayChanged old_slow_mode_delay:int32 new_slow_mode_delay:int32 = ChatEventAction;
//@description The message TTL setting was changed @old_message_ttl_setting Previous value of message_ttl_setting @new_message_ttl_setting New value of message_ttl_setting //@description The message TTL was changed @old_message_ttl Previous value of message_ttl @new_message_ttl New value of message_ttl
chatEventMessageTtlSettingChanged old_message_ttl_setting:int32 new_message_ttl_setting:int32 = ChatEventAction; chatEventMessageTtlChanged old_message_ttl:int32 new_message_ttl:int32 = ChatEventAction;
//@description The sign_messages setting of a channel was toggled @sign_messages New value of sign_messages //@description The sign_messages setting of a channel was toggled @sign_messages New value of sign_messages
chatEventSignMessagesToggled sign_messages:Bool = ChatEventAction; chatEventSignMessagesToggled sign_messages:Bool = ChatEventAction;
@ -3761,8 +3761,8 @@ updateChatNotificationSettings chat_id:int53 notification_settings:chatNotificat
//@description Notification settings for some type of chats were updated @scope Types of chats for which notification settings were updated @notification_settings The new notification settings //@description Notification settings for some type of chats were updated @scope Types of chats for which notification settings were updated @notification_settings The new notification settings
updateScopeNotificationSettings scope:NotificationSettingsScope notification_settings:scopeNotificationSettings = Update; updateScopeNotificationSettings scope:NotificationSettingsScope notification_settings:scopeNotificationSettings = Update;
//@description The message Time To Live setting for a chat was changed @chat_id Chat identifier @message_ttl_setting New value of message_ttl_setting //@description The message Time To Live setting for a chat was changed @chat_id Chat identifier @message_ttl New value of message_ttl
updateChatMessageTtlSetting chat_id:int53 message_ttl_setting:int32 = Update; updateChatMessageTtl chat_id:int53 message_ttl:int32 = Update;
//@description The chat action bar was changed @chat_id Chat identifier @action_bar The new value of the action bar; may be null //@description The chat action bar was changed @chat_id Chat identifier @action_bar The new value of the action bar; may be null
updateChatActionBar chat_id:int53 action_bar:ChatActionBar = Update; updateChatActionBar chat_id:int53 action_bar:ChatActionBar = Update;
@ -4767,10 +4767,10 @@ setChatTitle chat_id:int53 title:string = Ok;
//@chat_id Chat identifier @photo New chat photo; pass null to delete the chat photo //@chat_id Chat identifier @photo New chat photo; pass null to delete the chat photo
setChatPhoto chat_id:int53 photo:InputChatPhoto = Ok; setChatPhoto chat_id:int53 photo:InputChatPhoto = Ok;
//@description Changes the message TTL setting (sets a new self-destruct timer) in a chat. Requires can_delete_messages administrator right in basic groups, supergroups and channels //@description Changes the message TTL in a chat. Requires can_delete_messages administrator right in basic groups, supergroups and channels
//-Message TTL setting of a chat with the current user (Saved Messages) and the chat 777000 (Telegram) can't be changed //-Message TTL can't be changed in a chat with the current user (Saved Messages) and the chat 777000 (Telegram)
//@chat_id Chat identifier @ttl New TTL value, in seconds; must be one of 0, 86400, 7 * 86400, or 31 * 86400 unless the chat is secret //@chat_id Chat identifier @ttl New TTL value, in seconds; must be one of 0, 86400, 7 * 86400, or 31 * 86400 unless the chat is secret
setChatMessageTtlSetting chat_id:int53 ttl:int32 = Ok; setChatMessageTtl chat_id:int53 ttl:int32 = Ok;
//@description Changes the chat members permissions. Supported only for basic groups and supergroups. Requires can_restrict_members administrator right //@description Changes the chat members permissions. Supported only for basic groups and supergroups. Requires can_restrict_members administrator right
//@chat_id Chat identifier @permissions New non-administrator members permissions in the chat //@chat_id Chat identifier @permissions New non-administrator members permissions in the chat

View File

@ -24,7 +24,7 @@
#include "td/telegram/logevent/LogEventHelper.h" #include "td/telegram/logevent/LogEventHelper.h"
#include "td/telegram/MessageSender.h" #include "td/telegram/MessageSender.h"
#include "td/telegram/MessagesManager.h" #include "td/telegram/MessagesManager.h"
#include "td/telegram/MessageTtlSetting.h" #include "td/telegram/MessageTtl.h"
#include "td/telegram/misc.h" #include "td/telegram/misc.h"
#include "td/telegram/net/NetQuery.h" #include "td/telegram/net/NetQuery.h"
#include "td/telegram/NotificationManager.h" #include "td/telegram/NotificationManager.h"
@ -10132,8 +10132,8 @@ void ContactsManager::update_secret_chat(SecretChat *c, SecretChatId secret_chat
c->is_state_changed = false; c->is_state_changed = false;
} }
if (c->is_ttl_changed) { if (c->is_ttl_changed) {
send_closure_later(G()->messages_manager(), &MessagesManager::on_update_dialog_message_ttl_setting, send_closure_later(G()->messages_manager(), &MessagesManager::on_update_dialog_message_ttl,
DialogId(secret_chat_id), MessageTtlSetting(c->ttl)); DialogId(secret_chat_id), MessageTtl(c->ttl));
c->is_ttl_changed = false; c->is_ttl_changed = false;
} }
} }
@ -10342,11 +10342,11 @@ void ContactsManager::on_get_user_full(tl_object_ptr<telegram_api::userFull> &&u
td_->messages_manager_->on_update_dialog_has_scheduled_server_messages( td_->messages_manager_->on_update_dialog_has_scheduled_server_messages(
DialogId(user_id), (user->flags_ & USER_FULL_FLAG_HAS_SCHEDULED_MESSAGES) != 0); DialogId(user_id), (user->flags_ & USER_FULL_FLAG_HAS_SCHEDULED_MESSAGES) != 0);
{ {
MessageTtlSetting message_ttl_setting; MessageTtl message_ttl;
if ((user->flags_ & USER_FULL_FLAG_HAS_MESSAGE_TTL) != 0) { if ((user->flags_ & USER_FULL_FLAG_HAS_MESSAGE_TTL) != 0) {
message_ttl_setting = MessageTtlSetting(user->ttl_period_); message_ttl = MessageTtl(user->ttl_period_);
} }
td_->messages_manager_->on_update_dialog_message_ttl_setting(DialogId(user_id), message_ttl_setting); td_->messages_manager_->on_update_dialog_message_ttl(DialogId(user_id), message_ttl);
} }
UserFull *user_full = add_user_full(user_id); UserFull *user_full = add_user_full(user_id);
@ -10619,11 +10619,11 @@ void ContactsManager::on_get_chat_full(tl_object_ptr<telegram_api::ChatFull> &&c
default_join_group_call_as_dialog_id, false); default_join_group_call_as_dialog_id, false);
} }
{ {
MessageTtlSetting message_ttl_setting; MessageTtl message_ttl;
if ((chat->flags_ & CHAT_FULL_FLAG_HAS_MESSAGE_TTL) != 0) { if ((chat->flags_ & CHAT_FULL_FLAG_HAS_MESSAGE_TTL) != 0) {
message_ttl_setting = MessageTtlSetting(chat->ttl_period_); message_ttl = MessageTtl(chat->ttl_period_);
} }
td_->messages_manager_->on_update_dialog_message_ttl_setting(DialogId(chat_id), message_ttl_setting); td_->messages_manager_->on_update_dialog_message_ttl(DialogId(chat_id), message_ttl);
} }
ChatFull *chat_full = add_chat_full(chat_id); ChatFull *chat_full = add_chat_full(chat_id);
@ -10696,11 +10696,11 @@ void ContactsManager::on_get_chat_full(tl_object_ptr<telegram_api::ChatFull> &&c
std::move(channel->recent_requesters_)); std::move(channel->recent_requesters_));
{ {
MessageTtlSetting message_ttl_setting; MessageTtl message_ttl;
if ((channel->flags_ & CHANNEL_FULL_FLAG_HAS_MESSAGE_TTL) != 0) { if ((channel->flags_ & CHANNEL_FULL_FLAG_HAS_MESSAGE_TTL) != 0) {
message_ttl_setting = MessageTtlSetting(channel->ttl_period_); message_ttl = MessageTtl(channel->ttl_period_);
} }
td_->messages_manager_->on_update_dialog_message_ttl_setting(DialogId(channel_id), message_ttl_setting); td_->messages_manager_->on_update_dialog_message_ttl(DialogId(channel_id), message_ttl);
} }
auto c = get_channel(channel_id); auto c = get_channel(channel_id);

View File

@ -17,7 +17,7 @@
#include "td/telegram/InputGroupCallId.h" #include "td/telegram/InputGroupCallId.h"
#include "td/telegram/MessageSender.h" #include "td/telegram/MessageSender.h"
#include "td/telegram/MessagesManager.h" #include "td/telegram/MessagesManager.h"
#include "td/telegram/MessageTtlSetting.h" #include "td/telegram/MessageTtl.h"
#include "td/telegram/StickersManager.h" #include "td/telegram/StickersManager.h"
#include "td/telegram/Td.h" #include "td/telegram/Td.h"
#include "td/telegram/telegram_api.h" #include "td/telegram/telegram_api.h"
@ -324,10 +324,10 @@ static td_api::object_ptr<td_api::ChatEventAction> get_chat_event_action_object(
} }
case telegram_api::channelAdminLogEventActionChangeHistoryTTL::ID: { case telegram_api::channelAdminLogEventActionChangeHistoryTTL::ID: {
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionChangeHistoryTTL>(action_ptr); auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionChangeHistoryTTL>(action_ptr);
auto old_value = MessageTtlSetting(clamp(action->prev_value_, 0, 86400 * 366)); auto old_value = MessageTtl(clamp(action->prev_value_, 0, 86400 * 366));
auto new_value = MessageTtlSetting(clamp(action->new_value_, 0, 86400 * 366)); auto new_value = MessageTtl(clamp(action->new_value_, 0, 86400 * 366));
return td_api::make_object<td_api::chatEventMessageTtlSettingChanged>(old_value.get_message_ttl_setting_object(), return td_api::make_object<td_api::chatEventMessageTtlChanged>(old_value.get_message_ttl_object(),
new_value.get_message_ttl_setting_object()); new_value.get_message_ttl_object());
} }
case telegram_api::channelAdminLogEventActionToggleNoForwards::ID: { case telegram_api::channelAdminLogEventActionToggleNoForwards::ID: {
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionToggleNoForwards>(action_ptr); auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionToggleNoForwards>(action_ptr);

View File

@ -0,0 +1,27 @@
//
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2021
//
// 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)
//
#include "td/telegram/MessageTtl.h"
namespace td {
bool MessageTtl::is_empty() const {
return period_ == 0;
}
int32 MessageTtl::get_message_ttl_object() const {
return period_;
}
bool operator==(const MessageTtl &lhs, const MessageTtl &rhs) {
return lhs.period_ == rhs.period_;
}
StringBuilder &operator<<(StringBuilder &string_builder, const MessageTtl &message_ttl) {
return string_builder << "MessageTtl[" << message_ttl.period_ << "]";
}
} // namespace td

View File

@ -14,43 +14,43 @@
namespace td { namespace td {
class MessageTtlSetting { class MessageTtl {
int32 ttl_period_ = 0; int32 period_ = 0;
friend StringBuilder &operator<<(StringBuilder &string_builder, const MessageTtlSetting &message_ttl_setting); friend StringBuilder &operator<<(StringBuilder &string_builder, const MessageTtl &message_ttl);
friend bool operator==(const MessageTtlSetting &lhs, const MessageTtlSetting &rhs); friend bool operator==(const MessageTtl &lhs, const MessageTtl &rhs);
public: public:
MessageTtlSetting() = default; MessageTtl() = default;
template <class T, typename = std::enable_if_t<std::is_convertible<T, int32>::value>> template <class T, typename = std::enable_if_t<std::is_convertible<T, int32>::value>>
MessageTtlSetting(T ttl_period) = delete; MessageTtl(T period) = delete;
explicit MessageTtlSetting(int32 ttl_period) : ttl_period_(ttl_period) { explicit MessageTtl(int32 period) : period_(period) {
} }
bool is_empty() const; bool is_empty() const;
int32 get_message_ttl_setting_object() const; int32 get_message_ttl_object() const;
template <class StorerT> template <class StorerT>
void store(StorerT &storer) const { void store(StorerT &storer) const {
td::store(ttl_period_, storer); td::store(period_, storer);
} }
template <class ParserT> template <class ParserT>
void parse(ParserT &parser) { void parse(ParserT &parser) {
td::parse(ttl_period_, parser); td::parse(period_, parser);
} }
}; };
bool operator==(const MessageTtlSetting &lhs, const MessageTtlSetting &rhs); bool operator==(const MessageTtl &lhs, const MessageTtl &rhs);
inline bool operator!=(const MessageTtlSetting &lhs, const MessageTtlSetting &rhs) { inline bool operator!=(const MessageTtl &lhs, const MessageTtl &rhs) {
return !(lhs == rhs); return !(lhs == rhs);
} }
StringBuilder &operator<<(StringBuilder &string_builder, const MessageTtlSetting &message_ttl_setting); StringBuilder &operator<<(StringBuilder &string_builder, const MessageTtl &message_ttl);
} // namespace td } // namespace td

View File

@ -1,27 +0,0 @@
//
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2021
//
// 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)
//
#include "td/telegram/MessageTtlSetting.h"
namespace td {
bool MessageTtlSetting::is_empty() const {
return ttl_period_ == 0;
}
int32 MessageTtlSetting::get_message_ttl_setting_object() const {
return ttl_period_;
}
bool operator==(const MessageTtlSetting &lhs, const MessageTtlSetting &rhs) {
return lhs.ttl_period_ == rhs.ttl_period_;
}
StringBuilder &operator<<(StringBuilder &string_builder, const MessageTtlSetting &message_ttl_setting) {
return string_builder << "MessageTtlSetting[" << message_ttl_setting.ttl_period_ << "]";
}
} // namespace td

View File

@ -5297,7 +5297,7 @@ void MessagesManager::Dialog::store(StorerT &storer) const {
bool has_pending_read_channel_inbox = pending_read_channel_inbox_pts != 0; bool has_pending_read_channel_inbox = pending_read_channel_inbox_pts != 0;
bool has_last_yet_unsent_message = last_message_id.is_valid() && last_message_id.is_yet_unsent(); bool has_last_yet_unsent_message = last_message_id.is_valid() && last_message_id.is_yet_unsent();
bool has_active_group_call_id = active_group_call_id.is_valid(); bool has_active_group_call_id = active_group_call_id.is_valid();
bool has_message_ttl_setting = !message_ttl_setting.is_empty(); bool has_message_ttl = !message_ttl.is_empty();
bool has_default_join_group_call_as_dialog_id = default_join_group_call_as_dialog_id.is_valid(); bool has_default_join_group_call_as_dialog_id = default_join_group_call_as_dialog_id.is_valid();
bool store_has_bots = dialog_type == DialogType::Chat || dialog_type == DialogType::Channel; bool store_has_bots = dialog_type == DialogType::Chat || dialog_type == DialogType::Channel;
bool has_theme_name = !theme_name.empty(); bool has_theme_name = !theme_name.empty();
@ -5364,8 +5364,8 @@ void MessagesManager::Dialog::store(StorerT &storer) const {
STORE_FLAG(is_group_call_empty); STORE_FLAG(is_group_call_empty);
STORE_FLAG(has_active_group_call_id); STORE_FLAG(has_active_group_call_id);
STORE_FLAG(false); // action_bar->can_invite_members STORE_FLAG(false); // action_bar->can_invite_members
STORE_FLAG(has_message_ttl_setting); STORE_FLAG(has_message_ttl);
STORE_FLAG(is_message_ttl_setting_inited); STORE_FLAG(is_message_ttl_inited);
STORE_FLAG(has_default_join_group_call_as_dialog_id); STORE_FLAG(has_default_join_group_call_as_dialog_id);
STORE_FLAG(store_has_bots ? has_bots : false); STORE_FLAG(store_has_bots ? has_bots : false);
STORE_FLAG(store_has_bots ? is_has_bots_inited : false); STORE_FLAG(store_has_bots ? is_has_bots_inited : false);
@ -5465,8 +5465,8 @@ void MessagesManager::Dialog::store(StorerT &storer) const {
if (has_active_group_call_id) { if (has_active_group_call_id) {
store(active_group_call_id, storer); store(active_group_call_id, storer);
} }
if (has_message_ttl_setting) { if (has_message_ttl) {
store(message_ttl_setting, storer); store(message_ttl, storer);
} }
if (has_default_join_group_call_as_dialog_id) { if (has_default_join_group_call_as_dialog_id) {
store(default_join_group_call_as_dialog_id, storer); store(default_join_group_call_as_dialog_id, storer);
@ -5514,7 +5514,7 @@ void MessagesManager::Dialog::parse(ParserT &parser) {
bool has_folder_id = false; bool has_folder_id = false;
bool has_pending_read_channel_inbox = false; bool has_pending_read_channel_inbox = false;
bool has_active_group_call_id = false; bool has_active_group_call_id = false;
bool has_message_ttl_setting = false; bool has_message_ttl = false;
bool has_default_join_group_call_as_dialog_id = false; bool has_default_join_group_call_as_dialog_id = false;
bool has_theme_name = false; bool has_theme_name = false;
bool has_flags3 = false; bool has_flags3 = false;
@ -5588,8 +5588,8 @@ void MessagesManager::Dialog::parse(ParserT &parser) {
PARSE_FLAG(is_group_call_empty); PARSE_FLAG(is_group_call_empty);
PARSE_FLAG(has_active_group_call_id); PARSE_FLAG(has_active_group_call_id);
PARSE_FLAG(action_bar_can_invite_members); PARSE_FLAG(action_bar_can_invite_members);
PARSE_FLAG(has_message_ttl_setting); PARSE_FLAG(has_message_ttl);
PARSE_FLAG(is_message_ttl_setting_inited); PARSE_FLAG(is_message_ttl_inited);
PARSE_FLAG(has_default_join_group_call_as_dialog_id); PARSE_FLAG(has_default_join_group_call_as_dialog_id);
PARSE_FLAG(has_bots); PARSE_FLAG(has_bots);
PARSE_FLAG(is_has_bots_inited); PARSE_FLAG(is_has_bots_inited);
@ -5608,7 +5608,7 @@ void MessagesManager::Dialog::parse(ParserT &parser) {
is_is_blocked_inited = false; is_is_blocked_inited = false;
has_active_group_call = false; has_active_group_call = false;
is_group_call_empty = false; is_group_call_empty = false;
is_message_ttl_setting_inited = false; is_message_ttl_inited = false;
has_bots = false; has_bots = false;
is_has_bots_inited = false; is_has_bots_inited = false;
is_theme_name_inited = false; is_theme_name_inited = false;
@ -5743,8 +5743,8 @@ void MessagesManager::Dialog::parse(ParserT &parser) {
if (has_active_group_call_id) { if (has_active_group_call_id) {
parse(active_group_call_id, parser); parse(active_group_call_id, parser);
} }
if (has_message_ttl_setting) { if (has_message_ttl) {
parse(message_ttl_setting, parser); parse(message_ttl, parser);
} }
if (has_default_join_group_call_as_dialog_id) { if (has_default_join_group_call_as_dialog_id) {
parse(default_join_group_call_as_dialog_id, parser); parse(default_join_group_call_as_dialog_id, parser);
@ -20401,10 +20401,10 @@ td_api::object_ptr<td_api::chat> MessagesManager::get_chat_object(const Dialog *
can_report_dialog(d->dialog_id), d->notification_settings.silent_send_message, can_report_dialog(d->dialog_id), d->notification_settings.silent_send_message,
d->server_unread_count + d->local_unread_count, d->last_read_inbox_message_id.get(), d->server_unread_count + d->local_unread_count, d->last_read_inbox_message_id.get(),
d->last_read_outbox_message_id.get(), d->unread_mention_count, d->last_read_outbox_message_id.get(), d->unread_mention_count,
get_chat_notification_settings_object(&d->notification_settings), get_chat_notification_settings_object(&d->notification_settings), d->message_ttl.get_message_ttl_object(),
d->message_ttl_setting.get_message_ttl_setting_object(), get_dialog_theme_name(d), get_chat_action_bar_object(d), get_dialog_theme_name(d), get_chat_action_bar_object(d), get_video_chat_object(d),
get_video_chat_object(d), get_chat_join_requests_info_object(d), d->reply_markup_message_id.get(), get_chat_join_requests_info_object(d), d->reply_markup_message_id.get(), std::move(draft_message),
std::move(draft_message), d->client_data); d->client_data);
} }
tl_object_ptr<td_api::chat> MessagesManager::get_chat_object(DialogId dialog_id) const { tl_object_ptr<td_api::chat> MessagesManager::get_chat_object(DialogId dialog_id) const {
@ -29593,13 +29593,13 @@ void MessagesManager::send_update_chat_message_sender(const Dialog *d) {
td_api::make_object<td_api::updateChatMessageSender>(d->dialog_id.get(), get_default_message_sender_object(d))); td_api::make_object<td_api::updateChatMessageSender>(d->dialog_id.get(), get_default_message_sender_object(d)));
} }
void MessagesManager::send_update_chat_message_ttl_setting(const Dialog *d) { void MessagesManager::send_update_chat_message_ttl(const Dialog *d) {
CHECK(d != nullptr); CHECK(d != nullptr);
LOG_CHECK(d->is_update_new_chat_sent) << "Wrong " << d->dialog_id << " in send_update_chat_message_ttl_setting"; LOG_CHECK(d->is_update_new_chat_sent) << "Wrong " << d->dialog_id << " in send_update_chat_message_ttl";
on_dialog_updated(d->dialog_id, "send_update_chat_message_ttl_setting"); on_dialog_updated(d->dialog_id, "send_update_chat_message_ttl");
send_closure(G()->td(), &Td::send_update, send_closure(
td_api::make_object<td_api::updateChatMessageTtlSetting>( G()->td(), &Td::send_update,
d->dialog_id.get(), d->message_ttl_setting.get_message_ttl_setting_object())); td_api::make_object<td_api::updateChatMessageTtl>(d->dialog_id.get(), d->message_ttl.get_message_ttl_object()));
} }
void MessagesManager::send_update_chat_has_scheduled_messages(Dialog *d, bool from_deletion) { void MessagesManager::send_update_chat_has_scheduled_messages(Dialog *d, bool from_deletion) {
@ -31013,21 +31013,21 @@ void MessagesManager::on_update_dialog_default_send_message_as_dialog_id(DialogI
} }
} }
void MessagesManager::on_update_dialog_message_ttl_setting(DialogId dialog_id, MessageTtlSetting message_ttl_setting) { void MessagesManager::on_update_dialog_message_ttl(DialogId dialog_id, MessageTtl message_ttl) {
auto d = get_dialog_force(dialog_id, "on_update_dialog_message_ttl_setting"); auto d = get_dialog_force(dialog_id, "on_update_dialog_message_ttl");
if (d == nullptr) { if (d == nullptr) {
// nothing to do // nothing to do
return; return;
} }
if (d->message_ttl_setting != message_ttl_setting) { if (d->message_ttl != message_ttl) {
d->message_ttl_setting = message_ttl_setting; d->message_ttl = message_ttl;
d->is_message_ttl_setting_inited = true; d->is_message_ttl_inited = true;
send_update_chat_message_ttl_setting(d); send_update_chat_message_ttl(d);
} }
if (!d->is_message_ttl_setting_inited) { if (!d->is_message_ttl_inited) {
d->is_message_ttl_setting_inited = true; d->is_message_ttl_inited = true;
on_dialog_updated(dialog_id, "on_update_dialog_message_ttl_setting"); on_dialog_updated(dialog_id, "on_update_dialog_message_ttl");
} }
} }
@ -32175,12 +32175,12 @@ void MessagesManager::set_dialog_title(DialogId dialog_id, const string &title,
td_->create_handler<EditDialogTitleQuery>(std::move(promise))->send(dialog_id, new_title); td_->create_handler<EditDialogTitleQuery>(std::move(promise))->send(dialog_id, new_title);
} }
void MessagesManager::set_dialog_message_ttl_setting(DialogId dialog_id, int32 ttl, Promise<Unit> &&promise) { void MessagesManager::set_dialog_message_ttl(DialogId dialog_id, int32 ttl, Promise<Unit> &&promise) {
if (ttl < 0) { if (ttl < 0) {
return promise.set_error(Status::Error(400, "Message auto-delete time can't be negative")); return promise.set_error(Status::Error(400, "Message auto-delete time can't be negative"));
} }
Dialog *d = get_dialog_force(dialog_id, "set_dialog_message_ttl_setting"); Dialog *d = get_dialog_force(dialog_id, "set_dialog_message_ttl");
if (d == nullptr) { if (d == nullptr) {
return promise.set_error(Status::Error(400, "Chat not found")); return promise.set_error(Status::Error(400, "Chat not found"));
} }
@ -32231,7 +32231,7 @@ void MessagesManager::set_dialog_message_ttl_setting(DialogId dialog_id, int32 t
send_update_new_message(d, m); send_update_new_message(d, m);
if (need_update_dialog_pos) { if (need_update_dialog_pos) {
send_update_chat_last_message(d, "set_dialog_message_ttl_setting"); send_update_chat_last_message(d, "set_dialog_message_ttl");
} }
int64 random_id = begin_send_message(dialog_id, m); int64 random_id = begin_send_message(dialog_id, m);
@ -34848,9 +34848,8 @@ MessagesManager::Dialog *MessagesManager::add_new_dialog(unique_ptr<Dialog> &&d,
do_set_dialog_folder_id( do_set_dialog_folder_id(
d.get(), td_->contacts_manager_->get_secret_chat_initial_folder_id(dialog_id.get_secret_chat_id())); d.get(), td_->contacts_manager_->get_secret_chat_initial_folder_id(dialog_id.get_secret_chat_id()));
} }
d->message_ttl_setting = d->message_ttl = MessageTtl(td_->contacts_manager_->get_secret_chat_ttl(dialog_id.get_secret_chat_id()));
MessageTtlSetting(td_->contacts_manager_->get_secret_chat_ttl(dialog_id.get_secret_chat_id())); d->is_message_ttl_inited = true;
d->is_message_ttl_setting_inited = true;
d->has_bots = td_->contacts_manager_->is_user_bot( d->has_bots = td_->contacts_manager_->is_user_bot(
td_->contacts_manager_->get_secret_chat_user_id(dialog_id.get_secret_chat_id())); td_->contacts_manager_->get_secret_chat_user_id(dialog_id.get_secret_chat_id()));
d->is_has_bots_inited = true; d->is_has_bots_inited = true;
@ -34988,10 +34987,10 @@ void MessagesManager::fix_new_dialog(Dialog *d, unique_ptr<Message> &&last_datab
order != DEFAULT_ORDER) { order != DEFAULT_ORDER) {
// asynchronously get dialog folder identifier from the server // asynchronously get dialog folder identifier from the server
get_dialog_info_full(dialog_id, Auto(), "fix_new_dialog init folder_id"); get_dialog_info_full(dialog_id, Auto(), "fix_new_dialog init folder_id");
} else if (!d->is_message_ttl_setting_inited && !td_->auth_manager_->is_bot() && } else if (!d->is_message_ttl_inited && !td_->auth_manager_->is_bot() &&
have_input_peer(dialog_id, AccessRights::Write)) { have_input_peer(dialog_id, AccessRights::Write)) {
// asynchronously get dialog message TTL setting from the server // asynchronously get dialog message TTL from the server
get_dialog_info_full(dialog_id, Auto(), "fix_new_dialog init message_ttl_setting"); get_dialog_info_full(dialog_id, Auto(), "fix_new_dialog init message_ttl");
} }
if ((!d->know_action_bar || d->need_repair_action_bar) && !td_->auth_manager_->is_bot() && if ((!d->know_action_bar || d->need_repair_action_bar) && !td_->auth_manager_->is_bot() &&
dialog_type != DialogType::SecretChat && dialog_id != get_my_dialog_id() && dialog_type != DialogType::SecretChat && dialog_id != get_my_dialog_id() &&

View File

@ -35,7 +35,7 @@
#include "td/telegram/MessagesDb.h" #include "td/telegram/MessagesDb.h"
#include "td/telegram/MessageSearchFilter.h" #include "td/telegram/MessageSearchFilter.h"
#include "td/telegram/MessageThreadInfo.h" #include "td/telegram/MessageThreadInfo.h"
#include "td/telegram/MessageTtlSetting.h" #include "td/telegram/MessageTtl.h"
#include "td/telegram/net/DcId.h" #include "td/telegram/net/DcId.h"
#include "td/telegram/net/NetQuery.h" #include "td/telegram/net/NetQuery.h"
#include "td/telegram/Notification.h" #include "td/telegram/Notification.h"
@ -310,7 +310,7 @@ class MessagesManager final : public Actor {
void on_update_dialog_default_send_message_as_dialog_id(DialogId dialog_id, DialogId default_send_as_dialog_id, void on_update_dialog_default_send_message_as_dialog_id(DialogId dialog_id, DialogId default_send_as_dialog_id,
bool force); bool force);
void on_update_dialog_message_ttl_setting(DialogId dialog_id, MessageTtlSetting message_ttl_setting); void on_update_dialog_message_ttl(DialogId dialog_id, MessageTtl message_ttl);
void on_update_dialog_filters(); void on_update_dialog_filters();
@ -428,7 +428,7 @@ class MessagesManager final : public Actor {
Result<vector<MessageId>> resend_messages(DialogId dialog_id, vector<MessageId> message_ids) TD_WARN_UNUSED_RESULT; Result<vector<MessageId>> resend_messages(DialogId dialog_id, vector<MessageId> message_ids) TD_WARN_UNUSED_RESULT;
void set_dialog_message_ttl_setting(DialogId dialog_id, int32 ttl, Promise<Unit> &&promise); void set_dialog_message_ttl(DialogId dialog_id, int32 ttl, Promise<Unit> &&promise);
Status send_screenshot_taken_notification_message(DialogId dialog_id); Status send_screenshot_taken_notification_message(DialogId dialog_id);
@ -1205,7 +1205,7 @@ class MessagesManager final : public Actor {
MessageId last_pinned_message_id; MessageId last_pinned_message_id;
MessageId reply_markup_message_id; MessageId reply_markup_message_id;
DialogNotificationSettings notification_settings; DialogNotificationSettings notification_settings;
MessageTtlSetting message_ttl_setting; MessageTtl message_ttl;
unique_ptr<DraftMessage> draft_message; unique_ptr<DraftMessage> draft_message;
unique_ptr<DialogActionBar> action_bar; unique_ptr<DialogActionBar> action_bar;
LogEventIdWithGeneration save_draft_message_log_event_id; LogEventIdWithGeneration save_draft_message_log_event_id;
@ -1287,7 +1287,7 @@ class MessagesManager final : public Actor {
bool had_last_yet_unsent_message = false; // whether the dialog was stored to database without last message bool had_last_yet_unsent_message = false; // whether the dialog was stored to database without last message
bool has_active_group_call = false; bool has_active_group_call = false;
bool is_group_call_empty = false; bool is_group_call_empty = false;
bool is_message_ttl_setting_inited = false; bool is_message_ttl_inited = false;
bool has_expected_active_group_call_id = false; bool has_expected_active_group_call_id = false;
bool has_bots = false; bool has_bots = false;
bool is_has_bots_inited = false; bool is_has_bots_inited = false;
@ -2400,7 +2400,7 @@ class MessagesManager final : public Actor {
void send_update_chat_message_sender(const Dialog *d); void send_update_chat_message_sender(const Dialog *d);
void send_update_chat_message_ttl_setting(const Dialog *d); void send_update_chat_message_ttl(const Dialog *d);
void send_update_chat_has_scheduled_messages(Dialog *d, bool from_deletion); void send_update_chat_has_scheduled_messages(Dialog *d, bool from_deletion);

View File

@ -5958,9 +5958,9 @@ void Td::on_request(uint64 id, const td_api::setChatPhoto &request) {
messages_manager_->set_dialog_photo(DialogId(request.chat_id_), request.photo_, std::move(promise)); messages_manager_->set_dialog_photo(DialogId(request.chat_id_), request.photo_, std::move(promise));
} }
void Td::on_request(uint64 id, const td_api::setChatMessageTtlSetting &request) { void Td::on_request(uint64 id, const td_api::setChatMessageTtl &request) {
CREATE_OK_REQUEST_PROMISE(); CREATE_OK_REQUEST_PROMISE();
messages_manager_->set_dialog_message_ttl_setting(DialogId(request.chat_id_), request.ttl_, std::move(promise)); messages_manager_->set_dialog_message_ttl(DialogId(request.chat_id_), request.ttl_, std::move(promise));
} }
void Td::on_request(uint64 id, const td_api::setChatPermissions &request) { void Td::on_request(uint64 id, const td_api::setChatPermissions &request) {

View File

@ -819,7 +819,7 @@ class Td final : public Actor {
void on_request(uint64 id, const td_api::setChatPhoto &request); void on_request(uint64 id, const td_api::setChatPhoto &request);
void on_request(uint64 id, const td_api::setChatMessageTtlSetting &request); void on_request(uint64 id, const td_api::setChatMessageTtl &request);
void on_request(uint64 id, const td_api::setChatPermissions &request); void on_request(uint64 id, const td_api::setChatPermissions &request);

View File

@ -27,7 +27,7 @@
#include "td/telegram/Location.h" #include "td/telegram/Location.h"
#include "td/telegram/MessageId.h" #include "td/telegram/MessageId.h"
#include "td/telegram/MessagesManager.h" #include "td/telegram/MessagesManager.h"
#include "td/telegram/MessageTtlSetting.h" #include "td/telegram/MessageTtl.h"
#include "td/telegram/net/DcOptions.h" #include "td/telegram/net/DcOptions.h"
#include "td/telegram/net/NetQuery.h" #include "td/telegram/net/NetQuery.h"
#include "td/telegram/NotificationManager.h" #include "td/telegram/NotificationManager.h"
@ -2673,11 +2673,11 @@ void UpdatesManager::on_update(tl_object_ptr<telegram_api::updatePeerSettings> u
} }
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updatePeerHistoryTTL> update, Promise<Unit> &&promise) { void UpdatesManager::on_update(tl_object_ptr<telegram_api::updatePeerHistoryTTL> update, Promise<Unit> &&promise) {
MessageTtlSetting message_ttl_setting; MessageTtl message_ttl;
if ((update->flags_ & telegram_api::updatePeerHistoryTTL::TTL_PERIOD_MASK) != 0) { if ((update->flags_ & telegram_api::updatePeerHistoryTTL::TTL_PERIOD_MASK) != 0) {
message_ttl_setting = MessageTtlSetting(update->ttl_period_); message_ttl = MessageTtl(update->ttl_period_);
} }
td_->messages_manager_->on_update_dialog_message_ttl_setting(DialogId(update->peer_), message_ttl_setting); td_->messages_manager_->on_update_dialog_message_ttl(DialogId(update->peer_), message_ttl);
promise.set_value(Unit()); promise.set_value(Unit());
} }

View File

@ -3905,11 +3905,11 @@ class CliClient final : public Actor {
send_request(td_api::make_object<td_api::setChatPhoto>( send_request(td_api::make_object<td_api::setChatPhoto>(
as_chat_id(chat_id), td_api::make_object<td_api::inputChatPhotoAnimation>(as_input_file(animation), as_chat_id(chat_id), td_api::make_object<td_api::inputChatPhotoAnimation>(as_input_file(animation),
to_double(main_frame_timestamp)))); to_double(main_frame_timestamp))));
} else if (op == "scmts") { } else if (op == "scmt") {
string chat_id; string chat_id;
int32 ttl; int32 ttl;
get_args(args, chat_id, ttl); get_args(args, chat_id, ttl);
send_request(td_api::make_object<td_api::setChatMessageTtlSetting>(as_chat_id(chat_id), ttl)); send_request(td_api::make_object<td_api::setChatMessageTtl>(as_chat_id(chat_id), ttl));
} else if (op == "scperm") { } else if (op == "scperm") {
string chat_id; string chat_id;
string permissions; string permissions;