Add messageChatSetTtl.from_user_id.
This commit is contained in:
parent
a26274a62b
commit
62e721fa6f
@ -2094,8 +2094,8 @@ 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
|
//@description The TTL (Time To Live) setting for messages in the chat has been changed @ttl New message TTL @from_user_id If not 0, a user identifier, which default setting was automatically applied
|
||||||
messageChatSetTtl ttl:int32 = MessageContent;
|
messageChatSetTtl ttl:int32 from_user_id:int53 = MessageContent;
|
||||||
|
|
||||||
//@description A forum topic has been created @name Name of the topic @icon Icon of the topic
|
//@description A forum topic has been created @name Name of the topic @icon Icon of the topic
|
||||||
messageForumTopicCreated name:string icon:forumTopicIcon = MessageContent;
|
messageForumTopicCreated name:string icon:forumTopicIcon = MessageContent;
|
||||||
|
@ -450,9 +450,10 @@ class MessageScreenshotTaken final : public MessageContent {
|
|||||||
class MessageChatSetTtl final : public MessageContent {
|
class MessageChatSetTtl final : public MessageContent {
|
||||||
public:
|
public:
|
||||||
int32 ttl;
|
int32 ttl;
|
||||||
|
UserId from_user_id;
|
||||||
|
|
||||||
MessageChatSetTtl() = default;
|
MessageChatSetTtl() = default;
|
||||||
explicit MessageChatSetTtl(int32 ttl) : ttl(ttl) {
|
MessageChatSetTtl(int32 ttl, UserId from_user_id) : ttl(ttl), from_user_id(from_user_id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageContentType get_type() const final {
|
MessageContentType get_type() const final {
|
||||||
@ -1009,7 +1010,14 @@ static void store(const MessageContent *content, StorerT &storer) {
|
|||||||
break;
|
break;
|
||||||
case MessageContentType::ChatSetTtl: {
|
case MessageContentType::ChatSetTtl: {
|
||||||
const auto *m = static_cast<const MessageChatSetTtl *>(content);
|
const auto *m = static_cast<const MessageChatSetTtl *>(content);
|
||||||
|
bool has_from_user_id = m->from_user_id.is_valid();
|
||||||
|
BEGIN_STORE_FLAGS();
|
||||||
|
STORE_FLAG(has_from_user_id);
|
||||||
|
END_STORE_FLAGS();
|
||||||
store(m->ttl, storer);
|
store(m->ttl, storer);
|
||||||
|
if (has_from_user_id) {
|
||||||
|
store(m->from_user_id, storer);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MessageContentType::Call: {
|
case MessageContentType::Call: {
|
||||||
@ -1427,7 +1435,16 @@ static void parse(unique_ptr<MessageContent> &content, ParserT &parser) {
|
|||||||
break;
|
break;
|
||||||
case MessageContentType::ChatSetTtl: {
|
case MessageContentType::ChatSetTtl: {
|
||||||
auto m = make_unique<MessageChatSetTtl>();
|
auto m = make_unique<MessageChatSetTtl>();
|
||||||
|
bool has_from_user_id = false;
|
||||||
|
if (parser.version() >= static_cast<int32>(Version::AddMessageChatSetTtlFlags)) {
|
||||||
|
BEGIN_PARSE_FLAGS();
|
||||||
|
PARSE_FLAG(has_from_user_id);
|
||||||
|
END_PARSE_FLAGS();
|
||||||
|
}
|
||||||
parse(m->ttl, parser);
|
parse(m->ttl, parser);
|
||||||
|
if (has_from_user_id) {
|
||||||
|
parse(m->from_user_id, parser);
|
||||||
|
}
|
||||||
content = std::move(m);
|
content = std::move(m);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1783,8 +1800,8 @@ unique_ptr<MessageContent> create_screenshot_taken_message_content() {
|
|||||||
return make_unique<MessageScreenshotTaken>();
|
return make_unique<MessageScreenshotTaken>();
|
||||||
}
|
}
|
||||||
|
|
||||||
unique_ptr<MessageContent> create_chat_set_ttl_message_content(int32 ttl) {
|
unique_ptr<MessageContent> create_chat_set_ttl_message_content(int32 ttl, UserId from_user_id) {
|
||||||
return make_unique<MessageChatSetTtl>(ttl);
|
return make_unique<MessageChatSetTtl>(ttl, from_user_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Result<InputMessageContent> create_input_message_content(
|
static Result<InputMessageContent> create_input_message_content(
|
||||||
@ -3584,7 +3601,10 @@ void merge_message_contents(Td *td, const MessageContent *old_content, MessageCo
|
|||||||
const auto *old_ = static_cast<const MessageChatSetTtl *>(old_content);
|
const auto *old_ = static_cast<const MessageChatSetTtl *>(old_content);
|
||||||
const auto *new_ = static_cast<const MessageChatSetTtl *>(new_content);
|
const auto *new_ = static_cast<const MessageChatSetTtl *>(new_content);
|
||||||
if (old_->ttl != new_->ttl) {
|
if (old_->ttl != new_->ttl) {
|
||||||
LOG(ERROR) << "Ttl has changed from " << old_->ttl << " to " << new_->ttl;
|
LOG(ERROR) << "TTL has changed from " << old_->ttl << " to " << new_->ttl;
|
||||||
|
need_update = true;
|
||||||
|
}
|
||||||
|
if (old_->from_user_id != new_->from_user_id) {
|
||||||
need_update = true;
|
need_update = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -3592,10 +3612,11 @@ void merge_message_contents(Td *td, const MessageContent *old_content, MessageCo
|
|||||||
case MessageContentType::Call: {
|
case MessageContentType::Call: {
|
||||||
const auto *old_ = static_cast<const MessageCall *>(old_content);
|
const auto *old_ = static_cast<const MessageCall *>(old_content);
|
||||||
const auto *new_ = static_cast<const MessageCall *>(new_content);
|
const auto *new_ = static_cast<const MessageCall *>(new_content);
|
||||||
if (old_->call_id != new_->call_id || old_->is_video != new_->is_video) {
|
if (old_->call_id != new_->call_id) {
|
||||||
is_content_changed = true;
|
is_content_changed = true;
|
||||||
}
|
}
|
||||||
if (old_->duration != new_->duration || old_->discard_reason != new_->discard_reason) {
|
if (old_->duration != new_->duration || old_->discard_reason != new_->discard_reason ||
|
||||||
|
old_->is_video != new_->is_video) {
|
||||||
need_update = true;
|
need_update = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -5129,11 +5150,12 @@ unique_ptr<MessageContent> get_action_message_content(Td *td, tl_object_ptr<tele
|
|||||||
}
|
}
|
||||||
case telegram_api::messageActionSetMessagesTTL::ID: {
|
case telegram_api::messageActionSetMessagesTTL::ID: {
|
||||||
auto action = move_tl_object_as<telegram_api::messageActionSetMessagesTTL>(action_ptr);
|
auto action = move_tl_object_as<telegram_api::messageActionSetMessagesTTL>(action_ptr);
|
||||||
if (action->period_ < 0) {
|
UserId from_user_id(action->auto_setting_from_);
|
||||||
LOG(ERROR) << "Receive wrong TTL = " << action->period_;
|
if (action->period_ < 0 || !(from_user_id == UserId() || from_user_id.is_valid())) {
|
||||||
|
LOG(ERROR) << "Receive invalid " << oneline(to_string(action));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return make_unique<MessageChatSetTtl>(action->period_);
|
return make_unique<MessageChatSetTtl>(action->period_, from_user_id);
|
||||||
}
|
}
|
||||||
case telegram_api::messageActionGroupCallScheduled::ID: {
|
case telegram_api::messageActionGroupCallScheduled::ID: {
|
||||||
auto action = move_tl_object_as<telegram_api::messageActionGroupCallScheduled>(action_ptr);
|
auto action = move_tl_object_as<telegram_api::messageActionGroupCallScheduled>(action_ptr);
|
||||||
@ -5361,7 +5383,8 @@ tl_object_ptr<td_api::MessageContent> get_message_content_object(const MessageCo
|
|||||||
return make_tl_object<td_api::messageScreenshotTaken>();
|
return make_tl_object<td_api::messageScreenshotTaken>();
|
||||||
case MessageContentType::ChatSetTtl: {
|
case MessageContentType::ChatSetTtl: {
|
||||||
const auto *m = static_cast<const MessageChatSetTtl *>(content);
|
const auto *m = static_cast<const MessageChatSetTtl *>(content);
|
||||||
return make_tl_object<td_api::messageChatSetTtl>(m->ttl);
|
return make_tl_object<td_api::messageChatSetTtl>(
|
||||||
|
m->ttl, td->contacts_manager_->get_user_id_object(m->from_user_id, "MessageChatSetTtl"));
|
||||||
}
|
}
|
||||||
case MessageContentType::Call: {
|
case MessageContentType::Call: {
|
||||||
const auto *m = static_cast<const MessageCall *>(content);
|
const auto *m = static_cast<const MessageCall *>(content);
|
||||||
@ -6055,8 +6078,11 @@ void add_message_content_dependencies(Dependencies &dependencies, const MessageC
|
|||||||
break;
|
break;
|
||||||
case MessageContentType::ScreenshotTaken:
|
case MessageContentType::ScreenshotTaken:
|
||||||
break;
|
break;
|
||||||
case MessageContentType::ChatSetTtl:
|
case MessageContentType::ChatSetTtl: {
|
||||||
|
const auto *content = static_cast<const MessageChatSetTtl *>(message_content);
|
||||||
|
dependencies.add(content->from_user_id);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case MessageContentType::Unsupported:
|
case MessageContentType::Unsupported:
|
||||||
break;
|
break;
|
||||||
case MessageContentType::Call:
|
case MessageContentType::Call:
|
||||||
|
@ -98,7 +98,7 @@ unique_ptr<MessageContent> create_contact_registered_message_content();
|
|||||||
|
|
||||||
unique_ptr<MessageContent> create_screenshot_taken_message_content();
|
unique_ptr<MessageContent> create_screenshot_taken_message_content();
|
||||||
|
|
||||||
unique_ptr<MessageContent> create_chat_set_ttl_message_content(int32 ttl);
|
unique_ptr<MessageContent> create_chat_set_ttl_message_content(int32 ttl, UserId from_user_id);
|
||||||
|
|
||||||
Result<InputMessageContent> get_input_message_content(
|
Result<InputMessageContent> get_input_message_content(
|
||||||
DialogId dialog_id, tl_object_ptr<td_api::InputMessageContent> &&input_message_content, Td *td, bool is_premium);
|
DialogId dialog_id, tl_object_ptr<td_api::InputMessageContent> &&input_message_content, Td *td, bool is_premium);
|
||||||
|
@ -14527,7 +14527,7 @@ void MessagesManager::on_secret_chat_ttl_changed(SecretChatId secret_chat_id, Us
|
|||||||
message_info.date = date;
|
message_info.date = date;
|
||||||
message_info.random_id = random_id;
|
message_info.random_id = random_id;
|
||||||
message_info.flags = MESSAGE_FLAG_HAS_FROM_ID;
|
message_info.flags = MESSAGE_FLAG_HAS_FROM_ID;
|
||||||
message_info.content = create_chat_set_ttl_message_content(ttl);
|
message_info.content = create_chat_set_ttl_message_content(ttl, UserId());
|
||||||
|
|
||||||
Dialog *d = get_dialog_force(message_info.dialog_id, "on_secret_chat_ttl_changed");
|
Dialog *d = get_dialog_force(message_info.dialog_id, "on_secret_chat_ttl_changed");
|
||||||
if (d == nullptr && have_dialog_info_force(message_info.dialog_id)) {
|
if (d == nullptr && have_dialog_info_force(message_info.dialog_id)) {
|
||||||
@ -34564,7 +34564,7 @@ void MessagesManager::set_dialog_message_ttl(DialogId dialog_id, int32 ttl, Prom
|
|||||||
} else {
|
} else {
|
||||||
bool need_update_dialog_pos = false;
|
bool need_update_dialog_pos = false;
|
||||||
Message *m = get_message_to_send(d, MessageId(), MessageId(), MessageSendOptions(),
|
Message *m = get_message_to_send(d, MessageId(), MessageId(), MessageSendOptions(),
|
||||||
create_chat_set_ttl_message_content(ttl), &need_update_dialog_pos);
|
create_chat_set_ttl_message_content(ttl, UserId()), &need_update_dialog_pos);
|
||||||
|
|
||||||
send_update_new_message(d, m);
|
send_update_new_message(d, m);
|
||||||
if (need_update_dialog_pos) {
|
if (need_update_dialog_pos) {
|
||||||
|
@ -768,7 +768,6 @@ bool UpdatesManager::is_acceptable_message(const telegram_api::Message *message_
|
|||||||
case telegram_api::messageActionContactSignUp::ID:
|
case telegram_api::messageActionContactSignUp::ID:
|
||||||
case telegram_api::messageActionGroupCall::ID:
|
case telegram_api::messageActionGroupCall::ID:
|
||||||
case telegram_api::messageActionGroupCallScheduled::ID:
|
case telegram_api::messageActionGroupCallScheduled::ID:
|
||||||
case telegram_api::messageActionSetMessagesTTL::ID:
|
|
||||||
case telegram_api::messageActionSetChatTheme::ID:
|
case telegram_api::messageActionSetChatTheme::ID:
|
||||||
case telegram_api::messageActionChatJoinedByRequest::ID:
|
case telegram_api::messageActionChatJoinedByRequest::ID:
|
||||||
case telegram_api::messageActionWebViewDataSentMe::ID:
|
case telegram_api::messageActionWebViewDataSentMe::ID:
|
||||||
@ -838,6 +837,14 @@ bool UpdatesManager::is_acceptable_message(const telegram_api::Message *message_
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case telegram_api::messageActionSetMessagesTTL::ID: {
|
||||||
|
auto set_messages_ttl = static_cast<const telegram_api::messageActionSetMessagesTTL *>(action);
|
||||||
|
if (set_messages_ttl->auto_setting_from_ != 0 &&
|
||||||
|
!is_acceptable_user(UserId(set_messages_ttl->auto_setting_from_))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
return false;
|
return false;
|
||||||
|
@ -57,6 +57,7 @@ enum class Version : int32 {
|
|||||||
AddStickerSetListFlags,
|
AddStickerSetListFlags,
|
||||||
AddInputInvoiceFlags,
|
AddInputInvoiceFlags,
|
||||||
AddVideoNoteFlags,
|
AddVideoNoteFlags,
|
||||||
|
AddMessageChatSetTtlFlags,
|
||||||
Next
|
Next
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user