Add class MessageEffectId.
This commit is contained in:
parent
65c6f3a23a
commit
8827ffbbd6
@ -753,6 +753,7 @@ set(TDLIB_SOURCE_PART2
|
||||
td/telegram/MessageContentType.h
|
||||
td/telegram/MessageCopyOptions.h
|
||||
td/telegram/MessageDb.h
|
||||
td/telegram/MessageEffectId.h
|
||||
td/telegram/MessageEntity.h
|
||||
td/telegram/MessageExtendedMedia.h
|
||||
td/telegram/MessageForwardInfo.h
|
||||
|
@ -369,6 +369,7 @@ function split_file($file, $chunks, $undo) {
|
||||
'link_manager[_(-](?![.]get[(][)])|LinkManager' => 'LinkManager',
|
||||
'LogeventIdWithGeneration|add_log_event|delete_log_event|get_erase_log_event_promise|parse_time|store_time' => 'logevent/LogEventHelper',
|
||||
'MessageCopyOptions' => 'MessageCopyOptions',
|
||||
'MessageEffectId' => 'MessageEffectId',
|
||||
'MessageForwardInfo|LastForwardedMessageInfo|forward_info' => 'MessageForwardInfo',
|
||||
'MessageFullId' => 'MessageFullId',
|
||||
'MessageId' => 'MessageId',
|
||||
|
@ -111,7 +111,7 @@ struct BusinessConnectionManager::PendingMessage {
|
||||
unique_ptr<MessageContent> content_;
|
||||
unique_ptr<ReplyMarkup> reply_markup_;
|
||||
int64 random_id_ = 0;
|
||||
int64 effect_id_ = 0;
|
||||
MessageEffectId effect_id_;
|
||||
bool noforwards_ = false;
|
||||
bool disable_notification_ = false;
|
||||
bool invert_media_ = false;
|
||||
@ -140,7 +140,7 @@ class BusinessConnectionManager::SendBusinessMessageQuery final : public Td::Res
|
||||
if (message_->noforwards_) {
|
||||
flags |= telegram_api::messages_sendMessage::NOFORWARDS_MASK;
|
||||
}
|
||||
if (message_->effect_id_) {
|
||||
if (message_->effect_id_.is_valid()) {
|
||||
flags |= telegram_api::messages_sendMessage::EFFECT_MASK;
|
||||
}
|
||||
if (message_->invert_media_) {
|
||||
@ -172,7 +172,7 @@ class BusinessConnectionManager::SendBusinessMessageQuery final : public Td::Res
|
||||
flags, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/,
|
||||
false /*ignored*/, false /*ignored*/, std::move(input_peer), std::move(reply_to), message_text->text,
|
||||
message_->random_id_, get_input_reply_markup(td_->user_manager_.get(), message_->reply_markup_),
|
||||
std::move(entities), 0, nullptr, nullptr, message_->effect_id_),
|
||||
std::move(entities), 0, nullptr, nullptr, message_->effect_id_.get()),
|
||||
td_->business_connection_manager_->get_business_connection_dc_id(message_->business_connection_id_),
|
||||
{{message_->dialog_id_}}));
|
||||
}
|
||||
@ -214,7 +214,7 @@ class BusinessConnectionManager::SendBusinessMediaQuery final : public Td::Resul
|
||||
if (message_->noforwards_) {
|
||||
flags |= telegram_api::messages_sendMedia::NOFORWARDS_MASK;
|
||||
}
|
||||
if (message_->effect_id_) {
|
||||
if (message_->effect_id_.is_valid()) {
|
||||
flags |= telegram_api::messages_sendMedia::EFFECT_MASK;
|
||||
}
|
||||
if (message_->invert_media_) {
|
||||
@ -246,7 +246,7 @@ class BusinessConnectionManager::SendBusinessMediaQuery final : public Td::Resul
|
||||
std::move(reply_to), std::move(input_media),
|
||||
message_text == nullptr ? string() : message_text->text, message_->random_id_,
|
||||
get_input_reply_markup(td_->user_manager_.get(), message_->reply_markup_),
|
||||
std::move(entities), 0, nullptr, nullptr, message_->effect_id_),
|
||||
std::move(entities), 0, nullptr, nullptr, message_->effect_id_.get()),
|
||||
td_->business_connection_manager_->get_business_connection_dc_id(message_->business_connection_id_),
|
||||
{{message_->dialog_id_}}));
|
||||
}
|
||||
@ -289,7 +289,7 @@ class BusinessConnectionManager::SendBusinessMultiMediaQuery final : public Td::
|
||||
if (messages_[0]->noforwards_) {
|
||||
flags |= telegram_api::messages_sendMultiMedia::NOFORWARDS_MASK;
|
||||
}
|
||||
if (messages_[0]->effect_id_) {
|
||||
if (messages_[0]->effect_id_.is_valid()) {
|
||||
flags |= telegram_api::messages_sendMultiMedia::EFFECT_MASK;
|
||||
}
|
||||
if (messages_[0]->invert_media_) {
|
||||
@ -309,7 +309,7 @@ class BusinessConnectionManager::SendBusinessMultiMediaQuery final : public Td::
|
||||
telegram_api::messages_sendMultiMedia(flags, false /*ignored*/, false /*ignored*/, false /*ignored*/,
|
||||
false /*ignored*/, false /*ignored*/, false /*ignored*/,
|
||||
std::move(input_peer), std::move(reply_to), std::move(input_single_media),
|
||||
0, nullptr, nullptr, messages_[0]->effect_id_),
|
||||
0, nullptr, nullptr, messages_[0]->effect_id_.get()),
|
||||
td_->business_connection_manager_->get_business_connection_dc_id(messages_[0]->business_connection_id_),
|
||||
{{messages_[0]->dialog_id_}}));
|
||||
}
|
||||
@ -662,7 +662,7 @@ Result<InputMessageContent> BusinessConnectionManager::process_input_message_con
|
||||
|
||||
unique_ptr<BusinessConnectionManager::PendingMessage> BusinessConnectionManager::create_business_message_to_send(
|
||||
BusinessConnectionId business_connection_id, DialogId dialog_id, MessageInputReplyTo &&input_reply_to,
|
||||
bool disable_notification, bool protect_content, int64 effect_id, unique_ptr<ReplyMarkup> &&reply_markup,
|
||||
bool disable_notification, bool protect_content, MessageEffectId effect_id, unique_ptr<ReplyMarkup> &&reply_markup,
|
||||
InputMessageContent &&input_content) const {
|
||||
auto content = dup_message_content(td_, td_->dialog_manager_->get_my_dialog_id(), input_content.content.get(),
|
||||
MessageContentDupType::Send, MessageCopyOptions());
|
||||
@ -685,7 +685,7 @@ unique_ptr<BusinessConnectionManager::PendingMessage> BusinessConnectionManager:
|
||||
|
||||
void BusinessConnectionManager::send_message(BusinessConnectionId business_connection_id, DialogId dialog_id,
|
||||
td_api::object_ptr<td_api::InputMessageReplyTo> &&reply_to,
|
||||
bool disable_notification, bool protect_content, int64 effect_id,
|
||||
bool disable_notification, bool protect_content, MessageEffectId effect_id,
|
||||
td_api::object_ptr<td_api::ReplyMarkup> &&reply_markup,
|
||||
td_api::object_ptr<td_api::InputMessageContent> &&input_message_content,
|
||||
Promise<td_api::object_ptr<td_api::businessMessage>> &&promise) {
|
||||
@ -957,7 +957,7 @@ void BusinessConnectionManager::complete_upload_media(unique_ptr<PendingMessage>
|
||||
void BusinessConnectionManager::send_message_album(
|
||||
BusinessConnectionId business_connection_id, DialogId dialog_id,
|
||||
td_api::object_ptr<td_api::InputMessageReplyTo> &&reply_to, bool disable_notification, bool protect_content,
|
||||
int64 effect_id, vector<td_api::object_ptr<td_api::InputMessageContent>> &&input_message_contents,
|
||||
MessageEffectId effect_id, vector<td_api::object_ptr<td_api::InputMessageContent>> &&input_message_contents,
|
||||
Promise<td_api::object_ptr<td_api::businessMessages>> &&promise) {
|
||||
TRY_STATUS_PROMISE(promise, check_business_connection(business_connection_id, dialog_id));
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "td/telegram/BusinessConnectionId.h"
|
||||
#include "td/telegram/DialogId.h"
|
||||
#include "td/telegram/files/FileId.h"
|
||||
#include "td/telegram/MessageEffectId.h"
|
||||
#include "td/telegram/MessageInputReplyTo.h"
|
||||
#include "td/telegram/net/DcId.h"
|
||||
#include "td/telegram/td_api.h"
|
||||
@ -61,13 +62,14 @@ class BusinessConnectionManager final : public Actor {
|
||||
|
||||
void send_message(BusinessConnectionId business_connection_id, DialogId dialog_id,
|
||||
td_api::object_ptr<td_api::InputMessageReplyTo> &&reply_to, bool disable_notification,
|
||||
bool protect_content, int64 effect_id, td_api::object_ptr<td_api::ReplyMarkup> &&reply_markup,
|
||||
bool protect_content, MessageEffectId effect_id,
|
||||
td_api::object_ptr<td_api::ReplyMarkup> &&reply_markup,
|
||||
td_api::object_ptr<td_api::InputMessageContent> &&input_message_content,
|
||||
Promise<td_api::object_ptr<td_api::businessMessage>> &&promise);
|
||||
|
||||
void send_message_album(BusinessConnectionId business_connection_id, DialogId dialog_id,
|
||||
td_api::object_ptr<td_api::InputMessageReplyTo> &&reply_to, bool disable_notification,
|
||||
bool protect_content, int64 effect_id,
|
||||
bool protect_content, MessageEffectId effect_id,
|
||||
vector<td_api::object_ptr<td_api::InputMessageContent>> &&input_message_contents,
|
||||
Promise<td_api::object_ptr<td_api::businessMessages>> &&promise);
|
||||
|
||||
@ -114,7 +116,8 @@ class BusinessConnectionManager final : public Actor {
|
||||
unique_ptr<PendingMessage> create_business_message_to_send(BusinessConnectionId business_connection_id,
|
||||
DialogId dialog_id, MessageInputReplyTo &&input_reply_to,
|
||||
bool disable_notification, bool protect_content,
|
||||
int64 effect_id, unique_ptr<ReplyMarkup> &&reply_markup,
|
||||
MessageEffectId effect_id,
|
||||
unique_ptr<ReplyMarkup> &&reply_markup,
|
||||
InputMessageContent &&input_content) const;
|
||||
|
||||
void do_send_message(unique_ptr<PendingMessage> &&message,
|
||||
|
@ -64,7 +64,7 @@ class SaveDraftMessageQuery final : public Td::ResultHandler {
|
||||
if (media != nullptr) {
|
||||
flags |= telegram_api::messages_saveDraft::MEDIA_MASK;
|
||||
}
|
||||
if (draft_message->message_effect_id_ != 0) {
|
||||
if (draft_message->message_effect_id_.is_valid()) {
|
||||
flags |= telegram_api::messages_saveDraft::EFFECT_MASK;
|
||||
}
|
||||
}
|
||||
@ -72,7 +72,7 @@ class SaveDraftMessageQuery final : public Td::ResultHandler {
|
||||
telegram_api::messages_saveDraft(
|
||||
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,
|
||||
std::move(input_message_entities), std::move(media), draft_message->message_effect_id_),
|
||||
std::move(input_message_entities), std::move(media), draft_message->message_effect_id_.get()),
|
||||
{{dialog_id}}));
|
||||
}
|
||||
|
||||
@ -405,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();
|
||||
}
|
||||
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), message_effect_id_);
|
||||
std::move(input_message_content), message_effect_id_.get());
|
||||
}
|
||||
|
||||
DraftMessage::DraftMessage(Td *td, telegram_api::object_ptr<telegram_api::draftMessage> &&draft_message) {
|
||||
@ -432,7 +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_,
|
||||
force_small_media, force_large_media, draft_message->invert_media_, false);
|
||||
message_effect_id_ = draft_message->effect_;
|
||||
message_effect_id_ = MessageEffectId(draft_message->effect_);
|
||||
}
|
||||
|
||||
Result<unique_ptr<DraftMessage>> DraftMessage::get_draft_message(
|
||||
@ -445,7 +445,7 @@ Result<unique_ptr<DraftMessage>> DraftMessage::get_draft_message(
|
||||
auto result = make_unique<DraftMessage>();
|
||||
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);
|
||||
result->message_effect_id_ = draft_message->effect_id_;
|
||||
result->message_effect_id_ = MessageEffectId(draft_message->effect_id_);
|
||||
|
||||
auto input_message_content = std::move(draft_message->input_message_text_);
|
||||
if (input_message_content != nullptr) {
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "td/telegram/InputMessageText.h"
|
||||
#include "td/telegram/logevent/LogEvent.h"
|
||||
#include "td/telegram/MessageContentType.h"
|
||||
#include "td/telegram/MessageEffectId.h"
|
||||
#include "td/telegram/MessageId.h"
|
||||
#include "td/telegram/MessageInputReplyTo.h"
|
||||
#include "td/telegram/td_api.h"
|
||||
@ -46,7 +47,7 @@ class DraftMessage {
|
||||
MessageInputReplyTo message_input_reply_to_;
|
||||
InputMessageText input_message_text_;
|
||||
unique_ptr<DraftMessageContent> local_content_;
|
||||
int64 message_effect_id_ = 0;
|
||||
MessageEffectId message_effect_id_;
|
||||
|
||||
friend class SaveDraftMessageQuery;
|
||||
|
||||
|
@ -22,7 +22,7 @@ void DraftMessage::store(StorerT &storer) const {
|
||||
bool has_input_message_text = !input_message_text_.is_empty();
|
||||
bool has_message_input_reply_to = !message_input_reply_to_.is_empty();
|
||||
bool has_local_content = local_content_ != nullptr;
|
||||
bool has_message_effect_id = message_effect_id_ != 0;
|
||||
bool has_message_effect_id = message_effect_id_.is_valid();
|
||||
BEGIN_STORE_FLAGS();
|
||||
STORE_FLAG(has_input_message_text);
|
||||
STORE_FLAG(has_message_input_reply_to);
|
||||
|
65
td/telegram/MessageEffectId.h
Normal file
65
td/telegram/MessageEffectId.h
Normal file
@ -0,0 +1,65 @@
|
||||
//
|
||||
// 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/utils/common.h"
|
||||
#include "td/utils/HashTableUtils.h"
|
||||
#include "td/utils/StringBuilder.h"
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
namespace td {
|
||||
|
||||
class MessageEffectId {
|
||||
int64 id = 0;
|
||||
|
||||
public:
|
||||
MessageEffectId() = default;
|
||||
|
||||
explicit constexpr MessageEffectId(int64 message_effect_id) : id(message_effect_id) {
|
||||
}
|
||||
template <class T, typename = std::enable_if_t<std::is_convertible<T, int64>::value>>
|
||||
MessageEffectId(T message_effect_id) = delete;
|
||||
|
||||
bool is_valid() const {
|
||||
return id != 0;
|
||||
}
|
||||
|
||||
int64 get() const {
|
||||
return id;
|
||||
}
|
||||
|
||||
bool operator==(const MessageEffectId &other) const {
|
||||
return id == other.id;
|
||||
}
|
||||
|
||||
bool operator!=(const MessageEffectId &other) const {
|
||||
return id != other.id;
|
||||
}
|
||||
|
||||
template <class StorerT>
|
||||
void store(StorerT &storer) const {
|
||||
storer.store_long(id);
|
||||
}
|
||||
|
||||
template <class ParserT>
|
||||
void parse(ParserT &parser) {
|
||||
id = parser.fetch_long();
|
||||
}
|
||||
};
|
||||
|
||||
struct MessageEffectIdHash {
|
||||
uint32 operator()(MessageEffectId message_effect_id) const {
|
||||
return Hash<int64>()(message_effect_id.get());
|
||||
}
|
||||
};
|
||||
|
||||
inline StringBuilder &operator<<(StringBuilder &string_builder, MessageEffectId message_effect_id) {
|
||||
return string_builder << "message effect " << message_effect_id.get();
|
||||
}
|
||||
|
||||
} // namespace td
|
@ -2885,7 +2885,7 @@ class SendMessageQuery final : public Td::ResultHandler {
|
||||
public:
|
||||
void send(int32 flags, DialogId dialog_id, tl_object_ptr<telegram_api::InputPeer> as_input_peer,
|
||||
const MessageInputReplyTo &input_reply_to, MessageId top_thread_message_id, int32 schedule_date,
|
||||
int64 effect_id, tl_object_ptr<telegram_api::ReplyMarkup> &&reply_markup,
|
||||
MessageEffectId effect_id, tl_object_ptr<telegram_api::ReplyMarkup> &&reply_markup,
|
||||
vector<tl_object_ptr<telegram_api::MessageEntity>> &&entities, const string &text, bool is_copy,
|
||||
int64 random_id, NetQueryRef *send_query_ref) {
|
||||
random_id_ = random_id;
|
||||
@ -2909,10 +2909,11 @@ class SendMessageQuery final : public Td::ResultHandler {
|
||||
}
|
||||
|
||||
auto query = G()->net_query_creator().create(
|
||||
telegram_api::messages_sendMessage(
|
||||
flags, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/,
|
||||
false /*ignored*/, false /*ignored*/, std::move(input_peer), std::move(reply_to), text, random_id,
|
||||
std::move(reply_markup), std::move(entities), schedule_date, std::move(as_input_peer), nullptr, effect_id),
|
||||
telegram_api::messages_sendMessage(flags, false /*ignored*/, false /*ignored*/, false /*ignored*/,
|
||||
false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/,
|
||||
std::move(input_peer), std::move(reply_to), text, random_id,
|
||||
std::move(reply_markup), std::move(entities), schedule_date,
|
||||
std::move(as_input_peer), nullptr, effect_id.get()),
|
||||
{{dialog_id, MessageContentType::Text},
|
||||
{dialog_id, is_copy ? MessageContentType::Photo : MessageContentType::Text}});
|
||||
if (td_->option_manager_->get_option_boolean("use_quick_ack")) {
|
||||
@ -3085,7 +3086,7 @@ class SendMultiMediaQuery final : public Td::ResultHandler {
|
||||
public:
|
||||
void send(int32 flags, DialogId dialog_id, tl_object_ptr<telegram_api::InputPeer> as_input_peer,
|
||||
const MessageInputReplyTo &input_reply_to, MessageId top_thread_message_id, int32 schedule_date,
|
||||
int64 effect_id, vector<FileId> &&file_ids,
|
||||
MessageEffectId effect_id, vector<FileId> &&file_ids,
|
||||
vector<tl_object_ptr<telegram_api::inputSingleMedia>> &&input_single_media, bool is_copy) {
|
||||
for (auto &single_media : input_single_media) {
|
||||
random_ids_.push_back(single_media->random_id_);
|
||||
@ -3115,7 +3116,7 @@ class SendMultiMediaQuery final : public Td::ResultHandler {
|
||||
telegram_api::messages_sendMultiMedia(flags, false /*ignored*/, false /*ignored*/, false /*ignored*/,
|
||||
false /*ignored*/, false /*ignored*/, false /*ignored*/,
|
||||
std::move(input_peer), std::move(reply_to), std::move(input_single_media),
|
||||
schedule_date, std::move(as_input_peer), nullptr, effect_id),
|
||||
schedule_date, std::move(as_input_peer), nullptr, effect_id.get()),
|
||||
{{dialog_id, is_copy ? MessageContentType::Text : MessageContentType::Photo},
|
||||
{dialog_id, MessageContentType::Photo}}));
|
||||
}
|
||||
@ -3203,7 +3204,7 @@ class SendMediaQuery final : public Td::ResultHandler {
|
||||
public:
|
||||
void send(FileId file_id, FileId thumbnail_file_id, int32 flags, DialogId dialog_id,
|
||||
tl_object_ptr<telegram_api::InputPeer> as_input_peer, const MessageInputReplyTo &input_reply_to,
|
||||
MessageId top_thread_message_id, int32 schedule_date, int64 effect_id,
|
||||
MessageId top_thread_message_id, int32 schedule_date, MessageEffectId effect_id,
|
||||
tl_object_ptr<telegram_api::ReplyMarkup> &&reply_markup,
|
||||
vector<tl_object_ptr<telegram_api::MessageEntity>> &&entities, const string &text,
|
||||
tl_object_ptr<telegram_api::InputMedia> &&input_media, MessageContentType content_type, bool is_copy,
|
||||
@ -3234,10 +3235,11 @@ class SendMediaQuery final : public Td::ResultHandler {
|
||||
}
|
||||
|
||||
auto query = G()->net_query_creator().create(
|
||||
telegram_api::messages_sendMedia(
|
||||
flags, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/,
|
||||
false /*ignored*/, std::move(input_peer), std::move(reply_to), std::move(input_media), text, random_id,
|
||||
std::move(reply_markup), std::move(entities), schedule_date, std::move(as_input_peer), nullptr, effect_id),
|
||||
telegram_api::messages_sendMedia(flags, false /*ignored*/, false /*ignored*/, false /*ignored*/,
|
||||
false /*ignored*/, false /*ignored*/, false /*ignored*/, std::move(input_peer),
|
||||
std::move(reply_to), std::move(input_media), text, random_id,
|
||||
std::move(reply_markup), std::move(entities), schedule_date,
|
||||
std::move(as_input_peer), nullptr, effect_id.get()),
|
||||
{{dialog_id, content_type}, {dialog_id, is_copy ? MessageContentType::Text : content_type}});
|
||||
if (td_->option_manager_->get_option_boolean("use_quick_ack") && was_uploaded_) {
|
||||
query->quick_ack_promise_ = PromiseCreator::lambda([random_id](Result<Unit> result) {
|
||||
@ -4241,7 +4243,7 @@ void MessagesManager::Message::store(StorerT &storer) const {
|
||||
bool has_initial_top_thread_message_id = !message_id.is_any_server() && initial_top_thread_message_id.is_valid();
|
||||
bool has_sender_boost_count = sender_boost_count != 0;
|
||||
bool has_via_business_bot_user_id = via_business_bot_user_id.is_valid();
|
||||
bool has_effect_id = effect_id != 0;
|
||||
bool has_effect_id = effect_id.is_valid();
|
||||
bool has_fact_check = fact_check != nullptr;
|
||||
BEGIN_STORE_FLAGS();
|
||||
STORE_FLAG(is_channel_post);
|
||||
@ -13240,7 +13242,7 @@ MessagesManager::MessageInfo MessagesManager::parse_telegram_api_message(
|
||||
message_info.has_mention = message->mentioned_;
|
||||
message_info.has_unread_content = message->media_unread_;
|
||||
message_info.invert_media = message->invert_media_;
|
||||
message_info.effect_id = message->effect_;
|
||||
message_info.effect_id = MessageEffectId(message->effect_);
|
||||
|
||||
bool is_content_read = true;
|
||||
if (!td->auth_manager_->is_bot()) {
|
||||
@ -22748,8 +22750,8 @@ td_api::object_ptr<td_api::message> MessagesManager::get_business_message_messag
|
||||
false, false, false, false, false, false, false, false, false, false, false, m->date, m->edit_date,
|
||||
std::move(forward_info), std::move(import_info), nullptr, Auto(), nullptr, std::move(reply_to), 0, 0,
|
||||
std::move(self_destruct_type), 0.0, 0.0, via_bot_user_id, via_business_bot_user_id, 0, string(),
|
||||
m->media_album_id, m->effect_id, get_restriction_reason_description(m->restriction_reasons), std::move(content),
|
||||
std::move(reply_markup));
|
||||
m->media_album_id, m->effect_id.get(), get_restriction_reason_description(m->restriction_reasons),
|
||||
std::move(content), std::move(reply_markup));
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::message> MessagesManager::get_message_object(MessageFullId message_full_id,
|
||||
@ -22867,7 +22869,7 @@ td_api::object_ptr<td_api::message> MessagesManager::get_message_object(DialogId
|
||||
top_thread_message_id,
|
||||
td_->saved_messages_manager_->get_saved_messages_topic_id_object(m->saved_messages_topic_id),
|
||||
std::move(self_destruct_type), ttl_expires_in, auto_delete_in, via_bot_user_id, via_business_bot_user_id,
|
||||
m->sender_boost_count, m->author_signature, m->media_album_id, m->effect_id,
|
||||
m->sender_boost_count, m->author_signature, m->media_album_id, m->effect_id.get(),
|
||||
get_restriction_reason_description(m->restriction_reasons), std::move(content), std::move(reply_markup));
|
||||
}
|
||||
|
||||
@ -23063,7 +23065,7 @@ unique_ptr<MessagesManager::Message> MessagesManager::create_message_to_send(
|
||||
if (m->sender_user_id == my_id && dialog_type == DialogType::Channel) {
|
||||
m->sender_boost_count = td_->chat_manager_->get_channel_my_boost_count(dialog_id.get_channel_id());
|
||||
}
|
||||
m->effect_id = options.effect_id;
|
||||
m->effect_id = MessageEffectId(options.effect_id);
|
||||
m->content = std::move(content);
|
||||
m->invert_media = invert_media;
|
||||
m->forward_info = std::move(forward_info);
|
||||
@ -23779,7 +23781,7 @@ Result<MessagesManager::MessageSendOptions> MessagesManager::process_message_sen
|
||||
if (!allow_effect) {
|
||||
return Status::Error(400, "Can't use message effects in the method");
|
||||
}
|
||||
result.effect_id = options->effect_id_;
|
||||
result.effect_id = MessageEffectId(options->effect_id_);
|
||||
}
|
||||
|
||||
return std::move(result);
|
||||
@ -24367,7 +24369,7 @@ void MessagesManager::do_send_message_group(int64 media_album_id) {
|
||||
MessageId top_thread_message_id;
|
||||
int32 flags = 0;
|
||||
int32 schedule_date = 0;
|
||||
int64 effect_id = 0;
|
||||
MessageEffectId effect_id;
|
||||
bool is_copy = false;
|
||||
for (size_t i = 0; i < request.message_ids.size(); i++) {
|
||||
auto *m = get_message(d, request.message_ids[i]);
|
||||
@ -25803,7 +25805,7 @@ int32 MessagesManager::get_message_flags(const Message *m) {
|
||||
if (m->invert_media) {
|
||||
flags |= SEND_MESSAGE_FLAG_INVERT_MEDIA;
|
||||
}
|
||||
if (m->effect_id != 0) {
|
||||
if (m->effect_id.is_valid()) {
|
||||
flags |= SEND_MESSAGE_FLAG_EFFECT;
|
||||
}
|
||||
return flags;
|
||||
@ -26540,7 +26542,7 @@ Result<td_api::object_ptr<td_api::messages>> MessagesManager::send_quick_reply_s
|
||||
auto *d = get_dialog(dialog_id);
|
||||
CHECK(d != nullptr);
|
||||
|
||||
MessageSendOptions message_send_options(false, false, false, false, false, 0, sending_id, 0);
|
||||
MessageSendOptions message_send_options(false, false, false, false, false, 0, sending_id, MessageEffectId());
|
||||
FlatHashMap<MessageId, MessageId, MessageIdHash> original_message_id_to_new_message_id;
|
||||
vector<td_api::object_ptr<td_api::message>> result;
|
||||
vector<Message *> sent_messages;
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "td/telegram/MessageContentType.h"
|
||||
#include "td/telegram/MessageCopyOptions.h"
|
||||
#include "td/telegram/MessageDb.h"
|
||||
#include "td/telegram/MessageEffectId.h"
|
||||
#include "td/telegram/MessageFullId.h"
|
||||
#include "td/telegram/MessageId.h"
|
||||
#include "td/telegram/MessageInputReplyTo.h"
|
||||
@ -1003,7 +1004,7 @@ class MessagesManager final : public Actor {
|
||||
vector<RestrictionReason> restriction_reasons;
|
||||
string author_signature;
|
||||
int64 media_album_id = 0;
|
||||
int64 effect_id = 0;
|
||||
MessageEffectId effect_id;
|
||||
bool is_outgoing = false;
|
||||
bool is_silent = false;
|
||||
bool is_channel_post = false;
|
||||
@ -1120,7 +1121,7 @@ class MessagesManager final : public Actor {
|
||||
double ttl_expires_at = 0; // only for TTL
|
||||
|
||||
int64 media_album_id = 0;
|
||||
int64 effect_id = 0;
|
||||
MessageEffectId effect_id;
|
||||
|
||||
unique_ptr<MessageContent> content;
|
||||
|
||||
@ -1489,11 +1490,12 @@ class MessagesManager final : public Actor {
|
||||
bool only_preview = false;
|
||||
int32 schedule_date = 0;
|
||||
int32 sending_id = 0;
|
||||
int64 effect_id = 0;
|
||||
MessageEffectId effect_id;
|
||||
|
||||
MessageSendOptions() = default;
|
||||
MessageSendOptions(bool disable_notification, bool from_background, bool update_stickersets_order,
|
||||
bool protect_content, bool only_preview, int32 schedule_date, int32 sending_id, int64 effect_id)
|
||||
bool protect_content, bool only_preview, int32 schedule_date, int32 sending_id,
|
||||
MessageEffectId effect_id)
|
||||
: disable_notification(disable_notification)
|
||||
, from_background(from_background)
|
||||
, update_stickersets_order(update_stickersets_order)
|
||||
|
@ -1211,12 +1211,12 @@ td_api::object_ptr<td_api::messageEffect> ReactionManager::get_message_effect_ob
|
||||
td_->stickers_manager_->get_sticker_object(effect.effect_sticker_id_),
|
||||
td_->stickers_manager_->get_sticker_object(effect.effect_animation_id_));
|
||||
}();
|
||||
return td_api::make_object<td_api::messageEffect>(effect.id_,
|
||||
return td_api::make_object<td_api::messageEffect>(effect.id_.get(),
|
||||
td_->stickers_manager_->get_sticker_object(effect.static_icon_id_),
|
||||
effect.emoji_, effect.is_premium_, std::move(type));
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::messageEffect> ReactionManager::get_message_effect_object(int64 effect_id) const {
|
||||
td_api::object_ptr<td_api::messageEffect> ReactionManager::get_message_effect_object(MessageEffectId effect_id) const {
|
||||
for (auto &effect : message_effects_.effects_) {
|
||||
if (effect.id_ == effect_id) {
|
||||
return get_message_effect_object(effect);
|
||||
@ -1227,9 +1227,12 @@ td_api::object_ptr<td_api::messageEffect> ReactionManager::get_message_effect_ob
|
||||
|
||||
td_api::object_ptr<td_api::updateAvailableMessageEffects> ReactionManager::get_update_available_message_effects_object()
|
||||
const {
|
||||
auto get_raw_effect_ids = [](const vector<MessageEffectId> &message_effect_ids) {
|
||||
return transform(message_effect_ids, [](MessageEffectId effect_id) { return effect_id.get(); });
|
||||
};
|
||||
return td_api::make_object<td_api::updateAvailableMessageEffects>(
|
||||
vector<int64>(active_message_effects_.reaction_effects_),
|
||||
vector<int64>(active_message_effects_.sticker_effects_));
|
||||
get_raw_effect_ids(active_message_effects_.reaction_effects_),
|
||||
get_raw_effect_ids(active_message_effects_.sticker_effects_));
|
||||
}
|
||||
|
||||
void ReactionManager::reload_message_effects() {
|
||||
@ -1324,7 +1327,7 @@ void ReactionManager::on_get_message_effects(
|
||||
bool have_invalid_order = false;
|
||||
for (const auto &available_effect : effects->effects_) {
|
||||
Effect effect;
|
||||
effect.id_ = available_effect->id_;
|
||||
effect.id_ = MessageEffectId(available_effect->id_);
|
||||
effect.emoji_ = std::move(available_effect->emoticon_);
|
||||
effect.is_premium_ = available_effect->premium_required_;
|
||||
if (available_effect->static_icon_id_ != 0) {
|
||||
@ -1441,7 +1444,7 @@ void ReactionManager::update_active_message_effects() {
|
||||
send_closure(G()->td(), &Td::send_update, get_update_available_message_effects_object());
|
||||
}
|
||||
|
||||
void ReactionManager::get_message_effect(int64 effect_id,
|
||||
void ReactionManager::get_message_effect(MessageEffectId effect_id,
|
||||
Promise<td_api::object_ptr<td_api::messageEffect>> &&promise) {
|
||||
load_message_effects();
|
||||
if (message_effects_.effects_.empty() && message_effects_.are_being_reloaded_) {
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include "td/telegram/ChatReactions.h"
|
||||
#include "td/telegram/files/FileId.h"
|
||||
#include "td/telegram/MessageEffectId.h"
|
||||
#include "td/telegram/ReactionListType.h"
|
||||
#include "td/telegram/ReactionType.h"
|
||||
#include "td/telegram/ReactionUnavailabilityReason.h"
|
||||
@ -83,7 +84,7 @@ class ReactionManager final : public Actor {
|
||||
|
||||
void reload_message_effects();
|
||||
|
||||
void get_message_effect(int64 effect_id, Promise<td_api::object_ptr<td_api::messageEffect>> &&promise);
|
||||
void get_message_effect(MessageEffectId effect_id, Promise<td_api::object_ptr<td_api::messageEffect>> &&promise);
|
||||
|
||||
void get_current_state(vector<td_api::object_ptr<td_api::Update>> &updates) const;
|
||||
|
||||
@ -194,7 +195,7 @@ class ReactionManager final : public Actor {
|
||||
};
|
||||
|
||||
struct Effect {
|
||||
int64 id_ = 0;
|
||||
MessageEffectId id_;
|
||||
string emoji_;
|
||||
FileId static_icon_id_;
|
||||
FileId effect_sticker_id_;
|
||||
@ -202,7 +203,7 @@ class ReactionManager final : public Actor {
|
||||
bool is_premium_ = false;
|
||||
|
||||
bool is_valid() const {
|
||||
return id_ != 0 && effect_sticker_id_.is_valid();
|
||||
return id_.is_valid() && effect_sticker_id_.is_valid();
|
||||
}
|
||||
|
||||
bool is_sticker() const {
|
||||
@ -229,8 +230,8 @@ class ReactionManager final : public Actor {
|
||||
};
|
||||
|
||||
struct ActiveEffects {
|
||||
vector<int64> reaction_effects_;
|
||||
vector<int64> sticker_effects_;
|
||||
vector<MessageEffectId> reaction_effects_;
|
||||
vector<MessageEffectId> sticker_effects_;
|
||||
|
||||
bool is_empty() const {
|
||||
return reaction_effects_.empty() && sticker_effects_.empty();
|
||||
@ -289,7 +290,7 @@ class ReactionManager final : public Actor {
|
||||
|
||||
td_api::object_ptr<td_api::messageEffect> get_message_effect_object(const Effect &effect) const;
|
||||
|
||||
td_api::object_ptr<td_api::messageEffect> get_message_effect_object(int64 effect_id) const;
|
||||
td_api::object_ptr<td_api::messageEffect> get_message_effect_object(MessageEffectId effect_id) const;
|
||||
|
||||
td_api::object_ptr<td_api::updateAvailableMessageEffects> get_update_available_message_effects_object() const;
|
||||
|
||||
@ -331,7 +332,8 @@ class ReactionManager final : public Actor {
|
||||
Effects message_effects_;
|
||||
ActiveEffects active_message_effects_;
|
||||
|
||||
vector<std::pair<int64, Promise<td_api::object_ptr<td_api::messageEffect>>>> pending_get_message_effect_queries_;
|
||||
vector<std::pair<MessageEffectId, Promise<td_api::object_ptr<td_api::messageEffect>>>>
|
||||
pending_get_message_effect_queries_;
|
||||
};
|
||||
|
||||
} // namespace td
|
||||
|
@ -87,6 +87,7 @@
|
||||
#include "td/telegram/Location.h"
|
||||
#include "td/telegram/Logging.h"
|
||||
#include "td/telegram/MessageCopyOptions.h"
|
||||
#include "td/telegram/MessageEffectId.h"
|
||||
#include "td/telegram/MessageEntity.h"
|
||||
#include "td/telegram/MessageFullId.h"
|
||||
#include "td/telegram/MessageId.h"
|
||||
@ -5517,7 +5518,7 @@ void Td::on_request(uint64 id, td_api::setSavedMessagesTagLabel &request) {
|
||||
void Td::on_request(uint64 id, const td_api::getMessageEffect &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_REQUEST_PROMISE();
|
||||
reaction_manager_->get_message_effect(request.effect_id_, std::move(promise));
|
||||
reaction_manager_->get_message_effect(MessageEffectId(request.effect_id_), std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::getMessagePublicForwards &request) {
|
||||
@ -5773,10 +5774,11 @@ void Td::on_request(uint64 id, td_api::setMessageFactCheck &request) {
|
||||
void Td::on_request(uint64 id, td_api::sendBusinessMessage &request) {
|
||||
CHECK_IS_BOT();
|
||||
CREATE_REQUEST_PROMISE();
|
||||
business_connection_manager_->send_message(
|
||||
BusinessConnectionId(std::move(request.business_connection_id_)), DialogId(request.chat_id_),
|
||||
std::move(request.reply_to_), request.disable_notification_, request.protect_content_, request.effect_id_,
|
||||
std::move(request.reply_markup_), std::move(request.input_message_content_), std::move(promise));
|
||||
business_connection_manager_->send_message(BusinessConnectionId(std::move(request.business_connection_id_)),
|
||||
DialogId(request.chat_id_), std::move(request.reply_to_),
|
||||
request.disable_notification_, request.protect_content_,
|
||||
MessageEffectId(request.effect_id_), std::move(request.reply_markup_),
|
||||
std::move(request.input_message_content_), std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::sendBusinessMessageAlbum &request) {
|
||||
@ -5784,8 +5786,8 @@ void Td::on_request(uint64 id, td_api::sendBusinessMessageAlbum &request) {
|
||||
CREATE_REQUEST_PROMISE();
|
||||
business_connection_manager_->send_message_album(
|
||||
BusinessConnectionId(std::move(request.business_connection_id_)), DialogId(request.chat_id_),
|
||||
std::move(request.reply_to_), request.disable_notification_, request.protect_content_, request.effect_id_,
|
||||
std::move(request.input_message_contents_), std::move(promise));
|
||||
std::move(request.reply_to_), request.disable_notification_, request.protect_content_,
|
||||
MessageEffectId(request.effect_id_), std::move(request.input_message_contents_), std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::loadQuickReplyShortcuts &request) {
|
||||
|
Loading…
Reference in New Issue
Block a user