Remove spoiler and custom emoji entities from messages forwarded to secret chats.
This commit is contained in:
parent
03773d01fd
commit
833dfcc9db
@ -4660,8 +4660,13 @@ unique_ptr<MessageContent> dup_message_content(Td *td, DialogId dialog_id, const
|
||||
CHECK(result->file_id.is_valid());
|
||||
return std::move(result);
|
||||
}
|
||||
case MessageContentType::Text:
|
||||
return make_unique<MessageText>(*static_cast<const MessageText *>(content));
|
||||
case MessageContentType::Text: {
|
||||
auto result = make_unique<MessageText>(*static_cast<const MessageText *>(content));
|
||||
if (type == MessageContentDupType::Copy || type == MessageContentDupType::ServerCopy) {
|
||||
remove_unallowed_entities(result->text, to_secret);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
case MessageContentType::Venue:
|
||||
return make_unique<MessageVenue>(*static_cast<const MessageVenue *>(content));
|
||||
case MessageContentType::Video: {
|
||||
|
@ -209,6 +209,14 @@ td_api::object_ptr<td_api::formattedText> get_formatted_text_object(const Format
|
||||
text.text, get_text_entities_object(text.entities, skip_bot_commands, max_media_timestamp));
|
||||
}
|
||||
|
||||
void remove_unallowed_entities(FormattedText &text, bool to_secret) {
|
||||
if (to_secret) {
|
||||
td::remove_if(text.entities, [](const MessageEntity &entity) {
|
||||
return entity.type == MessageEntity::Type::Spoiler || entity.type == MessageEntity::Type::CustomEmoji;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
static bool is_word_character(uint32 code) {
|
||||
switch (get_unicode_simple_category(code)) {
|
||||
case UnicodeSimpleCategory::Letter:
|
||||
@ -3271,6 +3279,8 @@ vector<tl_object_ptr<secret_api::MessageEntity>> get_input_secret_message_entiti
|
||||
break;
|
||||
case MessageEntity::Type::Spoiler:
|
||||
break;
|
||||
case MessageEntity::Type::CustomEmoji:
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
@ -150,6 +150,8 @@ vector<tl_object_ptr<td_api::textEntity>> get_text_entities_object(const vector<
|
||||
td_api::object_ptr<td_api::formattedText> get_formatted_text_object(const FormattedText &text, bool skip_bot_commands,
|
||||
int32 max_media_timestamp);
|
||||
|
||||
void remove_unallowed_entities(FormattedText &text, bool to_secret);
|
||||
|
||||
vector<MessageEntity> find_entities(Slice text, bool skip_bot_commands, bool skip_media_timestamps);
|
||||
|
||||
vector<Slice> find_mentions(Slice str);
|
||||
|
Loading…
x
Reference in New Issue
Block a user