Support premium stickers in secret chats.

This commit is contained in:
levlam 2022-06-03 17:31:48 +03:00
parent 8b9bed6a0b
commit 8fae960e43
6 changed files with 14 additions and 6 deletions

View File

@ -14312,6 +14312,11 @@ bool ContactsManager::have_min_user(UserId user_id) const {
return users_.count(user_id) > 0;
}
bool ContactsManager::is_user_premium(UserId user_id) const {
auto u = get_user(user_id);
return u != nullptr && u->is_premium;
}
bool ContactsManager::is_user_deleted(UserId user_id) const {
auto u = get_user(user_id);
return u == nullptr || u->is_deleted;

View File

@ -452,6 +452,8 @@ class ContactsManager final : public Actor {
bool is_user_contact(UserId user_id, bool is_mutual = false) const;
bool is_user_premium(UserId user_id) const;
bool is_user_deleted(UserId user_id) const;
bool is_user_support(UserId user_id) const;

View File

@ -4033,7 +4033,7 @@ unique_ptr<MessageContent> get_secret_message_content(
Td *td, string message_text, unique_ptr<EncryptedFile> file,
tl_object_ptr<secret_api::DecryptedMessageMedia> &&media,
vector<tl_object_ptr<secret_api::MessageEntity>> &&secret_entities, DialogId owner_dialog_id,
MultiPromiseActor &load_data_multipromise) {
MultiPromiseActor &load_data_multipromise, bool is_premium) {
int32 constructor_id = media == nullptr ? secret_api::decryptedMessageMediaEmpty::ID : media->get_id();
auto caption = [&] {
switch (constructor_id) {
@ -4194,8 +4194,8 @@ unique_ptr<MessageContent> get_secret_message_content(
auto external_document = move_tl_object_as<secret_api::decryptedMessageMediaExternalDocument>(media);
auto document = secret_to_telegram_document(*external_document);
return get_document_message_content(td, std::move(document), owner_dialog_id,
FormattedText{std::move(message_text), std::move(entities)}, false, false,
&load_data_multipromise);
FormattedText{std::move(message_text), std::move(entities)}, false,
is_premium, &load_data_multipromise);
}
default:
break;

View File

@ -184,7 +184,7 @@ unique_ptr<MessageContent> get_secret_message_content(
Td *td, string message_text, unique_ptr<EncryptedFile> file,
tl_object_ptr<secret_api::DecryptedMessageMedia> &&media,
vector<tl_object_ptr<secret_api::MessageEntity>> &&secret_entities, DialogId owner_dialog_id,
MultiPromiseActor &load_data_multipromise);
MultiPromiseActor &load_data_multipromise, bool is_premium);
unique_ptr<MessageContent> get_message_content(Td *td, FormattedText message_text,
tl_object_ptr<telegram_api::MessageMedia> &&media,

View File

@ -13926,7 +13926,8 @@ void MessagesManager::on_get_secret_message(SecretChatId secret_chat_id, UserId
message_info.flags = flags;
message_info.content = get_secret_message_content(
td_, std::move(message->message_), std::move(file), std::move(message->media_), std::move(message->entities_),
message_info.dialog_id, pending_secret_message->load_data_multipromise);
message_info.dialog_id, pending_secret_message->load_data_multipromise,
td_->contacts_manager_->is_user_premium(user_id));
add_secret_message(std::move(pending_secret_message), std::move(lock_promise));
}

View File

@ -2691,7 +2691,7 @@ void StickersManager::create_sticker(FileId file_id, FileId premium_animation_fi
}
}
s->format = format;
on_get_sticker(std::move(s), sticker != nullptr);
on_get_sticker(std::move(s), sticker != nullptr && load_data_multipromise_ptr == nullptr);
}
bool StickersManager::has_input_media(FileId sticker_file_id, bool is_secret) const {