Add is_secret flag to messageAnimation, messagePhoto, messageVideo and messageVideoNote.
GitOrigin-RevId: 15bcfda6fb5723c6e4468ce73d0ad737a09426dc
This commit is contained in:
parent
aeff9a99d1
commit
e0381695a3
@ -802,8 +802,8 @@ paymentReceipt date:int32 payments_provider_user_id:int32 invoice:invoice order_
|
|||||||
//@description A text message @text Text of the message @web_page A preview of the web page that's mentioned in the text; may be null
|
//@description A text message @text Text of the message @web_page A preview of the web page that's mentioned in the text; may be null
|
||||||
messageText text:formattedText web_page:webPage = MessageContent;
|
messageText text:formattedText web_page:webPage = MessageContent;
|
||||||
|
|
||||||
//@description An animation message (GIF-style). @animation Message content @caption Animation caption
|
//@description An animation message (GIF-style). @animation Message content @caption Animation caption @is_secret True, if the animation thumbnail must be blurred and the animation must be shown only while tapped
|
||||||
messageAnimation animation:animation caption:formattedText = MessageContent;
|
messageAnimation animation:animation caption:formattedText is_secret:Bool = MessageContent;
|
||||||
|
|
||||||
//@description An audio message @audio Message content @caption Audio caption
|
//@description An audio message @audio Message content @caption Audio caption
|
||||||
messageAudio audio:audio caption:formattedText = MessageContent;
|
messageAudio audio:audio caption:formattedText = MessageContent;
|
||||||
@ -811,8 +811,8 @@ messageAudio audio:audio caption:formattedText = MessageContent;
|
|||||||
//@description A document message (general file) @document Message content @caption Document caption
|
//@description A document message (general file) @document Message content @caption Document caption
|
||||||
messageDocument document:document caption:formattedText = MessageContent;
|
messageDocument document:document caption:formattedText = MessageContent;
|
||||||
|
|
||||||
//@description A photo message @photo Message content @caption Photo caption
|
//@description A photo message @photo Message content @caption Photo caption @is_secret True, if the photo must be blurred and must be shown only while tapped
|
||||||
messagePhoto photo:photo caption:formattedText = MessageContent;
|
messagePhoto photo:photo caption:formattedText is_secret:Bool = MessageContent;
|
||||||
|
|
||||||
//@description An expired photo message (self-destructed after TTL has elapsed)
|
//@description An expired photo message (self-destructed after TTL has elapsed)
|
||||||
messageExpiredPhoto = MessageContent;
|
messageExpiredPhoto = MessageContent;
|
||||||
@ -820,14 +820,14 @@ messageExpiredPhoto = MessageContent;
|
|||||||
//@description A sticker message @sticker Message content
|
//@description A sticker message @sticker Message content
|
||||||
messageSticker sticker:sticker = MessageContent;
|
messageSticker sticker:sticker = MessageContent;
|
||||||
|
|
||||||
//@description A video message @video Message content @caption Video caption
|
//@description A video message @video Message content @caption Video caption @is_secret True, if the video thumbnail must be blurred and the video must be shown only while tapped
|
||||||
messageVideo video:video caption:formattedText = MessageContent;
|
messageVideo video:video caption:formattedText is_secret:Bool = MessageContent;
|
||||||
|
|
||||||
//@description An expired video message (self-destructed after TTL has elapsed)
|
//@description An expired video message (self-destructed after TTL has elapsed)
|
||||||
messageExpiredVideo = MessageContent;
|
messageExpiredVideo = MessageContent;
|
||||||
|
|
||||||
//@description A video note message @video_note Message content @is_viewed True, if at least one of the recipients has viewed the video note
|
//@description A video note message @video_note Message content @is_viewed True, if at least one of the recipients has viewed the video note @is_secret True, if the video note thumbnail must be blurred and the video note must be shown only while tapped
|
||||||
messageVideoNote video_note:videoNote is_viewed:Bool = MessageContent;
|
messageVideoNote video_note:videoNote is_viewed:Bool is_secret:Bool = MessageContent;
|
||||||
|
|
||||||
//@description A voice note message @voice_note Message content @caption Voice note caption @is_listened True, if at least one of the recipients has listened to the voice note
|
//@description A voice note message @voice_note Message content @caption Voice note caption @is_listened True, if at least one of the recipients has listened to the voice note
|
||||||
messageVoiceNote voice_note:voiceNote caption:formattedText is_listened:Bool = MessageContent;
|
messageVoiceNote voice_note:voiceNote caption:formattedText is_listened:Bool = MessageContent;
|
||||||
|
Binary file not shown.
@ -3947,6 +3947,7 @@ void MessagesManager::Message::store(StorerT &storer) const {
|
|||||||
STORE_FLAG(has_media_album_id);
|
STORE_FLAG(has_media_album_id);
|
||||||
STORE_FLAG(has_forward_from);
|
STORE_FLAG(has_forward_from);
|
||||||
STORE_FLAG(in_game_share);
|
STORE_FLAG(in_game_share);
|
||||||
|
STORE_FLAG(is_content_secret);
|
||||||
END_STORE_FLAGS();
|
END_STORE_FLAGS();
|
||||||
|
|
||||||
store(message_id, storer);
|
store(message_id, storer);
|
||||||
@ -4054,6 +4055,7 @@ void MessagesManager::Message::parse(ParserT &parser) {
|
|||||||
PARSE_FLAG(has_media_album_id);
|
PARSE_FLAG(has_media_album_id);
|
||||||
PARSE_FLAG(has_forward_from);
|
PARSE_FLAG(has_forward_from);
|
||||||
PARSE_FLAG(in_game_share);
|
PARSE_FLAG(in_game_share);
|
||||||
|
PARSE_FLAG(is_content_secret);
|
||||||
END_PARSE_FLAGS();
|
END_PARSE_FLAGS();
|
||||||
|
|
||||||
parse(message_id, parser);
|
parse(message_id, parser);
|
||||||
@ -4119,6 +4121,7 @@ void MessagesManager::Message::parse(ParserT &parser) {
|
|||||||
reply_markup = make_unique<ReplyMarkup>();
|
reply_markup = make_unique<ReplyMarkup>();
|
||||||
parse(*reply_markup, parser);
|
parse(*reply_markup, parser);
|
||||||
}
|
}
|
||||||
|
is_content_secret |= is_secret_message_content(ttl, content->get_id()); // repair is_content_secret for old messages
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class StorerT>
|
template <class StorerT>
|
||||||
@ -4693,7 +4696,8 @@ int32 MessagesManager::get_message_index_mask(DialogId dialog_id, const Message
|
|||||||
if (!m->message_id.is_server() && !is_secret) {
|
if (!m->message_id.is_server() && !is_secret) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (m->ttl > 0 && !is_secret) {
|
// retain second condition just in case
|
||||||
|
if (m->is_content_secret || (m->ttl > 0 && !is_secret)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int32 mentions_mask = get_message_content_index_mask(m->content.get(), is_secret, m->is_outgoing);
|
int32 mentions_mask = get_message_content_index_mask(m->content.get(), is_secret, m->is_outgoing);
|
||||||
@ -5247,10 +5251,11 @@ void MessagesManager::on_update_service_notification(tl_object_ptr<telegram_api:
|
|||||||
get_message_text(std::move(update->message_), std::move(update->entities_), update->inbox_date_),
|
get_message_text(std::move(update->message_), std::move(update->entities_), update->inbox_date_),
|
||||||
std::move(update->media_),
|
std::move(update->media_),
|
||||||
td_->auth_manager_->is_bot() ? DialogId() : get_service_notifications_dialog()->dialog_id, false, UserId(), &ttl);
|
td_->auth_manager_->is_bot() ? DialogId() : get_service_notifications_dialog()->dialog_id, false, UserId(), &ttl);
|
||||||
|
bool is_content_secret = is_secret_message_content(ttl, content->get_id());
|
||||||
if ((update->flags_ & telegram_api::updateServiceNotification::POPUP_MASK) != 0) {
|
if ((update->flags_ & telegram_api::updateServiceNotification::POPUP_MASK) != 0) {
|
||||||
send_closure(G()->td(), &Td::send_update,
|
send_closure(G()->td(), &Td::send_update,
|
||||||
make_tl_object<td_api::updateServiceNotification>(
|
make_tl_object<td_api::updateServiceNotification>(
|
||||||
update->type_, get_message_content_object(content.get(), update->inbox_date_)));
|
update->type_, get_message_content_object(content.get(), update->inbox_date_, is_content_secret)));
|
||||||
}
|
}
|
||||||
if ((update->flags_ & telegram_api::updateServiceNotification::INBOX_DATE_MASK) != 0 &&
|
if ((update->flags_ & telegram_api::updateServiceNotification::INBOX_DATE_MASK) != 0 &&
|
||||||
!td_->auth_manager_->is_bot()) {
|
!td_->auth_manager_->is_bot()) {
|
||||||
@ -5264,6 +5269,7 @@ void MessagesManager::on_update_service_notification(tl_object_ptr<telegram_api:
|
|||||||
new_message->sender_user_id = dialog_id.get_user_id();
|
new_message->sender_user_id = dialog_id.get_user_id();
|
||||||
new_message->date = update->inbox_date_;
|
new_message->date = update->inbox_date_;
|
||||||
new_message->ttl = ttl;
|
new_message->ttl = ttl;
|
||||||
|
new_message->is_content_secret = is_content_secret;
|
||||||
new_message->content = std::move(content);
|
new_message->content = std::move(content);
|
||||||
new_message->have_previous = true;
|
new_message->have_previous = true;
|
||||||
new_message->have_next = true;
|
new_message->have_next = true;
|
||||||
@ -7106,6 +7112,57 @@ void MessagesManager::delete_dialog_messages_from_updates(DialogId dialog_id, co
|
|||||||
send_update_delete_messages(dialog_id, std::move(deleted_message_ids), true, false);
|
send_update_delete_messages(dialog_id, std::move(deleted_message_ids), true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MessagesManager::is_secret_message_content(int32 ttl, int32 content_type) {
|
||||||
|
if (ttl <= 0 || ttl > 60) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
switch (content_type) {
|
||||||
|
case MessageAnimation::ID:
|
||||||
|
case MessageAudio::ID:
|
||||||
|
case MessagePhoto::ID:
|
||||||
|
case MessageVideo::ID:
|
||||||
|
case MessageVideoNote::ID:
|
||||||
|
case MessageVoiceNote::ID:
|
||||||
|
return true;
|
||||||
|
case MessageContact::ID:
|
||||||
|
case MessageDocument::ID:
|
||||||
|
case MessageGame::ID:
|
||||||
|
case MessageInvoice::ID:
|
||||||
|
case MessageLiveLocation::ID:
|
||||||
|
case MessageLocation::ID:
|
||||||
|
case MessageSticker::ID:
|
||||||
|
case MessageText::ID:
|
||||||
|
case MessageUnsupported::ID:
|
||||||
|
case MessageVenue::ID:
|
||||||
|
case MessageExpiredPhoto::ID:
|
||||||
|
case MessageExpiredVideo::ID:
|
||||||
|
case MessageChatCreate::ID:
|
||||||
|
case MessageChatChangeTitle::ID:
|
||||||
|
case MessageChatChangePhoto::ID:
|
||||||
|
case MessageChatDeletePhoto::ID:
|
||||||
|
case MessageChatDeleteHistory::ID:
|
||||||
|
case MessageChatAddUsers::ID:
|
||||||
|
case MessageChatJoinedByLink::ID:
|
||||||
|
case MessageChatDeleteUser::ID:
|
||||||
|
case MessageChatMigrateTo::ID:
|
||||||
|
case MessageChannelCreate::ID:
|
||||||
|
case MessageChannelMigrateFrom::ID:
|
||||||
|
case MessagePinMessage::ID:
|
||||||
|
case MessageGameScore::ID:
|
||||||
|
case MessageScreenshotTaken::ID:
|
||||||
|
case MessageChatSetTtl::ID:
|
||||||
|
case MessageCall::ID:
|
||||||
|
case MessagePaymentSuccessful::ID:
|
||||||
|
case MessageContactRegistered::ID:
|
||||||
|
case MessageCustomServiceAction::ID:
|
||||||
|
case MessageWebsiteConnected::ID:
|
||||||
|
return false;
|
||||||
|
default:
|
||||||
|
UNREACHABLE();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool MessagesManager::is_service_message_content(int32 content_type) {
|
bool MessagesManager::is_service_message_content(int32 content_type) {
|
||||||
switch (content_type) {
|
switch (content_type) {
|
||||||
case MessageAnimation::ID:
|
case MessageAnimation::ID:
|
||||||
@ -7155,6 +7212,9 @@ bool MessagesManager::is_service_message_content(int32 content_type) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
string MessagesManager::get_search_text(const Message *m) {
|
string MessagesManager::get_search_text(const Message *m) {
|
||||||
|
if (m->is_content_secret) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
switch (m->content->get_id()) {
|
switch (m->content->get_id()) {
|
||||||
case MessageText::ID: {
|
case MessageText::ID: {
|
||||||
auto *text = static_cast<const MessageText *>(m->content.get());
|
auto *text = static_cast<const MessageText *>(m->content.get());
|
||||||
@ -8422,14 +8482,15 @@ void MessagesManager::set_dialog_max_unavailable_message_id(DialogId dialog_id,
|
|||||||
}
|
}
|
||||||
|
|
||||||
tl_object_ptr<td_api::MessageContent> MessagesManager::get_message_content_object(const MessageContent *content,
|
tl_object_ptr<td_api::MessageContent> MessagesManager::get_message_content_object(const MessageContent *content,
|
||||||
int32 message_date) const {
|
int32 message_date,
|
||||||
|
bool is_content_secret) const {
|
||||||
CHECK(content != nullptr);
|
CHECK(content != nullptr);
|
||||||
switch (content->get_id()) {
|
switch (content->get_id()) {
|
||||||
case MessageAnimation::ID: {
|
case MessageAnimation::ID: {
|
||||||
const MessageAnimation *m = static_cast<const MessageAnimation *>(content);
|
const MessageAnimation *m = static_cast<const MessageAnimation *>(content);
|
||||||
return make_tl_object<td_api::messageAnimation>(
|
return make_tl_object<td_api::messageAnimation>(
|
||||||
td_->animations_manager_->get_animation_object(m->file_id, "get_message_content_object"),
|
td_->animations_manager_->get_animation_object(m->file_id, "get_message_content_object"),
|
||||||
get_formatted_text_object(m->caption));
|
get_formatted_text_object(m->caption), is_content_secret);
|
||||||
}
|
}
|
||||||
case MessageAudio::ID: {
|
case MessageAudio::ID: {
|
||||||
const MessageAudio *m = static_cast<const MessageAudio *>(content);
|
const MessageAudio *m = static_cast<const MessageAudio *>(content);
|
||||||
@ -8469,7 +8530,7 @@ tl_object_ptr<td_api::MessageContent> MessagesManager::get_message_content_objec
|
|||||||
case MessagePhoto::ID: {
|
case MessagePhoto::ID: {
|
||||||
const MessagePhoto *m = static_cast<const MessagePhoto *>(content);
|
const MessagePhoto *m = static_cast<const MessagePhoto *>(content);
|
||||||
return make_tl_object<td_api::messagePhoto>(get_photo_object(td_->file_manager_.get(), &m->photo),
|
return make_tl_object<td_api::messagePhoto>(get_photo_object(td_->file_manager_.get(), &m->photo),
|
||||||
get_formatted_text_object(m->caption));
|
get_formatted_text_object(m->caption), is_content_secret);
|
||||||
}
|
}
|
||||||
case MessageSticker::ID: {
|
case MessageSticker::ID: {
|
||||||
const MessageSticker *m = static_cast<const MessageSticker *>(content);
|
const MessageSticker *m = static_cast<const MessageSticker *>(content);
|
||||||
@ -8490,12 +8551,12 @@ tl_object_ptr<td_api::MessageContent> MessagesManager::get_message_content_objec
|
|||||||
case MessageVideo::ID: {
|
case MessageVideo::ID: {
|
||||||
const MessageVideo *m = static_cast<const MessageVideo *>(content);
|
const MessageVideo *m = static_cast<const MessageVideo *>(content);
|
||||||
return make_tl_object<td_api::messageVideo>(td_->videos_manager_->get_video_object(m->file_id),
|
return make_tl_object<td_api::messageVideo>(td_->videos_manager_->get_video_object(m->file_id),
|
||||||
get_formatted_text_object(m->caption));
|
get_formatted_text_object(m->caption), is_content_secret);
|
||||||
}
|
}
|
||||||
case MessageVideoNote::ID: {
|
case MessageVideoNote::ID: {
|
||||||
const MessageVideoNote *m = static_cast<const MessageVideoNote *>(content);
|
const MessageVideoNote *m = static_cast<const MessageVideoNote *>(content);
|
||||||
return make_tl_object<td_api::messageVideoNote>(td_->video_notes_manager_->get_video_note_object(m->file_id),
|
return make_tl_object<td_api::messageVideoNote>(td_->video_notes_manager_->get_video_note_object(m->file_id),
|
||||||
m->is_viewed);
|
m->is_viewed, is_content_secret);
|
||||||
}
|
}
|
||||||
case MessageVoiceNote::ID: {
|
case MessageVoiceNote::ID: {
|
||||||
const MessageVoiceNote *m = static_cast<const MessageVoiceNote *>(content);
|
const MessageVoiceNote *m = static_cast<const MessageVoiceNote *>(content);
|
||||||
@ -8710,11 +8771,7 @@ void MessagesManager::ttl_read_history_outbox(DialogId dialog_id, MessageId from
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MessagesManager::ttl_on_view(const Dialog *d, Message *message, double view_date, double now) {
|
void MessagesManager::ttl_on_view(const Dialog *d, Message *message, double view_date, double now) {
|
||||||
auto content_type = message->content->get_id();
|
if (message->ttl > 0 && message->ttl_expires_at == 0 && !message->is_content_secret) {
|
||||||
if ((content_type == MessageText::ID || content_type == MessageContact::ID ||
|
|
||||||
content_type == MessageLiveLocation::ID || content_type == MessageLocation::ID ||
|
|
||||||
content_type == MessageSticker::ID || content_type == MessageVenue::ID) &&
|
|
||||||
message->ttl > 0 && message->ttl_expires_at == 0) {
|
|
||||||
message->ttl_expires_at = message->ttl + view_date;
|
message->ttl_expires_at = message->ttl + view_date;
|
||||||
ttl_register_message(d->dialog_id, message, now);
|
ttl_register_message(d->dialog_id, message, now);
|
||||||
on_message_changed(d, message, "ttl_on_view");
|
on_message_changed(d, message, "ttl_on_view");
|
||||||
@ -8803,7 +8860,7 @@ void MessagesManager::on_message_ttl_expired(Dialog *d, Message *message) {
|
|||||||
ttl_unregister_message(d->dialog_id, message, Time::now());
|
ttl_unregister_message(d->dialog_id, message, Time::now());
|
||||||
on_message_ttl_expired_impl(d, message);
|
on_message_ttl_expired_impl(d, message);
|
||||||
send_update_message_content(d->dialog_id, message->message_id, message->content.get(), message->date,
|
send_update_message_content(d->dialog_id, message->message_id, message->content.get(), message->date,
|
||||||
"on_message_ttl_expired");
|
message->is_content_secret, "on_message_ttl_expired");
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessagesManager::on_message_ttl_expired_impl(Dialog *d, Message *message) {
|
void MessagesManager::on_message_ttl_expired_impl(Dialog *d, Message *message) {
|
||||||
@ -8838,6 +8895,7 @@ void MessagesManager::on_message_ttl_expired_impl(Dialog *d, Message *message) {
|
|||||||
update_message_contains_unread_mention(d, message, false, "on_message_ttl_expired_impl");
|
update_message_contains_unread_mention(d, message, false, "on_message_ttl_expired_impl");
|
||||||
message->contains_mention = false;
|
message->contains_mention = false;
|
||||||
message->reply_to_message_id = MessageId();
|
message->reply_to_message_id = MessageId();
|
||||||
|
message->is_content_secret = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessagesManager::loop() {
|
void MessagesManager::loop() {
|
||||||
@ -9593,6 +9651,8 @@ std::pair<DialogId, unique_ptr<MessagesManager::Message>> MessagesManager::creat
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32 ttl = message_info.ttl;
|
int32 ttl = message_info.ttl;
|
||||||
|
bool is_content_secret =
|
||||||
|
is_secret_message_content(ttl, message_info.content->get_id()); // should be calculated before TTL is adjusted
|
||||||
if (ttl < 0) {
|
if (ttl < 0) {
|
||||||
LOG(ERROR) << "Wrong ttl = " << ttl << " received in " << message_id << " in " << dialog_id;
|
LOG(ERROR) << "Wrong ttl = " << ttl << " received in " << message_id << " in " << dialog_id;
|
||||||
ttl = 0;
|
ttl = 0;
|
||||||
@ -9628,6 +9688,7 @@ std::pair<DialogId, unique_ptr<MessagesManager::Message>> MessagesManager::creat
|
|||||||
message_id.is_server() && message->contains_mention && (flags & MESSAGE_FLAG_HAS_UNREAD_CONTENT) != 0 &&
|
message_id.is_server() && message->contains_mention && (flags & MESSAGE_FLAG_HAS_UNREAD_CONTENT) != 0 &&
|
||||||
(dialog_type == DialogType::Chat || (dialog_type == DialogType::Channel && !is_broadcast_channel(dialog_id)));
|
(dialog_type == DialogType::Chat || (dialog_type == DialogType::Channel && !is_broadcast_channel(dialog_id)));
|
||||||
message->disable_notification = is_silent;
|
message->disable_notification = is_silent;
|
||||||
|
message->is_content_secret = is_content_secret;
|
||||||
message->views = views;
|
message->views = views;
|
||||||
message->content = std::move(message_info.content);
|
message->content = std::move(message_info.content);
|
||||||
message->reply_markup = get_reply_markup(std::move(message_info.reply_markup), td_->auth_manager_->is_bot(), false,
|
message->reply_markup = get_reply_markup(std::move(message_info.reply_markup), td_->auth_manager_->is_bot(), false,
|
||||||
@ -9649,7 +9710,8 @@ std::pair<DialogId, unique_ptr<MessagesManager::Message>> MessagesManager::creat
|
|||||||
if (!is_allowed_media_group_content(content_id)) {
|
if (!is_allowed_media_group_content(content_id)) {
|
||||||
LOG(ERROR) << "Receive media group id " << message_info.media_album_id << " in " << message_id << " from "
|
LOG(ERROR) << "Receive media group id " << message_info.media_album_id << " in " << message_id << " from "
|
||||||
<< dialog_id << " with content "
|
<< dialog_id << " with content "
|
||||||
<< oneline(to_string(get_message_content_object(message->content.get(), message->date)));
|
<< oneline(to_string(
|
||||||
|
get_message_content_object(message->content.get(), message->date, is_content_secret)));
|
||||||
} else {
|
} else {
|
||||||
message->media_album_id = message_info.media_album_id;
|
message->media_album_id = message_info.media_album_id;
|
||||||
}
|
}
|
||||||
@ -10034,9 +10096,11 @@ void MessagesManager::on_update_sent_text_message(int64 random_id,
|
|||||||
|
|
||||||
if (is_content_changed) {
|
if (is_content_changed) {
|
||||||
m->content = std::move(new_content);
|
m->content = std::move(new_content);
|
||||||
|
m->is_content_secret = is_secret_message_content(m->ttl, m->content->get_id());
|
||||||
}
|
}
|
||||||
if (need_update) {
|
if (need_update) {
|
||||||
send_update_message_content(dialog_id, m->message_id, m->content.get(), m->date, "on_update_sent_text_message");
|
send_update_message_content(dialog_id, m->message_id, m->content.get(), m->date, m->is_content_secret,
|
||||||
|
"on_update_sent_text_message");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -10073,7 +10137,8 @@ void MessagesManager::on_update_message_web_page(FullMessageId full_message_id,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
send_update_message_content(dialog_id, message_id, content, message->date, "on_update_message_web_page");
|
send_update_message_content(dialog_id, message_id, content, message->date, message->is_content_secret,
|
||||||
|
"on_update_message_web_page");
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessagesManager::on_get_dialogs(vector<tl_object_ptr<telegram_api::dialog>> &&dialogs, int32 total_count,
|
void MessagesManager::on_get_dialogs(vector<tl_object_ptr<telegram_api::dialog>> &&dialogs, int32 total_count,
|
||||||
@ -13907,7 +13972,7 @@ tl_object_ptr<td_api::message> MessagesManager::get_message_object(DialogId dial
|
|||||||
message->ttl_expires_at != 0 ? max(message->ttl_expires_at - Time::now(), 1e-3) : message->ttl,
|
message->ttl_expires_at != 0 ? max(message->ttl_expires_at - Time::now(), 1e-3) : message->ttl,
|
||||||
td_->contacts_manager_->get_user_id_object(message->via_bot_user_id, "via_bot_user_id"),
|
td_->contacts_manager_->get_user_id_object(message->via_bot_user_id, "via_bot_user_id"),
|
||||||
message->author_signature, message->views, message->media_album_id,
|
message->author_signature, message->views, message->media_album_id,
|
||||||
get_message_content_object(message->content.get(), message->date),
|
get_message_content_object(message->content.get(), message->date, message->is_content_secret),
|
||||||
get_reply_markup_object(message->reply_markup));
|
get_reply_markup_object(message->reply_markup));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -14460,9 +14525,7 @@ MessagesManager::Message *MessagesManager::get_message_to_send(Dialog *d, Messag
|
|||||||
if (is_service_message_content(m->content->get_id())) {
|
if (is_service_message_content(m->content->get_id())) {
|
||||||
m->ttl = 0;
|
m->ttl = 0;
|
||||||
}
|
}
|
||||||
if (m->ttl > 0) {
|
m->is_content_secret = is_secret_message_content(m->ttl, m->content->get_id());
|
||||||
m->ttl = max(m->ttl, get_message_content_duration(m->content.get()) + 1);
|
|
||||||
}
|
|
||||||
if (reply_to_message_id.is_valid()) {
|
if (reply_to_message_id.is_valid()) {
|
||||||
auto *reply_to_message = get_message_force(d, reply_to_message_id);
|
auto *reply_to_message = get_message_force(d, reply_to_message_id);
|
||||||
if (reply_to_message != nullptr) {
|
if (reply_to_message != nullptr) {
|
||||||
@ -15214,6 +15277,7 @@ Result<MessageId> MessagesManager::send_message(DialogId dialog_id, MessageId re
|
|||||||
m->clear_draft = message_content.clear_draft;
|
m->clear_draft = message_content.clear_draft;
|
||||||
if (message_content.ttl > 0) {
|
if (message_content.ttl > 0) {
|
||||||
m->ttl = message_content.ttl;
|
m->ttl = message_content.ttl;
|
||||||
|
m->is_content_secret = is_secret_message_content(m->ttl, m->content->get_id());
|
||||||
}
|
}
|
||||||
|
|
||||||
send_update_new_message(d, m, true);
|
send_update_new_message(d, m, true);
|
||||||
@ -15701,6 +15765,7 @@ Result<vector<MessageId>> MessagesManager::send_message_group(
|
|||||||
auto ttl = message_content.second;
|
auto ttl = message_content.second;
|
||||||
if (ttl > 0) {
|
if (ttl > 0) {
|
||||||
m->ttl = ttl;
|
m->ttl = ttl;
|
||||||
|
m->is_content_secret = is_secret_message_content(m->ttl, m->content->get_id());
|
||||||
}
|
}
|
||||||
m->media_album_id = media_album_id;
|
m->media_album_id = media_album_id;
|
||||||
|
|
||||||
@ -17920,13 +17985,14 @@ void MessagesManager::send_update_message_send_succeeded(Dialog *d, MessageId ol
|
|||||||
|
|
||||||
void MessagesManager::send_update_message_content(DialogId dialog_id, MessageId message_id,
|
void MessagesManager::send_update_message_content(DialogId dialog_id, MessageId message_id,
|
||||||
const MessageContent *content, int32 message_date,
|
const MessageContent *content, int32 message_date,
|
||||||
const char *source) const {
|
bool is_content_secret, const char *source) const {
|
||||||
LOG(INFO) << "Send updateMessageContent for " << message_id << " in " << dialog_id << " from " << source;
|
LOG(INFO) << "Send updateMessageContent for " << message_id << " in " << dialog_id << " from " << source;
|
||||||
CHECK(have_dialog(dialog_id)) << "Send updateMessageContent in unknown " << dialog_id << " from " << source
|
CHECK(have_dialog(dialog_id)) << "Send updateMessageContent in unknown " << dialog_id << " from " << source
|
||||||
<< " with load count " << loaded_dialogs_.count(dialog_id);
|
<< " with load count " << loaded_dialogs_.count(dialog_id);
|
||||||
send_closure(G()->td(), &Td::send_update,
|
send_closure(
|
||||||
make_tl_object<td_api::updateMessageContent>(dialog_id.get(), message_id.get(),
|
G()->td(), &Td::send_update,
|
||||||
get_message_content_object(content, message_date)));
|
make_tl_object<td_api::updateMessageContent>(
|
||||||
|
dialog_id.get(), message_id.get(), get_message_content_object(content, message_date, is_content_secret)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessagesManager::send_update_message_edited(FullMessageId full_message_id) const {
|
void MessagesManager::send_update_message_edited(FullMessageId full_message_id) const {
|
||||||
@ -18303,7 +18369,8 @@ FullMessageId MessagesManager::on_send_message_success(int64 random_id, MessageI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (is_content_changed) {
|
if (is_content_changed) {
|
||||||
send_update_message_content(dialog_id, old_message_id, sent_message->content.get(), sent_message->date, source);
|
send_update_message_content(dialog_id, old_message_id, sent_message->content.get(), sent_message->date,
|
||||||
|
sent_message->is_content_secret, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
sent_message->message_id = new_message_id;
|
sent_message->message_id = new_message_id;
|
||||||
@ -21696,7 +21763,7 @@ void MessagesManager::delete_message_from_database(Dialog *d, MessageId message_
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto is_secret = d->dialog_id.get_type() == DialogType::SecretChat;
|
auto is_secret = d->dialog_id.get_type() == DialogType::SecretChat;
|
||||||
if (m != nullptr && m->ttl > 0 && !is_secret) {
|
if (m != nullptr && m->ttl > 0) {
|
||||||
delete_message_files(m);
|
delete_message_files(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22003,7 +22070,7 @@ bool MessagesManager::need_message_text_changed_warning(const Message *old_messa
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MessagesManager::update_message_content(DialogId dialog_id, const Message *old_message,
|
bool MessagesManager::update_message_content(DialogId dialog_id, Message *old_message,
|
||||||
unique_ptr<MessageContent> &old_content,
|
unique_ptr<MessageContent> &old_content,
|
||||||
unique_ptr<MessageContent> new_content,
|
unique_ptr<MessageContent> new_content,
|
||||||
bool need_send_update_message_content) {
|
bool need_send_update_message_content) {
|
||||||
@ -22016,6 +22083,8 @@ bool MessagesManager::update_message_content(DialogId dialog_id, const Message *
|
|||||||
need_update = true;
|
need_update = true;
|
||||||
LOG(INFO) << "Message content has changed its type from " << old_content_type << " to " << new_content_type;
|
LOG(INFO) << "Message content has changed its type from " << old_content_type << " to " << new_content_type;
|
||||||
|
|
||||||
|
old_message->is_content_secret = is_secret_message_content(old_message->ttl, new_content->get_id());
|
||||||
|
|
||||||
auto old_file_id = get_message_content_file_id(old_content.get());
|
auto old_file_id = get_message_content_file_id(old_content.get());
|
||||||
if (old_file_id.is_valid()) {
|
if (old_file_id.is_valid()) {
|
||||||
// cancel file upload of the main file to allow next upload with the same file to succeed
|
// cancel file upload of the main file to allow next upload with the same file to succeed
|
||||||
@ -22070,7 +22139,8 @@ bool MessagesManager::update_message_content(DialogId dialog_id, const Message *
|
|||||||
if (need_message_text_changed_warning(old_message, old_, new_)) {
|
if (need_message_text_changed_warning(old_message, old_, new_)) {
|
||||||
LOG(ERROR) << "Message text has changed for " << to_string(get_message_object(dialog_id, old_message))
|
LOG(ERROR) << "Message text has changed for " << to_string(get_message_object(dialog_id, old_message))
|
||||||
<< ". New content is "
|
<< ". New content is "
|
||||||
<< to_string(get_message_content_object(new_content.get(), old_message->date));
|
<< to_string(get_message_content_object(new_content.get(), old_message->date,
|
||||||
|
old_message->is_content_secret));
|
||||||
}
|
}
|
||||||
need_update = true;
|
need_update = true;
|
||||||
}
|
}
|
||||||
@ -22080,7 +22150,8 @@ bool MessagesManager::update_message_content(DialogId dialog_id, const Message *
|
|||||||
old_->text.entities.size() <= MAX_CUSTOM_ENTITIES_COUNT) {
|
old_->text.entities.size() <= MAX_CUSTOM_ENTITIES_COUNT) {
|
||||||
LOG(WARNING) << "Entities has changed for " << to_string(get_message_object(dialog_id, old_message))
|
LOG(WARNING) << "Entities has changed for " << to_string(get_message_object(dialog_id, old_message))
|
||||||
<< ". New content is "
|
<< ". New content is "
|
||||||
<< to_string(get_message_content_object(new_content.get(), old_message->date));
|
<< to_string(get_message_content_object(new_content.get(), old_message->date,
|
||||||
|
old_message->is_content_secret));
|
||||||
}
|
}
|
||||||
need_update = true;
|
need_update = true;
|
||||||
}
|
}
|
||||||
@ -22437,7 +22508,7 @@ bool MessagesManager::update_message_content(DialogId dialog_id, const Message *
|
|||||||
|
|
||||||
if (need_update && need_send_update_message_content) {
|
if (need_update && need_send_update_message_content) {
|
||||||
send_update_message_content(dialog_id, old_message->message_id, old_content.get(), old_message->date,
|
send_update_message_content(dialog_id, old_message->message_id, old_content.get(), old_message->date,
|
||||||
"update_message_content");
|
old_message->is_content_secret, "update_message_content");
|
||||||
}
|
}
|
||||||
return is_content_changed || need_update;
|
return is_content_changed || need_update;
|
||||||
}
|
}
|
||||||
|
@ -1424,7 +1424,8 @@ class MessagesManager : public Actor {
|
|||||||
bool disable_notification = false;
|
bool disable_notification = false;
|
||||||
bool contains_mention = false;
|
bool contains_mention = false;
|
||||||
bool contains_unread_mention = false;
|
bool contains_unread_mention = false;
|
||||||
bool had_reply_markup = false; // had non-inline reply markup?
|
bool had_reply_markup = false; // had non-inline reply markup?
|
||||||
|
bool is_content_secret = false; // should be shown only while tapped
|
||||||
|
|
||||||
bool from_background = false; // for send_message
|
bool from_background = false; // for send_message
|
||||||
bool disable_web_page_preview = false; // for send_message
|
bool disable_web_page_preview = false; // for send_message
|
||||||
@ -1918,6 +1919,8 @@ class MessagesManager : public Actor {
|
|||||||
|
|
||||||
static bool can_forward_message(DialogId from_dialog_id, const Message *m);
|
static bool can_forward_message(DialogId from_dialog_id, const Message *m);
|
||||||
|
|
||||||
|
static bool is_secret_message_content(int32 ttl, int32 content_type);
|
||||||
|
|
||||||
static bool is_service_message_content(int32 content_type);
|
static bool is_service_message_content(int32 content_type);
|
||||||
|
|
||||||
static bool can_delete_channel_message(DialogParticipantStatus status, const Message *m, bool is_bot);
|
static bool can_delete_channel_message(DialogParticipantStatus status, const Message *m, bool is_bot);
|
||||||
@ -2060,7 +2063,7 @@ class MessagesManager : public Actor {
|
|||||||
bool need_message_text_changed_warning(const Message *old_message, const MessageText *old_content,
|
bool need_message_text_changed_warning(const Message *old_message, const MessageText *old_content,
|
||||||
const MessageText *new_content);
|
const MessageText *new_content);
|
||||||
|
|
||||||
bool update_message_content(DialogId dialog_id, const Message *old_message, unique_ptr<MessageContent> &old_content,
|
bool update_message_content(DialogId dialog_id, Message *old_message, unique_ptr<MessageContent> &old_content,
|
||||||
unique_ptr<MessageContent> new_content, bool need_send_update_message_content);
|
unique_ptr<MessageContent> new_content, bool need_send_update_message_content);
|
||||||
|
|
||||||
void send_update_new_message(Dialog *d, const Message *m, bool force = false);
|
void send_update_new_message(Dialog *d, const Message *m, bool force = false);
|
||||||
@ -2070,7 +2073,7 @@ class MessagesManager : public Actor {
|
|||||||
void send_update_message_send_succeeded(Dialog *d, MessageId old_message_id, const Message *m) const;
|
void send_update_message_send_succeeded(Dialog *d, MessageId old_message_id, const Message *m) const;
|
||||||
|
|
||||||
void send_update_message_content(DialogId dialog_id, MessageId message_id, const MessageContent *content,
|
void send_update_message_content(DialogId dialog_id, MessageId message_id, const MessageContent *content,
|
||||||
int32 message_date, const char *source) const;
|
int32 message_date, bool is_content_secret, const char *source) const;
|
||||||
|
|
||||||
void send_update_message_edited(FullMessageId full_message_id) const;
|
void send_update_message_edited(FullMessageId full_message_id) const;
|
||||||
|
|
||||||
@ -2265,8 +2268,8 @@ class MessagesManager : public Actor {
|
|||||||
unique_ptr<MessageContent> get_message_action_content(tl_object_ptr<telegram_api::MessageAction> &&action,
|
unique_ptr<MessageContent> get_message_action_content(tl_object_ptr<telegram_api::MessageAction> &&action,
|
||||||
DialogId owner_dialog_id, MessageId reply_to_message_id) const;
|
DialogId owner_dialog_id, MessageId reply_to_message_id) const;
|
||||||
|
|
||||||
tl_object_ptr<td_api::MessageContent> get_message_content_object(const MessageContent *content,
|
tl_object_ptr<td_api::MessageContent> get_message_content_object(const MessageContent *content, int32 message_date,
|
||||||
int32 message_date) const;
|
bool is_content_secret) const;
|
||||||
|
|
||||||
static FormattedText get_message_content_caption(const MessageContent *content);
|
static FormattedText get_message_content_caption(const MessageContent *content);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user