Add draftMessage.effect_id.

This commit is contained in:
levlam 2024-06-05 16:31:57 +03:00
parent d51b4e18b0
commit 65c6f3a23a
5 changed files with 32 additions and 12 deletions

View File

@ -1783,7 +1783,8 @@ reactionNotificationSettings message_reaction_source:ReactionNotificationSource
//@reply_to Information about the message to be replied; must be of the type inputMessageReplyToMessage; may be null if none //@reply_to Information about the message to be replied; must be of the type inputMessageReplyToMessage; may be null if none
//@date Point in time (Unix timestamp) when the draft was created //@date Point in time (Unix timestamp) when the draft was created
//@input_message_text Content of the message draft; must be of the type inputMessageText, inputMessageVideoNote, or inputMessageVoiceNote //@input_message_text Content of the message draft; must be of the type inputMessageText, inputMessageVideoNote, or inputMessageVoiceNote
draftMessage reply_to:InputMessageReplyTo date:int32 input_message_text:InputMessageContent = DraftMessage; //@effect_id Identifier of the effect to apply to the message when it is sent; 0 if none
draftMessage reply_to:InputMessageReplyTo date:int32 input_message_text:InputMessageContent effect_id:int64 = DraftMessage;
//@class ChatType @description Describes the type of chat //@class ChatType @description Describes the type of chat
@ -3483,7 +3484,7 @@ messageSelfDestructTypeImmediately = MessageSelfDestructType;
//@protect_content Pass true if the content of the message must be protected from forwarding and saving; for bots only //@protect_content Pass true if the content of the message must be protected from forwarding and saving; for bots only
//@update_order_of_installed_sticker_sets Pass true if the user explicitly chosen a sticker or a custom emoji from an installed sticker set; applicable only to sendMessage and sendMessageAlbum //@update_order_of_installed_sticker_sets Pass true if the user explicitly chosen a sticker or a custom emoji from an installed sticker set; applicable only to sendMessage and sendMessageAlbum
//@scheduling_state Message scheduling state; pass null to send message immediately. Messages sent to a secret chat, live location messages and self-destructing messages can't be scheduled //@scheduling_state Message scheduling state; pass null to send message immediately. Messages sent to a secret chat, live location messages and self-destructing messages can't be scheduled
//@effect_id Identifier of the effect to apply to the message; applicable only to sendMessage and sendMessageAlbum in private chats //@effect_id Identifier of the effect to apply to the message; pass 0 if none; applicable only to sendMessage and sendMessageAlbum in private chats
//@sending_id Non-persistent identifier, which will be returned back in messageSendingStatePending object and can be used to match sent messages and corresponding updateNewMessage updates //@sending_id Non-persistent identifier, which will be returned back in messageSendingStatePending object and can be used to match sent messages and corresponding updateNewMessage updates
//@only_preview Pass true to get a fake message instead of actually sending them //@only_preview Pass true to get a fake message instead of actually sending them
messageSendOptions disable_notification:Bool from_background:Bool protect_content:Bool update_order_of_installed_sticker_sets:Bool scheduling_state:MessageSchedulingState effect_id:int64 sending_id:int32 only_preview:Bool = MessageSendOptions; messageSendOptions disable_notification:Bool from_background:Bool protect_content:Bool update_order_of_installed_sticker_sets:Bool scheduling_state:MessageSchedulingState effect_id:int64 sending_id:int32 only_preview:Bool = MessageSendOptions;

View File

@ -64,12 +64,15 @@ class SaveDraftMessageQuery final : public Td::ResultHandler {
if (media != nullptr) { if (media != nullptr) {
flags |= telegram_api::messages_saveDraft::MEDIA_MASK; flags |= telegram_api::messages_saveDraft::MEDIA_MASK;
} }
if (draft_message->message_effect_id_ != 0) {
flags |= telegram_api::messages_saveDraft::EFFECT_MASK;
}
} }
send_query(G()->net_query_creator().create( send_query(G()->net_query_creator().create(
telegram_api::messages_saveDraft( telegram_api::messages_saveDraft(
flags, false /*ignored*/, false /*ignored*/, std::move(input_reply_to), std::move(input_peer), flags, false /*ignored*/, false /*ignored*/, std::move(input_reply_to), std::move(input_peer),
draft_message == nullptr ? string() : draft_message->input_message_text_.text.text, draft_message == nullptr ? string() : draft_message->input_message_text_.text.text,
std::move(input_message_entities), std::move(media), 0), std::move(input_message_entities), std::move(media), draft_message->message_effect_id_),
{{dialog_id}})); {{dialog_id}}));
} }
@ -381,7 +384,8 @@ bool DraftMessage::need_update_to(const DraftMessage &other, bool from_update) c
if (is_local()) { if (is_local()) {
return !from_update || other.is_local(); return !from_update || other.is_local();
} }
if (message_input_reply_to_ == other.message_input_reply_to_ && input_message_text_ == other.input_message_text_) { if (message_input_reply_to_ == other.message_input_reply_to_ && input_message_text_ == other.input_message_text_ &&
message_effect_id_ == other.message_effect_id_) {
return date_ < other.date_; return date_ < other.date_;
} else { } else {
return !from_update || date_ <= other.date_; return !from_update || date_ <= other.date_;
@ -401,7 +405,7 @@ td_api::object_ptr<td_api::draftMessage> DraftMessage::get_draft_message_object(
input_message_content = input_message_text_.get_input_message_text_object(); input_message_content = input_message_text_.get_input_message_text_object();
} }
return td_api::make_object<td_api::draftMessage>(message_input_reply_to_.get_input_message_reply_to_object(td), date_, return td_api::make_object<td_api::draftMessage>(message_input_reply_to_.get_input_message_reply_to_object(td), date_,
std::move(input_message_content)); std::move(input_message_content), message_effect_id_);
} }
DraftMessage::DraftMessage(Td *td, telegram_api::object_ptr<telegram_api::draftMessage> &&draft_message) { DraftMessage::DraftMessage(Td *td, telegram_api::object_ptr<telegram_api::draftMessage> &&draft_message) {
@ -428,6 +432,7 @@ DraftMessage::DraftMessage(Td *td, telegram_api::object_ptr<telegram_api::draftM
} }
input_message_text_ = InputMessageText(std::move(draft_text), std::move(web_page_url), draft_message->no_webpage_, input_message_text_ = InputMessageText(std::move(draft_text), std::move(web_page_url), draft_message->no_webpage_,
force_small_media, force_large_media, draft_message->invert_media_, false); force_small_media, force_large_media, draft_message->invert_media_, false);
message_effect_id_ = draft_message->effect_;
} }
Result<unique_ptr<DraftMessage>> DraftMessage::get_draft_message( Result<unique_ptr<DraftMessage>> DraftMessage::get_draft_message(
@ -440,6 +445,7 @@ Result<unique_ptr<DraftMessage>> DraftMessage::get_draft_message(
auto result = make_unique<DraftMessage>(); auto result = make_unique<DraftMessage>();
result->message_input_reply_to_ = td->messages_manager_->create_message_input_reply_to( result->message_input_reply_to_ = td->messages_manager_->create_message_input_reply_to(
dialog_id, top_thread_message_id, std::move(draft_message->reply_to_), true); dialog_id, top_thread_message_id, std::move(draft_message->reply_to_), true);
result->message_effect_id_ = draft_message->effect_id_;
auto input_message_content = std::move(draft_message->input_message_text_); auto input_message_content = std::move(draft_message->input_message_text_);
if (input_message_content != nullptr) { if (input_message_content != nullptr) {

View File

@ -46,6 +46,7 @@ class DraftMessage {
MessageInputReplyTo message_input_reply_to_; MessageInputReplyTo message_input_reply_to_;
InputMessageText input_message_text_; InputMessageText input_message_text_;
unique_ptr<DraftMessageContent> local_content_; unique_ptr<DraftMessageContent> local_content_;
int64 message_effect_id_ = 0;
friend class SaveDraftMessageQuery; friend class SaveDraftMessageQuery;

View File

@ -22,10 +22,12 @@ void DraftMessage::store(StorerT &storer) const {
bool has_input_message_text = !input_message_text_.is_empty(); bool has_input_message_text = !input_message_text_.is_empty();
bool has_message_input_reply_to = !message_input_reply_to_.is_empty(); bool has_message_input_reply_to = !message_input_reply_to_.is_empty();
bool has_local_content = local_content_ != nullptr; bool has_local_content = local_content_ != nullptr;
bool has_message_effect_id = message_effect_id_ != 0;
BEGIN_STORE_FLAGS(); BEGIN_STORE_FLAGS();
STORE_FLAG(has_input_message_text); STORE_FLAG(has_input_message_text);
STORE_FLAG(has_message_input_reply_to); STORE_FLAG(has_message_input_reply_to);
STORE_FLAG(has_local_content); STORE_FLAG(has_local_content);
STORE_FLAG(has_message_effect_id);
END_STORE_FLAGS(); END_STORE_FLAGS();
td::store(date_, storer); td::store(date_, storer);
if (has_input_message_text) { if (has_input_message_text) {
@ -37,6 +39,9 @@ void DraftMessage::store(StorerT &storer) const {
if (has_local_content) { if (has_local_content) {
store_draft_message_content(local_content_.get(), storer); store_draft_message_content(local_content_.get(), storer);
} }
if (has_message_effect_id) {
td::store(message_effect_id_, storer);
}
} }
template <class ParserT> template <class ParserT>
@ -45,12 +50,14 @@ void DraftMessage::parse(ParserT &parser) {
bool has_input_message_text; bool has_input_message_text;
bool has_message_input_reply_to = false; bool has_message_input_reply_to = false;
bool has_local_content = false; bool has_local_content = false;
bool has_message_effect_id = false;
if (parser.version() >= static_cast<int32>(Version::SupportRepliesInOtherChats)) { if (parser.version() >= static_cast<int32>(Version::SupportRepliesInOtherChats)) {
has_legacy_reply_to_message_id = false; has_legacy_reply_to_message_id = false;
BEGIN_PARSE_FLAGS(); BEGIN_PARSE_FLAGS();
PARSE_FLAG(has_input_message_text); PARSE_FLAG(has_input_message_text);
PARSE_FLAG(has_message_input_reply_to); PARSE_FLAG(has_message_input_reply_to);
PARSE_FLAG(has_local_content); PARSE_FLAG(has_local_content);
PARSE_FLAG(has_message_effect_id);
END_PARSE_FLAGS(); END_PARSE_FLAGS();
} else { } else {
has_legacy_reply_to_message_id = true; has_legacy_reply_to_message_id = true;
@ -71,6 +78,9 @@ void DraftMessage::parse(ParserT &parser) {
if (has_local_content) { if (has_local_content) {
parse_draft_message_content(local_content_, parser); parse_draft_message_content(local_content_, parser);
} }
if (has_message_effect_id) {
td::parse(message_effect_id_, parser);
}
} }
} // namespace td } // namespace td

View File

@ -4490,7 +4490,8 @@ class CliClient final : public Actor {
draft_message = td_api::make_object<td_api::draftMessage>( draft_message = td_api::make_object<td_api::draftMessage>(
std::move(reply_to), 0, std::move(reply_to), 0,
td_api::make_object<td_api::inputMessageText>(as_formatted_text(message, std::move(entities)), td_api::make_object<td_api::inputMessageText>(as_formatted_text(message, std::move(entities)),
get_link_preview_options(), false)); get_link_preview_options(), false),
message_effect_id_);
} }
send_request( send_request(
td_api::make_object<td_api::setChatDraftMessage>(chat_id, message_thread_id_, std::move(draft_message))); td_api::make_object<td_api::setChatDraftMessage>(chat_id, message_thread_id_, std::move(draft_message)));
@ -4503,18 +4504,19 @@ class CliClient final : public Actor {
td_api::make_object<td_api::draftMessage>( td_api::make_object<td_api::draftMessage>(
nullptr, 0, nullptr, 0,
td_api::make_object<td_api::inputMessageVideoNote>(as_input_file(video_path), nullptr, 10, 5, td_api::make_object<td_api::inputMessageVideoNote>(as_input_file(video_path), nullptr, 10, 5,
get_message_self_destruct_type())))); get_message_self_destruct_type()),
message_effect_id_)));
} else if (op == "scdmvoice") { } else if (op == "scdmvoice") {
ChatId chat_id; ChatId chat_id;
string voice_path; string voice_path;
get_args(args, chat_id, voice_path); get_args(args, chat_id, voice_path);
send_request(td_api::make_object<td_api::setChatDraftMessage>( send_request(td_api::make_object<td_api::setChatDraftMessage>(
chat_id, message_thread_id_, chat_id, message_thread_id_,
td_api::make_object<td_api::draftMessage>( td_api::make_object<td_api::draftMessage>(nullptr, 0,
nullptr, 0, td_api::make_object<td_api::inputMessageVoiceNote>(
td_api::make_object<td_api::inputMessageVoiceNote>(as_input_file(voice_path), 0, "abacaba", as_input_file(voice_path), 0, "abacaba",
as_caption("voice caption"), as_caption("voice caption"), get_message_self_destruct_type()),
get_message_self_destruct_type())))); message_effect_id_)));
} else if (op == "cadm") { } else if (op == "cadm") {
send_request(td_api::make_object<td_api::clearAllDraftMessages>()); send_request(td_api::make_object<td_api::clearAllDraftMessages>());
} else if (op == "tchpc") { } else if (op == "tchpc") {