Add stories.pinned_story_ids.

This commit is contained in:
levlam 2024-04-25 23:17:06 +03:00
parent 4cbf16a14e
commit 72368062ef
3 changed files with 23 additions and 14 deletions

View File

@ -3892,8 +3892,11 @@ storyInteractionInfo view_count:int32 forward_count:int32 reaction_count:int32 r
//@caption Caption of the story
story id:int32 sender_chat_id:int53 sender_id:MessageSender date:int32 is_being_sent:Bool is_being_edited:Bool is_edited:Bool is_posted_to_chat_page:Bool is_visible_only_for_self:Bool can_be_deleted:Bool can_be_edited:Bool can_be_forwarded:Bool can_be_replied:Bool can_toggle_is_posted_to_chat_page:Bool can_get_statistics:Bool can_get_interactions:Bool has_expired_viewers:Bool repost_info:storyRepostInfo interaction_info:storyInteractionInfo chosen_reaction_type:ReactionType privacy_settings:StoryPrivacySettings content:StoryContent areas:vector<storyArea> caption:formattedText = Story;
//@description Represents a list of stories @total_count Approximate total number of stories found @stories The list of stories
stories total_count:int32 stories:vector<story> = Stories;
//@description Represents a list of stories
//@total_count Approximate total number of stories found
//@stories The list of stories
//@pinned_story_ids Identifiers of the pinned stories; returned only in getChatPostedToChatPageStories with from_story_id == 0
stories total_count:int32 stories:vector<story> pinned_story_ids:vector<int32> = Stories;
//@description Contains identifier of a story along with identifier of its sender
//@sender_chat_id Identifier of the chat that posted the story

View File

@ -2373,11 +2373,13 @@ void StoryManager::on_get_dialog_pinned_stories(DialogId owner_dialog_id,
telegram_api::object_ptr<telegram_api::stories_stories> &&stories,
Promise<td_api::object_ptr<td_api::stories>> &&promise) {
TRY_STATUS_PROMISE(promise, G()->close_status());
auto pinned_story_ids = StoryId::get_story_ids(stories->pinned_to_top_);
auto result = on_get_stories(owner_dialog_id, {}, std::move(stories));
on_update_dialog_has_pinned_stories(owner_dialog_id, result.first > 0);
promise.set_value(get_stories_object(result.first, transform(result.second, [owner_dialog_id](StoryId story_id) {
return StoryFullId(owner_dialog_id, story_id);
})));
promise.set_value(get_stories_object(
result.first,
transform(result.second, [owner_dialog_id](StoryId story_id) { return StoryFullId(owner_dialog_id, story_id); }),
pinned_story_ids));
}
void StoryManager::get_story_archive(DialogId owner_dialog_id, StoryId from_story_id, int32 limit,
@ -2411,10 +2413,12 @@ void StoryManager::on_get_story_archive(DialogId owner_dialog_id,
telegram_api::object_ptr<telegram_api::stories_stories> &&stories,
Promise<td_api::object_ptr<td_api::stories>> &&promise) {
TRY_STATUS_PROMISE(promise, G()->close_status());
LOG_IF(ERROR, !stories->pinned_to_top_.empty()) << "Receive pinned stories in archive";
auto result = on_get_stories(owner_dialog_id, {}, std::move(stories));
promise.set_value(get_stories_object(result.first, transform(result.second, [owner_dialog_id](StoryId story_id) {
return StoryFullId(owner_dialog_id, story_id);
})));
promise.set_value(get_stories_object(
result.first,
transform(result.second, [owner_dialog_id](StoryId story_id) { return StoryFullId(owner_dialog_id, story_id); }),
{}));
}
void StoryManager::get_dialog_expiring_stories(DialogId owner_dialog_id,
@ -3297,13 +3301,15 @@ td_api::object_ptr<td_api::story> StoryManager::get_story_object(StoryFullId sto
}
td_api::object_ptr<td_api::stories> StoryManager::get_stories_object(int32 total_count,
const vector<StoryFullId> &story_full_ids) const {
const vector<StoryFullId> &story_full_ids,
const vector<StoryId> &pinned_story_ids) const {
if (total_count == -1) {
total_count = static_cast<int32>(story_full_ids.size());
}
return td_api::make_object<td_api::stories>(total_count, transform(story_full_ids, [this](StoryFullId story_full_id) {
return get_story_object(story_full_id);
}));
return td_api::make_object<td_api::stories>(
total_count,
transform(story_full_ids, [this](StoryFullId story_full_id) { return get_story_object(story_full_id); }),
StoryId::get_input_story_ids(pinned_story_ids));
}
td_api::object_ptr<td_api::chatActiveStories> StoryManager::get_chat_active_stories_object(

View File

@ -339,8 +339,8 @@ class StoryManager final : public Actor {
td_api::object_ptr<td_api::story> get_story_object(StoryFullId story_full_id) const;
td_api::object_ptr<td_api::stories> get_stories_object(int32 total_count,
const vector<StoryFullId> &story_full_ids) const;
td_api::object_ptr<td_api::stories> get_stories_object(int32 total_count, const vector<StoryFullId> &story_full_ids,
const vector<StoryId> &pinned_story_ids) const;
FileSourceId get_story_file_source_id(StoryFullId story_full_id);