Add new message content type MessageLiveLocationApproached.
GitOrigin-RevId: 6bf5ac6b3320d0b6da9c27bf5258105ccd958396
This commit is contained in:
parent
91cf083c94
commit
de1e5e0bd4
@ -1688,6 +1688,9 @@ messagePassportDataSent types:vector<PassportElementType> = MessageContent;
|
||||
//@description Telegram Passport data has been received; for bots only @elements List of received Telegram Passport elements @credentials Encrypted data credentials
|
||||
messagePassportDataReceived elements:vector<encryptedPassportElement> credentials:encryptedCredentials = MessageContent;
|
||||
|
||||
//@description A user in the chat approached another user @approacher The user or chat, which approached another user @observer The user which subscribed for the approaching notification @distance The distance between users
|
||||
messageLiveLocationApproached approacher:MessageSender observer:MessageSender distance:int32 = MessageContent;
|
||||
|
||||
//@description Message content that is not supported in the current TDLib version
|
||||
messageUnsupported = MessageContent;
|
||||
|
||||
|
Binary file not shown.
@ -168,6 +168,7 @@ messageActionBotAllowed#abe9affe domain:string = MessageAction;
|
||||
messageActionSecureValuesSentMe#1b287353 values:Vector<SecureValue> credentials:SecureCredentialsEncrypted = MessageAction;
|
||||
messageActionSecureValuesSent#d95c6154 types:Vector<SecureValueType> = MessageAction;
|
||||
messageActionContactSignUp#f3f25f76 = MessageAction;
|
||||
messageActionGeoProximityReached#98e0d697 from_id:Peer to_id:Peer distance:int = MessageAction;
|
||||
|
||||
dialog#2c171f72 flags:# pinned:flags.2?true unread_mark:flags.3?true peer:Peer top_message:int read_inbox_max_id:int read_outbox_max_id:int unread_count:int unread_mentions_count:int notify_settings:PeerNotifySettings pts:flags.0?int draft:flags.1?DraftMessage folder_id:flags.4?int = Dialog;
|
||||
dialogFolder#71bd134c flags:# pinned:flags.2?true folder:Folder peer:Peer top_message:int unread_muted_peers_count:int unread_unmuted_peers_count:int unread_muted_messages_count:int unread_unmuted_messages_count:int = Dialog;
|
||||
|
Binary file not shown.
@ -305,6 +305,7 @@ bool DialogAction::is_cancelled_by_message_of_type(MessageContentType message_co
|
||||
case MessageContentType::PassportDataReceived:
|
||||
case MessageContentType::Poll:
|
||||
case MessageContentType::Dice:
|
||||
case MessageContentType::LiveLocationApproached:
|
||||
return false;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "td/telegram/MessageEntity.h"
|
||||
#include "td/telegram/MessageEntity.hpp"
|
||||
#include "td/telegram/MessageId.h"
|
||||
#include "td/telegram/MessagesManager.h"
|
||||
#include "td/telegram/MessageSearchFilter.h"
|
||||
#include "td/telegram/misc.h"
|
||||
#include "td/telegram/net/DcId.h"
|
||||
@ -677,6 +678,22 @@ class MessageDice : public MessageContent {
|
||||
}
|
||||
};
|
||||
|
||||
class MessageLiveLocationApproached : public MessageContent {
|
||||
public:
|
||||
DialogId approacher_dialog_id;
|
||||
DialogId observer_dialog_id;
|
||||
int32 distance = 0;
|
||||
|
||||
MessageLiveLocationApproached() = default;
|
||||
MessageLiveLocationApproached(DialogId approacher_dialog_id, DialogId observer_dialog_id, int32 distance)
|
||||
: approacher_dialog_id(approacher_dialog_id), observer_dialog_id(observer_dialog_id), distance(distance) {
|
||||
}
|
||||
|
||||
MessageContentType get_type() const override {
|
||||
return MessageContentType::LiveLocationApproached;
|
||||
}
|
||||
};
|
||||
|
||||
constexpr const char *MessageDice::DEFAULT_EMOJI;
|
||||
|
||||
template <class StorerT>
|
||||
@ -943,6 +960,13 @@ static void store(const MessageContent *content, StorerT &storer) {
|
||||
store(m->dice_value, storer);
|
||||
break;
|
||||
}
|
||||
case MessageContentType::LiveLocationApproached: {
|
||||
auto m = static_cast<const MessageLiveLocationApproached *>(content);
|
||||
store(m->approacher_dialog_id, storer);
|
||||
store(m->observer_dialog_id, storer);
|
||||
store(m->distance, storer);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
@ -1304,6 +1328,14 @@ static void parse(unique_ptr<MessageContent> &content, ParserT &parser) {
|
||||
content = std::move(m);
|
||||
break;
|
||||
}
|
||||
case MessageContentType::LiveLocationApproached: {
|
||||
auto m = make_unique<MessageLiveLocationApproached>();
|
||||
parse(m->approacher_dialog_id, parser);
|
||||
parse(m->observer_dialog_id, parser);
|
||||
parse(m->distance, parser);
|
||||
content = std::move(m);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
LOG(FATAL) << "Have unknown message content type " << static_cast<int32>(content_type);
|
||||
}
|
||||
@ -1989,6 +2021,7 @@ bool can_have_input_media(const Td *td, const MessageContent *content) {
|
||||
case MessageContentType::WebsiteConnected:
|
||||
case MessageContentType::PassportDataSent:
|
||||
case MessageContentType::PassportDataReceived:
|
||||
case MessageContentType::LiveLocationApproached:
|
||||
return false;
|
||||
case MessageContentType::Animation:
|
||||
case MessageContentType::Audio:
|
||||
@ -2101,6 +2134,7 @@ SecretInputMedia get_secret_input_media(const MessageContent *content, Td *td,
|
||||
case MessageContentType::WebsiteConnected:
|
||||
case MessageContentType::PassportDataSent:
|
||||
case MessageContentType::PassportDataReceived:
|
||||
case MessageContentType::LiveLocationApproached:
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -2285,6 +2319,7 @@ static tl_object_ptr<telegram_api::InputMedia> get_input_media_impl(
|
||||
case MessageContentType::WebsiteConnected:
|
||||
case MessageContentType::PassportDataSent:
|
||||
case MessageContentType::PassportDataReceived:
|
||||
case MessageContentType::LiveLocationApproached:
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -2407,6 +2442,7 @@ void delete_message_content_thumbnail(MessageContent *content, Td *td) {
|
||||
case MessageContentType::PassportDataSent:
|
||||
case MessageContentType::PassportDataReceived:
|
||||
case MessageContentType::Poll:
|
||||
case MessageContentType::LiveLocationApproached:
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -2530,6 +2566,7 @@ static int32 get_message_content_media_index_mask(const MessageContent *content,
|
||||
case MessageContentType::PassportDataReceived:
|
||||
case MessageContentType::Poll:
|
||||
case MessageContentType::Dice:
|
||||
case MessageContentType::LiveLocationApproached:
|
||||
return 0;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -3141,6 +3178,15 @@ void merge_message_contents(Td *td, const MessageContent *old_content, MessageCo
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MessageContentType::LiveLocationApproached: {
|
||||
auto old_ = static_cast<const MessageLiveLocationApproached *>(old_content);
|
||||
auto new_ = static_cast<const MessageLiveLocationApproached *>(new_content);
|
||||
if (old_->approacher_dialog_id != new_->approacher_dialog_id ||
|
||||
old_->observer_dialog_id != new_->observer_dialog_id || old_->distance != new_->distance) {
|
||||
need_update = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MessageContentType::Unsupported: {
|
||||
auto old_ = static_cast<const MessageUnsupported *>(old_content);
|
||||
auto new_ = static_cast<const MessageUnsupported *>(new_content);
|
||||
@ -3273,6 +3319,7 @@ bool merge_message_content_file_id(Td *td, MessageContent *message_content, File
|
||||
case MessageContentType::PassportDataReceived:
|
||||
case MessageContentType::Poll:
|
||||
case MessageContentType::Dice:
|
||||
case MessageContentType::LiveLocationApproached:
|
||||
LOG(ERROR) << "Receive new file " << new_file_id << " in a sent message of the type " << content_type;
|
||||
break;
|
||||
default:
|
||||
@ -4164,6 +4211,7 @@ unique_ptr<MessageContent> dup_message_content(Td *td, DialogId dialog_id, const
|
||||
case MessageContentType::WebsiteConnected:
|
||||
case MessageContentType::PassportDataSent:
|
||||
case MessageContentType::PassportDataReceived:
|
||||
case MessageContentType::LiveLocationApproached:
|
||||
return nullptr;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -4346,6 +4394,18 @@ unique_ptr<MessageContent> get_action_message_content(Td *td, tl_object_ptr<tele
|
||||
LOG_IF(ERROR, td->auth_manager_->is_bot()) << "Receive ContactRegistered in " << owner_dialog_id;
|
||||
return td::make_unique<MessageContactRegistered>();
|
||||
}
|
||||
case telegram_api::messageActionGeoProximityReached::ID: {
|
||||
auto geo_proximity_reached = move_tl_object_as<telegram_api::messageActionGeoProximityReached>(action);
|
||||
DialogId approacher_id(geo_proximity_reached->from_id_);
|
||||
DialogId observer_id(geo_proximity_reached->to_id_);
|
||||
int32 distance = geo_proximity_reached->distance_;
|
||||
if (!approacher_id.is_valid() || !observer_id.is_valid() || distance < 0) {
|
||||
LOG(ERROR) << "Receive invalid " << oneline(to_string(geo_proximity_reached));
|
||||
break;
|
||||
}
|
||||
|
||||
return make_unique<MessageLiveLocationApproached>(approacher_id, observer_id, distance);
|
||||
}
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
@ -4547,6 +4607,12 @@ tl_object_ptr<td_api::MessageContent> get_message_content_object(const MessageCo
|
||||
return make_tl_object<td_api::messageDice>(std::move(initial_state), std::move(final_state), m->emoji,
|
||||
m->dice_value, success_animation_frame_number);
|
||||
}
|
||||
case MessageContentType::LiveLocationApproached: {
|
||||
const MessageLiveLocationApproached *m = static_cast<const MessageLiveLocationApproached *>(content);
|
||||
return make_tl_object<td_api::messageLiveLocationApproached>(
|
||||
td->messages_manager_->get_message_sender_object(m->approacher_dialog_id),
|
||||
td->messages_manager_->get_message_sender_object(m->observer_dialog_id), m->distance);
|
||||
}
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return nullptr;
|
||||
@ -4858,6 +4924,7 @@ string get_message_content_search_text(const Td *td, const MessageContent *conte
|
||||
case MessageContentType::PassportDataSent:
|
||||
case MessageContentType::PassportDataReceived:
|
||||
case MessageContentType::Dice:
|
||||
case MessageContentType::LiveLocationApproached:
|
||||
return string();
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -5051,6 +5118,12 @@ void add_message_content_dependencies(Dependencies &dependencies, const MessageC
|
||||
break;
|
||||
case MessageContentType::Dice:
|
||||
break;
|
||||
case MessageContentType::LiveLocationApproached: {
|
||||
auto content = static_cast<const MessageLiveLocationApproached *>(message_content);
|
||||
add_message_sender_dependencies(dependencies, content->approacher_dialog_id);
|
||||
add_message_sender_dependencies(dependencies, content->observer_dialog_id);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
UNREACHABLE();
|
||||
break;
|
||||
|
@ -96,6 +96,8 @@ StringBuilder &operator<<(StringBuilder &string_builder, MessageContentType cont
|
||||
return string_builder << "Poll";
|
||||
case MessageContentType::Dice:
|
||||
return string_builder << "Dice";
|
||||
case MessageContentType::LiveLocationApproached:
|
||||
return string_builder << "LiveLocationApproached";
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return string_builder;
|
||||
@ -147,6 +149,7 @@ bool is_allowed_media_group_content(MessageContentType content_type) {
|
||||
case MessageContentType::PassportDataReceived:
|
||||
case MessageContentType::Poll:
|
||||
case MessageContentType::Dice:
|
||||
case MessageContentType::LiveLocationApproached:
|
||||
return false;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -206,6 +209,7 @@ bool is_secret_message_content(int32 ttl, MessageContentType content_type) {
|
||||
case MessageContentType::PassportDataReceived:
|
||||
case MessageContentType::Poll:
|
||||
case MessageContentType::Dice:
|
||||
case MessageContentType::LiveLocationApproached:
|
||||
return false;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -258,6 +262,7 @@ bool is_service_message_content(MessageContentType content_type) {
|
||||
case MessageContentType::WebsiteConnected:
|
||||
case MessageContentType::PassportDataSent:
|
||||
case MessageContentType::PassportDataReceived:
|
||||
case MessageContentType::LiveLocationApproached:
|
||||
return true;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -310,6 +315,7 @@ bool can_have_message_content_caption(MessageContentType content_type) {
|
||||
case MessageContentType::PassportDataReceived:
|
||||
case MessageContentType::Poll:
|
||||
case MessageContentType::Dice:
|
||||
case MessageContentType::LiveLocationApproached:
|
||||
return false;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
|
@ -54,7 +54,8 @@ enum class MessageContentType : int32 {
|
||||
PassportDataSent,
|
||||
PassportDataReceived,
|
||||
Poll,
|
||||
Dice
|
||||
Dice,
|
||||
LiveLocationApproached
|
||||
};
|
||||
|
||||
StringBuilder &operator<<(StringBuilder &string_builder, MessageContentType content_type);
|
||||
|
@ -5566,10 +5566,10 @@ void MessagesManager::on_preload_folder_dialog_list_timeout_callback(void *messa
|
||||
FolderId(narrow_cast<int32>(folder_id_int)));
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::MessageSender> MessagesManager::get_message_sender_object(UserId user_id,
|
||||
DialogId dialog_id) const {
|
||||
td_api::object_ptr<td_api::MessageSender> MessagesManager::get_message_sender_object_const(UserId user_id,
|
||||
DialogId dialog_id) const {
|
||||
if (dialog_id.is_valid()) {
|
||||
CHECK(have_dialog(dialog_id));
|
||||
CHECK(!have_dialog(dialog_id));
|
||||
return td_api::make_object<td_api::messageSenderChat>(dialog_id.get());
|
||||
}
|
||||
if (!user_id.is_valid()) {
|
||||
@ -5580,7 +5580,16 @@ td_api::object_ptr<td_api::MessageSender> MessagesManager::get_message_sender_ob
|
||||
td_->contacts_manager_->get_user_id_object(user_id, "get_message_sender_object"));
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::MessageSender> MessagesManager::get_message_sender_object(DialogId dialog_id) const {
|
||||
td_api::object_ptr<td_api::MessageSender> MessagesManager::get_message_sender_object(UserId user_id,
|
||||
DialogId dialog_id) {
|
||||
if (dialog_id.is_valid() && !have_dialog(dialog_id)) {
|
||||
LOG(ERROR) << "Failed to find " << dialog_id;
|
||||
force_create_dialog(dialog_id, "get_message_sender_object");
|
||||
}
|
||||
return get_message_sender_object_const(user_id, dialog_id);
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::MessageSender> MessagesManager::get_message_sender_object(DialogId dialog_id) {
|
||||
if (dialog_id.get_type() == DialogType::User) {
|
||||
return get_message_sender_object(dialog_id.get_user_id(), DialogId());
|
||||
}
|
||||
@ -21871,7 +21880,7 @@ tl_object_ptr<td_api::message> MessagesManager::get_message_object(DialogId dial
|
||||
auto date = is_scheduled ? 0 : m->date;
|
||||
auto edit_date = m->hide_edit_date ? 0 : m->edit_date;
|
||||
return make_tl_object<td_api::message>(
|
||||
m->message_id.get(), get_message_sender_object(m->sender_user_id, m->sender_dialog_id), dialog_id.get(),
|
||||
m->message_id.get(), get_message_sender_object_const(m->sender_user_id, m->sender_dialog_id), dialog_id.get(),
|
||||
std::move(sending_state), std::move(scheduling_state), is_outgoing, can_be_edited, can_be_forwarded,
|
||||
can_delete_for_self, can_delete_for_all_users, can_get_statistics, can_get_message_thread, m->is_channel_post,
|
||||
contains_unread_mention, date, edit_date, get_message_forward_info_object(m->forward_info),
|
||||
@ -22279,6 +22288,7 @@ Status MessagesManager::can_send_message_content(DialogId dialog_id, const Messa
|
||||
case MessageContentType::WebsiteConnected:
|
||||
case MessageContentType::PassportDataSent:
|
||||
case MessageContentType::PassportDataReceived:
|
||||
case MessageContentType::LiveLocationApproached:
|
||||
UNREACHABLE();
|
||||
}
|
||||
return Status::OK();
|
||||
@ -23839,6 +23849,7 @@ bool MessagesManager::can_edit_message(DialogId dialog_id, const Message *m, boo
|
||||
case MessageContentType::WebsiteConnected:
|
||||
case MessageContentType::PassportDataSent:
|
||||
case MessageContentType::PassportDataReceived:
|
||||
case MessageContentType::LiveLocationApproached:
|
||||
return false;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
|
@ -190,9 +190,11 @@ class MessagesManager : public Actor {
|
||||
MessagesManager &operator=(MessagesManager &&) = delete;
|
||||
~MessagesManager() override;
|
||||
|
||||
td_api::object_ptr<td_api::MessageSender> get_message_sender_object(UserId user_id, DialogId dialog_id) const;
|
||||
td_api::object_ptr<td_api::MessageSender> get_message_sender_object_const(UserId user_id, DialogId dialog_id) const;
|
||||
|
||||
td_api::object_ptr<td_api::MessageSender> get_message_sender_object(DialogId dialog_id) const;
|
||||
td_api::object_ptr<td_api::MessageSender> get_message_sender_object(UserId user_id, DialogId dialog_id);
|
||||
|
||||
td_api::object_ptr<td_api::MessageSender> get_message_sender_object(DialogId dialog_id);
|
||||
|
||||
static vector<MessageId> get_message_ids(const vector<int64> &input_message_ids);
|
||||
|
||||
|
@ -604,6 +604,16 @@ bool UpdatesManager::is_acceptable_message(const telegram_api::Message *message_
|
||||
}
|
||||
break;
|
||||
}
|
||||
case telegram_api::messageActionGeoProximityReached::ID: {
|
||||
auto geo_proximity_reached = static_cast<const telegram_api::messageActionGeoProximityReached *>(action);
|
||||
if (!is_acceptable_peer(geo_proximity_reached->from_id_)) {
|
||||
return false;
|
||||
}
|
||||
if (!is_acceptable_peer(geo_proximity_reached->to_id_)) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user