Support sponsored messages with chat photo.

This commit is contained in:
levlam 2022-10-21 14:26:35 +03:00
parent 0d05683771
commit e6d539097e
2 changed files with 11 additions and 8 deletions

View File

@ -955,9 +955,10 @@ messageCalendar total_count:int32 days:vector<messageCalendarDay> = MessageCalen
//@is_recommended True, if the message needs to be labeled as "recommended" instead of "sponsored"
//@sponsor_chat_id Sponsor chat identifier; 0 if the sponsor chat is accessible through an invite link
//@sponsor_chat_info Information about the sponsor chat; may be null unless sponsor_chat_id == 0
//@show_chat_photo True, if the sponsor's chat photo must be shown
//@link An internal link to be opened when the sponsored message is clicked; may be null if the sponsor chat needs to be opened instead
//@content Content of the message. Currently, can be only of the type messageText
sponsoredMessage message_id:int53 is_recommended:Bool sponsor_chat_id:int53 sponsor_chat_info:chatInviteLinkInfo link:InternalLinkType content:MessageContent = SponsoredMessage;
sponsoredMessage message_id:int53 is_recommended:Bool sponsor_chat_id:int53 sponsor_chat_info:chatInviteLinkInfo show_chat_photo:Bool link:InternalLinkType content:MessageContent = SponsoredMessage;
//@description Describes a file added to file download list

View File

@ -92,17 +92,19 @@ class ViewSponsoredMessageQuery final : public Td::ResultHandler {
struct SponsoredMessageManager::SponsoredMessage {
int64 local_id = 0;
bool is_recommended = false;
bool show_dialog_photo = false;
DialogId sponsor_dialog_id;
ServerMessageId server_message_id;
string start_param;
string invite_hash;
unique_ptr<MessageContent> content;
SponsoredMessage() = default;
SponsoredMessage(int64 local_id, bool is_recommended, DialogId sponsor_dialog_id, ServerMessageId server_message_id,
string start_param, string invite_hash, unique_ptr<MessageContent> content)
SponsoredMessage(int64 local_id, bool is_recommended, bool show_dialog_photo, DialogId sponsor_dialog_id,
ServerMessageId server_message_id, string start_param, string invite_hash,
unique_ptr<MessageContent> content)
: local_id(local_id)
, is_recommended(is_recommended)
, show_dialog_photo(show_dialog_photo)
, sponsor_dialog_id(sponsor_dialog_id)
, server_message_id(server_message_id)
, start_param(std::move(start_param))
@ -191,7 +193,7 @@ td_api::object_ptr<td_api::sponsoredMessage> SponsoredMessageManager::get_sponso
}
return td_api::make_object<td_api::sponsoredMessage>(
sponsored_message.local_id, sponsored_message.is_recommended, sponsored_message.sponsor_dialog_id.get(),
std::move(chat_invite_link_info), std::move(link),
std::move(chat_invite_link_info), sponsored_message.show_dialog_photo, std::move(link),
get_message_content_object(sponsored_message.content.get(), td_, dialog_id, 0, false, true, -1));
}
@ -323,9 +325,9 @@ void SponsoredMessageManager::on_get_dialog_sponsored_messages(
auto is_inserted =
messages->message_random_ids.emplace(local_id, sponsored_message->random_id_.as_slice().str()).second;
CHECK(is_inserted);
messages->messages.emplace_back(local_id, sponsored_message->recommended_, sponsor_dialog_id, server_message_id,
std::move(sponsored_message->start_param_), std::move(invite_hash),
std::move(content));
messages->messages.emplace_back(
local_id, sponsored_message->recommended_, sponsored_message->show_peer_photo_, sponsor_dialog_id,
server_message_id, std::move(sponsored_message->start_param_), std::move(invite_hash), std::move(content));
break;
}
}