Add getStoryInteractions.prefer_forwards.

This commit is contained in:
levlam 2023-12-26 13:47:24 +03:00
parent b196d38a68
commit 8655fbe5d7
5 changed files with 21 additions and 15 deletions

View File

@ -3607,14 +3607,14 @@ storyInteractionTypeRepost story:story = StoryInteractionType;
//@description Represents interaction with a story
//@actor_id Identifier of the user or chat that made the interaction
//@interaction_date Approximate point in time (Unix timestamp) when the interaction happenned
//@block_list Block list to which the actor is added; may be null if none
//@block_list Block list to which the actor is added; may be null if none or for chat stories
//@type Type of the interaction
storyInteraction actor_id:MessageSender interaction_date:int32 block_list:BlockList type:StoryInteractionType = StoryInteraction;
//@description Represents a list of interactions with a story
//@total_count Approximate total number of interactions found
//@total_forward_count Approximate total number of found forwards and reposts
//@total_reaction_count Approximate total number of found reactions
//@total_forward_count Approximate total number of found forwards and reposts; always 0 for chat stories
//@total_reaction_count Approximate total number of found reactions; always 0 for chat stories
//@interactions List of story interactions
//@next_offset The offset for the next request. If empty, then there are no more results
storyInteractions total_count:int32 total_forward_count:int32 total_reaction_count:int32 interactions:vector<storyInteraction> next_offset:string = StoryInteractions;
@ -8217,10 +8217,11 @@ setStoryReaction story_sender_chat_id:int53 story_id:int32 reaction_type:Reactio
//@story_id Story identifier
//@query Query to search for in names, usernames and titles; may be empty to get all relevant interactions
//@only_contacts Pass true to get only interactions by contacts; pass false to get all relevant interactions
//@prefer_with_reaction Pass true to get interactions with reaction first; pass false to get interactions sorted just by interaction date
//@prefer_forwards Pass true to get forwards and reposts first, then reactions, then other views; pass false to get interactions sorted just by interaction date
//@prefer_with_reaction Pass true to get interactions with reaction first; pass false to get interactions sorted just by interaction date. Ignored if prefer_forwards == true
//@offset Offset of the first entry to return as received from the previous request; use empty string to get the first chunk of results
//@limit The maximum number of story interactions to return
getStoryInteractions story_id:int32 query:string only_contacts:Bool prefer_with_reaction:Bool offset:string limit:int32 = StoryInteractions;
getStoryInteractions story_id:int32 query:string only_contacts:Bool prefer_forwards:Bool prefer_with_reaction:Bool offset:string limit:int32 = StoryInteractions;
//@description Reports a story to the Telegram moderators
//@story_sender_chat_id The identifier of the sender of the story to report

View File

@ -348,8 +348,8 @@ class GetStoryViewsListQuery final : public Td::ResultHandler {
: promise_(std::move(promise)) {
}
void send(DialogId dialog_id, StoryId story_id, const string &query, bool only_contacts, bool prefer_with_reaction,
const string &offset, int32 limit) {
void send(DialogId dialog_id, StoryId story_id, const string &query, bool only_contacts, bool prefer_forwards,
bool prefer_with_reaction, const string &offset, int32 limit) {
dialog_id_ = dialog_id;
auto input_peer = td_->messages_manager_->get_input_peer(dialog_id_, AccessRights::Write);
if (input_peer == nullptr) {
@ -363,6 +363,9 @@ class GetStoryViewsListQuery final : public Td::ResultHandler {
if (only_contacts) {
flags |= telegram_api::stories_getStoryViewsList::JUST_CONTACTS_MASK;
}
if (prefer_forwards) {
flags |= telegram_api::stories_getStoryViewsList::FORWARDS_FIRST_MASK;
}
if (prefer_with_reaction) {
flags |= telegram_api::stories_getStoryViewsList::REACTIONS_FIRST_MASK;
}
@ -2820,7 +2823,8 @@ void StoryManager::get_channel_differences_if_needed(
}
void StoryManager::get_story_interactions(StoryId story_id, const string &query, bool only_contacts,
bool prefer_with_reaction, const string &offset, int32 limit,
bool prefer_forwards, bool prefer_with_reaction, const string &offset,
int32 limit,
Promise<td_api::object_ptr<td_api::storyInteractions>> &&promise) {
DialogId owner_dialog_id(td_->contacts_manager_->get_my_id());
StoryFullId story_full_id{owner_dialog_id, story_id};
@ -2842,7 +2846,7 @@ void StoryManager::get_story_interactions(StoryId story_id, const string &query,
});
td_->create_handler<GetStoryViewsListQuery>(std::move(query_promise))
->send(owner_dialog_id, story_id, query, only_contacts, prefer_with_reaction, offset, limit);
->send(owner_dialog_id, story_id, query, only_contacts, prefer_forwards, prefer_with_reaction, offset, limit);
}
void StoryManager::on_get_story_interactions(

View File

@ -263,8 +263,8 @@ class StoryManager final : public Actor {
void set_story_reaction(StoryFullId story_full_id, ReactionType reaction_type, bool add_to_recent,
Promise<Unit> &&promise);
void get_story_interactions(StoryId story_id, const string &query, bool only_contacts, bool prefer_with_reaction,
const string &offset, int32 limit,
void get_story_interactions(StoryId story_id, const string &query, bool only_contacts, bool prefer_forwards,
bool prefer_with_reaction, const string &offset, int32 limit,
Promise<td_api::object_ptr<td_api::storyInteractions>> &&promise);
void get_channel_differences_if_needed(

View File

@ -6686,8 +6686,8 @@ void Td::on_request(uint64 id, td_api::getStoryInteractions &request) {
CLEAN_INPUT_STRING(request.offset_);
CREATE_REQUEST_PROMISE();
story_manager_->get_story_interactions(StoryId(request.story_id_), request.query_, request.only_contacts_,
request.prefer_with_reaction_, request.offset_, request.limit_,
std::move(promise));
request.prefer_forwards_, request.prefer_with_reaction_, request.offset_,
request.limit_, std::move(promise));
}
void Td::on_request(uint64 id, td_api::reportStory &request) {

View File

@ -4424,9 +4424,10 @@ class CliClient final : public Actor {
string offset;
string query;
bool only_contacts;
bool prefer_forwards;
bool prefer_with_reaction;
get_args(args, story_id, limit, offset, query, only_contacts, prefer_with_reaction);
send_request(td_api::make_object<td_api::getStoryInteractions>(story_id, query, only_contacts,
get_args(args, story_id, limit, offset, query, only_contacts, prefer_forwards, prefer_with_reaction);
send_request(td_api::make_object<td_api::getStoryInteractions>(story_id, query, only_contacts, prefer_forwards,
prefer_with_reaction, offset, as_limit(limit)));
} else if (op == "rst") {
ChatId story_sender_chat_id;