Support filters in getStoryViewers.
This commit is contained in:
parent
d72e9cc68f
commit
fdd44e8f9d
@ -7478,11 +7478,14 @@ closeStory story_sender_chat_id:int53 story_id:int32 = Ok;
|
||||
//@update_recent_reactions Pass true if the reaction needs to be added to recent reactions
|
||||
setStoryReaction story_sender_chat_id:int53 story_id:int32 reaction_type:ReactionType update_recent_reactions:Bool = Ok;
|
||||
|
||||
//@description Returns viewers of a story. The method can be called if story.can_get_viewers == true. The views are returned in a reverse chronological order (i.e., in order of decreasing view_date)
|
||||
//@description Returns viewers of a story. The method can be called if story.can_get_viewers == true
|
||||
//@story_id Story identifier
|
||||
//@query Query to search for in names and usernames of the viewers; may be empty to get all relevant viewers
|
||||
//@only_contacts Pass true to get only contacts; pass false to get all relevant viewers
|
||||
//@prefer_with_reaction Pass true to get viewers with reaction first; pass false to get viewers sorted just by view_date
|
||||
//@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 viewers to return
|
||||
getStoryViewers story_id:int32 offset:string limit:int32 = StoryViewers;
|
||||
getStoryViewers story_id:int32 query:string only_contacts:Bool prefer_with_reaction:Bool offset:string limit:int32 = StoryViewers;
|
||||
|
||||
//@description Reports a story to the Telegram moderators
|
||||
//@story_sender_chat_id The identifier of the sender of the story to report
|
||||
|
@ -303,10 +303,20 @@ class GetStoryViewsListQuery final : public Td::ResultHandler {
|
||||
: promise_(std::move(promise)) {
|
||||
}
|
||||
|
||||
void send(StoryId story_id, const string &offset, int32 limit) {
|
||||
void send(StoryId story_id, const string &query, bool only_contacts, bool prefer_with_reaction, const string &offset,
|
||||
int32 limit) {
|
||||
int32 flags = 0;
|
||||
if (!query.empty()) {
|
||||
flags |= telegram_api::stories_getStoryViewsList::Q_MASK;
|
||||
}
|
||||
if (only_contacts) {
|
||||
flags |= telegram_api::stories_getStoryViewsList::JUST_CONTACTS_MASK;
|
||||
}
|
||||
if (prefer_with_reaction) {
|
||||
flags |= telegram_api::stories_getStoryViewsList::REACTIONS_FIRST_MASK;
|
||||
}
|
||||
send_query(G()->net_query_creator().create(telegram_api::stories_getStoryViewsList(
|
||||
flags, false /*ignored*/, false /*ignored*/, string(), story_id.get(), offset, limit)));
|
||||
flags, false /*ignored*/, false /*ignored*/, query, story_id.get(), offset, limit)));
|
||||
}
|
||||
|
||||
void on_result(BufferSlice packet) final {
|
||||
@ -2320,7 +2330,8 @@ Status StoryManager::can_get_story_viewers(StoryFullId story_full_id, const Stor
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
void StoryManager::get_story_viewers(StoryId story_id, const string &offset, int32 limit,
|
||||
void StoryManager::get_story_viewers(StoryId story_id, const string &query, bool only_contacts,
|
||||
bool prefer_with_reaction, const string &offset, int32 limit,
|
||||
Promise<td_api::object_ptr<td_api::storyViewers>> &&promise) {
|
||||
DialogId owner_dialog_id(td_->contacts_manager_->get_my_id());
|
||||
StoryFullId story_full_id{owner_dialog_id, story_id};
|
||||
@ -2335,7 +2346,7 @@ void StoryManager::get_story_viewers(StoryId story_id, const string &offset, int
|
||||
return promise.set_value(td_api::make_object<td_api::storyViewers>());
|
||||
}
|
||||
|
||||
bool is_first = offset.empty();
|
||||
bool is_first = offset.empty() && query.empty() && !only_contacts;
|
||||
auto query_promise = PromiseCreator::lambda(
|
||||
[actor_id = actor_id(this), story_id, is_first, promise = std::move(promise)](
|
||||
Result<telegram_api::object_ptr<telegram_api::stories_storyViewsList>> result) mutable {
|
||||
@ -2344,7 +2355,7 @@ void StoryManager::get_story_viewers(StoryId story_id, const string &offset, int
|
||||
});
|
||||
|
||||
td_->create_handler<GetStoryViewsListQuery>(std::move(query_promise))
|
||||
->send(story_full_id.get_story_id(), offset, limit);
|
||||
->send(story_full_id.get_story_id(), query, only_contacts, prefer_with_reaction, offset, limit);
|
||||
}
|
||||
|
||||
void StoryManager::on_get_story_viewers(
|
||||
|
@ -244,7 +244,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_viewers(StoryId story_id, const string &offset, int32 limit,
|
||||
void get_story_viewers(StoryId story_id, const string &query, bool only_contacts, bool prefer_with_reaction,
|
||||
const string &offset, int32 limit,
|
||||
Promise<td_api::object_ptr<td_api::storyViewers>> &&promise);
|
||||
|
||||
void report_story(StoryFullId story_full_id, ReportReason &&reason, Promise<Unit> &&promise);
|
||||
|
@ -6494,9 +6494,11 @@ void Td::on_request(uint64 id, const td_api::setStoryReaction &request) {
|
||||
|
||||
void Td::on_request(uint64 id, td_api::getStoryViewers &request) {
|
||||
CHECK_IS_USER();
|
||||
CLEAN_INPUT_STRING(request.query_);
|
||||
CLEAN_INPUT_STRING(request.offset_);
|
||||
CREATE_REQUEST_PROMISE();
|
||||
story_manager_->get_story_viewers(StoryId(request.story_id_), request.offset_, request.limit_, std::move(promise));
|
||||
story_manager_->get_story_viewers(StoryId(request.story_id_), request.query_, request.only_contacts_,
|
||||
request.prefer_with_reaction_, request.offset_, request.limit_, std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::reportStory &request) {
|
||||
|
@ -4152,8 +4152,12 @@ class CliClient final : public Actor {
|
||||
StoryId story_id;
|
||||
string limit;
|
||||
string offset;
|
||||
get_args(args, story_id, limit, offset);
|
||||
send_request(td_api::make_object<td_api::getStoryViewers>(story_id, offset, as_limit(limit)));
|
||||
string query;
|
||||
bool only_contacts;
|
||||
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::getStoryViewers>(story_id, query, only_contacts, prefer_with_reaction,
|
||||
offset, as_limit(limit)));
|
||||
} else if (op == "rst") {
|
||||
ChatId story_sender_chat_id;
|
||||
StoryId story_id;
|
||||
|
Loading…
Reference in New Issue
Block a user