Add MessageContentType::DialogShared.
This commit is contained in:
parent
9f0cf95027
commit
f7db1f1e32
@ -421,6 +421,7 @@ bool DialogAction::is_canceled_by_message_of_type(MessageContentType message_con
|
||||
case MessageContentType::GiveawayResults:
|
||||
case MessageContentType::GiveawayWinners:
|
||||
case MessageContentType::BoostApply:
|
||||
case MessageContentType::DialogShared:
|
||||
return false;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
|
@ -71,6 +71,7 @@
|
||||
#include "td/telegram/SecureValue.hpp"
|
||||
#include "td/telegram/ServerMessageId.h"
|
||||
#include "td/telegram/SharedDialog.h"
|
||||
#include "td/telegram/SharedDialog.hpp"
|
||||
#include "td/telegram/StickerFormat.h"
|
||||
#include "td/telegram/StickersManager.h"
|
||||
#include "td/telegram/StickersManager.hpp"
|
||||
@ -1102,6 +1103,21 @@ class MessageBoostApply final : public MessageContent {
|
||||
}
|
||||
};
|
||||
|
||||
class MessageDialogShared final : public MessageContent {
|
||||
public:
|
||||
vector<SharedDialog> shared_dialogs;
|
||||
int32 button_id = 0;
|
||||
|
||||
MessageDialogShared() = default;
|
||||
MessageDialogShared(vector<SharedDialog> &&shared_dialogs, int32 button_id)
|
||||
: shared_dialogs(std::move(shared_dialogs)), button_id(button_id) {
|
||||
}
|
||||
|
||||
MessageContentType get_type() const final {
|
||||
return MessageContentType::DialogShared;
|
||||
}
|
||||
};
|
||||
|
||||
template <class StorerT>
|
||||
static void store(const MessageContent *content, StorerT &storer) {
|
||||
CHECK(content != nullptr);
|
||||
@ -1658,6 +1674,14 @@ static void store(const MessageContent *content, StorerT &storer) {
|
||||
store(m->boost_count, storer);
|
||||
break;
|
||||
}
|
||||
case MessageContentType::DialogShared: {
|
||||
const auto *m = static_cast<const MessageDialogShared *>(content);
|
||||
BEGIN_STORE_FLAGS();
|
||||
END_STORE_FLAGS();
|
||||
store(m->shared_dialogs, storer);
|
||||
store(m->button_id, storer);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
@ -2394,6 +2418,19 @@ static void parse(unique_ptr<MessageContent> &content, ParserT &parser) {
|
||||
content = std::move(m);
|
||||
break;
|
||||
}
|
||||
case MessageContentType::DialogShared: {
|
||||
auto m = make_unique<MessageDialogShared>();
|
||||
BEGIN_PARSE_FLAGS();
|
||||
END_PARSE_FLAGS();
|
||||
parse(m->shared_dialogs, parser);
|
||||
if (m->shared_dialogs.empty() ||
|
||||
any_of(m->shared_dialogs, [](const auto &shared_dialog) { return !shared_dialog.is_valid(); })) {
|
||||
is_bad = true;
|
||||
}
|
||||
parse(m->button_id, parser);
|
||||
content = std::move(m);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
is_bad = true;
|
||||
@ -3040,6 +3077,7 @@ bool can_have_input_media(const Td *td, const MessageContent *content, bool is_s
|
||||
case MessageContentType::ExpiredVideoNote:
|
||||
case MessageContentType::ExpiredVoiceNote:
|
||||
case MessageContentType::BoostApply:
|
||||
case MessageContentType::DialogShared:
|
||||
return false;
|
||||
case MessageContentType::Animation:
|
||||
case MessageContentType::Audio:
|
||||
@ -3181,6 +3219,7 @@ SecretInputMedia get_secret_input_media(const MessageContent *content, Td *td,
|
||||
case MessageContentType::ExpiredVideoNote:
|
||||
case MessageContentType::ExpiredVoiceNote:
|
||||
case MessageContentType::BoostApply:
|
||||
case MessageContentType::DialogShared:
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -3324,6 +3363,7 @@ static tl_object_ptr<telegram_api::InputMedia> get_input_media_impl(
|
||||
case MessageContentType::ExpiredVideoNote:
|
||||
case MessageContentType::ExpiredVoiceNote:
|
||||
case MessageContentType::BoostApply:
|
||||
case MessageContentType::DialogShared:
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -3529,6 +3569,7 @@ void delete_message_content_thumbnail(MessageContent *content, Td *td) {
|
||||
case MessageContentType::ExpiredVideoNote:
|
||||
case MessageContentType::ExpiredVoiceNote:
|
||||
case MessageContentType::BoostApply:
|
||||
case MessageContentType::DialogShared:
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -3754,6 +3795,7 @@ Status can_send_message_content(DialogId dialog_id, const MessageContent *conten
|
||||
case MessageContentType::ExpiredVideoNote:
|
||||
case MessageContentType::ExpiredVoiceNote:
|
||||
case MessageContentType::BoostApply:
|
||||
case MessageContentType::DialogShared:
|
||||
UNREACHABLE();
|
||||
}
|
||||
return Status::OK();
|
||||
@ -3901,6 +3943,7 @@ static int32 get_message_content_media_index_mask(const MessageContent *content,
|
||||
case MessageContentType::ExpiredVideoNote:
|
||||
case MessageContentType::ExpiredVoiceNote:
|
||||
case MessageContentType::BoostApply:
|
||||
case MessageContentType::DialogShared:
|
||||
return 0;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -4184,6 +4227,8 @@ vector<UserId> get_message_content_min_user_ids(const Td *td, const MessageConte
|
||||
break;
|
||||
case MessageContentType::BoostApply:
|
||||
break;
|
||||
case MessageContentType::DialogShared:
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
break;
|
||||
@ -4589,6 +4634,7 @@ void merge_message_contents(Td *td, const MessageContent *old_content, MessageCo
|
||||
case MessageContentType::ExpiredVideoNote:
|
||||
case MessageContentType::ExpiredVoiceNote:
|
||||
case MessageContentType::BoostApply:
|
||||
case MessageContentType::DialogShared:
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -4739,6 +4785,7 @@ bool merge_message_content_file_id(Td *td, MessageContent *message_content, File
|
||||
case MessageContentType::ExpiredVideoNote:
|
||||
case MessageContentType::ExpiredVoiceNote:
|
||||
case MessageContentType::BoostApply:
|
||||
case MessageContentType::DialogShared:
|
||||
LOG(ERROR) << "Receive new file " << new_file_id << " in a sent message of the type " << content_type;
|
||||
break;
|
||||
default:
|
||||
@ -5273,6 +5320,14 @@ void compare_message_contents(Td *td, const MessageContent *old_content, const M
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MessageContentType::DialogShared: {
|
||||
const auto *lhs = static_cast<const MessageDialogShared *>(old_content);
|
||||
const auto *rhs = static_cast<const MessageDialogShared *>(new_content);
|
||||
if (lhs->shared_dialogs != rhs->shared_dialogs || lhs->button_id != rhs->button_id) {
|
||||
need_update = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
UNREACHABLE();
|
||||
break;
|
||||
@ -6435,6 +6490,7 @@ unique_ptr<MessageContent> dup_message_content(Td *td, DialogId dialog_id, const
|
||||
case MessageContentType::ExpiredVideoNote:
|
||||
case MessageContentType::ExpiredVoiceNote:
|
||||
case MessageContentType::BoostApply:
|
||||
case MessageContentType::DialogShared:
|
||||
return nullptr;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -6837,8 +6893,30 @@ unique_ptr<MessageContent> get_action_message_content(Td *td, tl_object_ptr<tele
|
||||
auto action = move_tl_object_as<telegram_api::messageActionBoostApply>(action_ptr);
|
||||
return make_unique<MessageBoostApply>(max(action->boosts_, 0));
|
||||
}
|
||||
case telegram_api::messageActionRequestedPeerSentMe::ID:
|
||||
return make_unique<MessageUnsupported>();
|
||||
case telegram_api::messageActionRequestedPeerSentMe::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::messageActionRequestedPeerSentMe>(action_ptr);
|
||||
vector<SharedDialog> shared_dialogs;
|
||||
for (auto &peer : action->peers_) {
|
||||
SharedDialog shared_dialog(td, std::move(peer));
|
||||
if (shared_dialog.is_valid()) {
|
||||
shared_dialogs.push_back(std::move(shared_dialog));
|
||||
}
|
||||
}
|
||||
if (shared_dialogs.size() > 1) {
|
||||
for (auto shared_dialog : shared_dialogs) {
|
||||
if (!shared_dialog.is_user()) {
|
||||
shared_dialogs.clear();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (shared_dialogs.empty() || shared_dialogs.size() != action->peers_.size()) {
|
||||
LOG(ERROR) << "Receive invalid " << oneline(to_string(action));
|
||||
break;
|
||||
}
|
||||
|
||||
return td::make_unique<MessageDialogShared>(std::move(shared_dialogs), action->button_id_);
|
||||
}
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
@ -7242,6 +7320,20 @@ tl_object_ptr<td_api::MessageContent> get_message_content_object(const MessageCo
|
||||
const auto *m = static_cast<const MessageBoostApply *>(content);
|
||||
return td_api::make_object<td_api::messageChatBoost>(m->boost_count);
|
||||
}
|
||||
case MessageContentType::DialogShared: {
|
||||
const auto *m = static_cast<const MessageDialogShared *>(content);
|
||||
CHECK(!m->shared_dialogs.empty());
|
||||
if (m->shared_dialogs[0].is_user()) {
|
||||
vector<td_api::object_ptr<td_api::sharedUser>> users;
|
||||
for (const auto &shared_dialog : m->shared_dialogs) {
|
||||
users.push_back(shared_dialog.get_shared_user_object(td));
|
||||
}
|
||||
return td_api::make_object<td_api::messageUsersShared>(std::move(users), m->button_id);
|
||||
}
|
||||
CHECK(m->shared_dialogs.size() == 1);
|
||||
return td_api::make_object<td_api::messageChatShared>(m->shared_dialogs[0].get_shared_chat_object(td),
|
||||
m->button_id);
|
||||
}
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return nullptr;
|
||||
@ -7677,6 +7769,7 @@ string get_message_content_search_text(const Td *td, const MessageContent *conte
|
||||
case MessageContentType::ExpiredVideoNote:
|
||||
case MessageContentType::ExpiredVoiceNote:
|
||||
case MessageContentType::BoostApply:
|
||||
case MessageContentType::DialogShared:
|
||||
return string();
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -8021,6 +8114,8 @@ void add_message_content_dependencies(Dependencies &dependencies, const MessageC
|
||||
break;
|
||||
case MessageContentType::BoostApply:
|
||||
break;
|
||||
case MessageContentType::DialogShared:
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
break;
|
||||
|
@ -144,6 +144,8 @@ StringBuilder &operator<<(StringBuilder &string_builder, MessageContentType cont
|
||||
return string_builder << "ExpiredVoiceNote";
|
||||
case MessageContentType::BoostApply:
|
||||
return string_builder << "BoostApply";
|
||||
case MessageContentType::DialogShared:
|
||||
return string_builder << "ChatShared";
|
||||
default:
|
||||
return string_builder << "Invalid type " << static_cast<int32>(content_type);
|
||||
}
|
||||
@ -218,6 +220,7 @@ bool is_allowed_media_group_content(MessageContentType content_type) {
|
||||
case MessageContentType::ExpiredVideoNote:
|
||||
case MessageContentType::ExpiredVoiceNote:
|
||||
case MessageContentType::BoostApply:
|
||||
case MessageContentType::DialogShared:
|
||||
return false;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -298,6 +301,7 @@ bool can_be_secret_message_content(MessageContentType content_type) {
|
||||
case MessageContentType::ExpiredVideoNote:
|
||||
case MessageContentType::ExpiredVoiceNote:
|
||||
case MessageContentType::BoostApply:
|
||||
case MessageContentType::DialogShared:
|
||||
return false;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -374,6 +378,7 @@ bool is_service_message_content(MessageContentType content_type) {
|
||||
case MessageContentType::GiveawayLaunch:
|
||||
case MessageContentType::GiveawayResults:
|
||||
case MessageContentType::BoostApply:
|
||||
case MessageContentType::DialogShared:
|
||||
return true;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -450,6 +455,7 @@ bool is_editable_message_content(MessageContentType content_type) {
|
||||
case MessageContentType::ExpiredVideoNote:
|
||||
case MessageContentType::ExpiredVoiceNote:
|
||||
case MessageContentType::BoostApply:
|
||||
case MessageContentType::DialogShared:
|
||||
return false;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -574,6 +580,7 @@ bool can_have_message_content_caption(MessageContentType content_type) {
|
||||
case MessageContentType::ExpiredVideoNote:
|
||||
case MessageContentType::ExpiredVoiceNote:
|
||||
case MessageContentType::BoostApply:
|
||||
case MessageContentType::DialogShared:
|
||||
return false;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
|
@ -79,7 +79,8 @@ enum class MessageContentType : int32 {
|
||||
GiveawayWinners,
|
||||
ExpiredVideoNote,
|
||||
ExpiredVoiceNote,
|
||||
BoostApply
|
||||
BoostApply,
|
||||
DialogShared
|
||||
};
|
||||
// increase MessageUnsupported::CURRENT_VERSION each time a new message content type is added
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user