Add Story.can_get_viewers.
This commit is contained in:
parent
2bf612c020
commit
ca8b80d198
@ -4918,11 +4918,12 @@ storyInteractionInfo view_count:int32 recent_viewer_user_ids:vector<int53> = Sto
|
|||||||
//@sender_user_id Identifier of the user that created the story
|
//@sender_user_id Identifier of the user that created the story
|
||||||
//@date Point in time (Unix timestamp) when the story was published
|
//@date Point in time (Unix timestamp) when the story was published
|
||||||
//@is_pinned True, if the story is saved in the sender's profile and will be available there after expiration
|
//@is_pinned True, if the story is saved in the sender's profile and will be available there after expiration
|
||||||
|
//@can_get_viewers True, users viewed the story can be received through getStoryViewers
|
||||||
//@interaction_info Information about interactions with the story; may be null if the story isn't owned or there were no interactions
|
//@interaction_info Information about interactions with the story; may be null if the story isn't owned or there were no interactions
|
||||||
//@privacy_rules Pryvacy rules affecting story visibility; may be null if the story isn't owned
|
//@privacy_rules Pryvacy rules affecting story visibility; may be null if the story isn't owned
|
||||||
//@content Content of the story
|
//@content Content of the story
|
||||||
//@caption Caption of the story
|
//@caption Caption of the story
|
||||||
story id:int32 sender_user_id:int53 date:int32 is_pinned:Bool interaction_info:storyInteractionInfo privacy_rules:userPrivacySettingRules content:StoryContent caption:formattedText = Story;
|
story id:int32 sender_user_id:int53 date:int32 is_pinned:Bool can_get_viewers:Bool interaction_info:storyInteractionInfo privacy_rules:userPrivacySettingRules content:StoryContent caption:formattedText = Story;
|
||||||
|
|
||||||
//@description Represents a list of stories @total_count Approximate total number of stories found @stories The list of stories
|
//@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;
|
stories total_count:int32 stories:vector<story> = Stories;
|
||||||
|
@ -1560,6 +1560,7 @@ void ConfigManager::process_app_config(tl_object_ptr<telegram_api::JSONValue> &c
|
|||||||
bool premium_gift_text_field_icon = false;
|
bool premium_gift_text_field_icon = false;
|
||||||
int32 dialog_filter_update_period = 300;
|
int32 dialog_filter_update_period = 300;
|
||||||
bool archive_all_stories = false;
|
bool archive_all_stories = false;
|
||||||
|
int32 story_viewers_expire_period = 86400;
|
||||||
if (config->get_id() == telegram_api::jsonObject::ID) {
|
if (config->get_id() == telegram_api::jsonObject::ID) {
|
||||||
for (auto &key_value : static_cast<telegram_api::jsonObject *>(config.get())->value_) {
|
for (auto &key_value : static_cast<telegram_api::jsonObject *>(config.get())->value_) {
|
||||||
Slice key = key_value->key_;
|
Slice key = key_value->key_;
|
||||||
@ -1960,6 +1961,10 @@ void ConfigManager::process_app_config(tl_object_ptr<telegram_api::JSONValue> &c
|
|||||||
archive_all_stories = get_json_value_bool(std::move(key_value->value_), key);
|
archive_all_stories = get_json_value_bool(std::move(key_value->value_), key);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (key == "story_viewers_expire_period") {
|
||||||
|
story_viewers_expire_period = get_json_value_int(std::move(key_value->value_), key);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
new_values.push_back(std::move(key_value));
|
new_values.push_back(std::move(key_value));
|
||||||
}
|
}
|
||||||
@ -2126,6 +2131,10 @@ void ConfigManager::process_app_config(tl_object_ptr<telegram_api::JSONValue> &c
|
|||||||
options.set_option_empty("gift_premium_from_input_field");
|
options.set_option_empty("gift_premium_from_input_field");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (story_viewers_expire_period >= 0) {
|
||||||
|
options.set_option_integer("story_viewers_expire_period", story_viewers_expire_period);
|
||||||
|
}
|
||||||
|
|
||||||
if (!options.get_option_boolean("need_synchronize_archive_all_stories")) {
|
if (!options.get_option_boolean("need_synchronize_archive_all_stories")) {
|
||||||
options.set_option_boolean("archive_all_stories", archive_all_stories);
|
options.set_option_boolean("archive_all_stories", archive_all_stories);
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,7 @@ class ConfigManager final : public NetQueryCallback {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
struct AppConfig {
|
struct AppConfig {
|
||||||
static constexpr int32 CURRENT_VERSION = 4;
|
static constexpr int32 CURRENT_VERSION = 5;
|
||||||
int32 version_ = 0;
|
int32 version_ = 0;
|
||||||
int32 hash_ = 0;
|
int32 hash_ = 0;
|
||||||
telegram_api::object_ptr<telegram_api::JSONValue> config_;
|
telegram_api::object_ptr<telegram_api::JSONValue> config_;
|
||||||
|
@ -292,7 +292,8 @@ bool OptionManager::is_internal_option(Slice name) {
|
|||||||
return name == "saved_animations_limit" || name == "saved_gifs_limit_default" ||
|
return name == "saved_animations_limit" || name == "saved_gifs_limit_default" ||
|
||||||
name == "saved_gifs_limit_premium" || name == "session_count" || name == "since_last_open" ||
|
name == "saved_gifs_limit_premium" || name == "session_count" || name == "since_last_open" ||
|
||||||
name == "stickers_faved_limit_default" || name == "stickers_faved_limit_premium" ||
|
name == "stickers_faved_limit_default" || name == "stickers_faved_limit_premium" ||
|
||||||
name == "stickers_normal_by_emoji_per_premium_num" || name == "stickers_premium_by_emoji_num";
|
name == "stickers_normal_by_emoji_per_premium_num" || name == "stickers_premium_by_emoji_num" ||
|
||||||
|
name == "story_viewers_expire_period";
|
||||||
case 'v':
|
case 'v':
|
||||||
return name == "video_note_size_max";
|
return name == "video_note_size_max";
|
||||||
case 'w':
|
case 'w':
|
||||||
|
@ -990,6 +990,21 @@ void StoryManager::read_stories_on_server(DialogId owner_dialog_id, StoryId stor
|
|||||||
td_->create_handler<ReadStoriesQuery>(get_erase_log_event_promise(log_event_id))->send(owner_dialog_id, story_id);
|
td_->create_handler<ReadStoriesQuery>(get_erase_log_event_promise(log_event_id))->send(owner_dialog_id, story_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Status StoryManager::can_get_story_viewers(StoryFullId story_full_id, const Story *story) const {
|
||||||
|
CHECK(story != nullptr);
|
||||||
|
if (!is_story_owned(story_full_id.get_dialog_id())) {
|
||||||
|
return Status::Error(400, "Story is not outgoing");
|
||||||
|
}
|
||||||
|
if (!story_full_id.get_story_id().is_server()) {
|
||||||
|
return Status::Error(400, "Story is not sent yet");
|
||||||
|
}
|
||||||
|
if (G()->unix_time() >=
|
||||||
|
story->expire_date_ + td_->option_manager_->get_option_integer("story_viewers_expire_period", 86400)) {
|
||||||
|
return Status::Error(400, "Story is too old");
|
||||||
|
}
|
||||||
|
return Status::OK();
|
||||||
|
}
|
||||||
|
|
||||||
void StoryManager::get_story_viewers(StoryId story_id, const td_api::messageViewer *offset, int32 limit,
|
void StoryManager::get_story_viewers(StoryId story_id, const td_api::messageViewer *offset, int32 limit,
|
||||||
Promise<td_api::object_ptr<td_api::messageViewers>> &&promise) {
|
Promise<td_api::object_ptr<td_api::messageViewers>> &&promise) {
|
||||||
DialogId owner_dialog_id(td_->contacts_manager_->get_my_id());
|
DialogId owner_dialog_id(td_->contacts_manager_->get_my_id());
|
||||||
@ -998,14 +1013,13 @@ void StoryManager::get_story_viewers(StoryId story_id, const td_api::messageView
|
|||||||
if (story == nullptr) {
|
if (story == nullptr) {
|
||||||
return promise.set_error(Status::Error(400, "Story not found"));
|
return promise.set_error(Status::Error(400, "Story not found"));
|
||||||
}
|
}
|
||||||
if (!story_id.is_server()) {
|
|
||||||
return promise.set_value(td_api::object_ptr<td_api::messageViewers>());
|
|
||||||
}
|
|
||||||
// TRY_STATUS_PROMISE(promise, can_get_story_viewers(story_full_id));
|
|
||||||
|
|
||||||
if (limit <= 0) {
|
if (limit <= 0) {
|
||||||
return promise.set_error(Status::Error(400, "Parameter limit must be positive"));
|
return promise.set_error(Status::Error(400, "Parameter limit must be positive"));
|
||||||
}
|
}
|
||||||
|
if (can_get_story_viewers(story_full_id, story).is_error()) {
|
||||||
|
return promise.set_value(td_api::object_ptr<td_api::messageViewers>());
|
||||||
|
}
|
||||||
|
|
||||||
int32 offset_date = 0;
|
int32 offset_date = 0;
|
||||||
int64 offset_user_id = 0;
|
int64 offset_user_id = 0;
|
||||||
if (offset != nullptr) {
|
if (offset != nullptr) {
|
||||||
@ -1159,7 +1173,8 @@ td_api::object_ptr<td_api::story> StoryManager::get_story_object(StoryFullId sto
|
|||||||
return td_api::make_object<td_api::story>(
|
return td_api::make_object<td_api::story>(
|
||||||
story_full_id.get_story_id().get(),
|
story_full_id.get_story_id().get(),
|
||||||
td_->contacts_manager_->get_user_id_object(dialog_id.get_user_id(), "get_story_object"), story->date_,
|
td_->contacts_manager_->get_user_id_object(dialog_id.get_user_id(), "get_story_object"), story->date_,
|
||||||
story->is_pinned_, story->interaction_info_.get_story_interaction_info_object(td_), std::move(privacy_rules),
|
story->is_pinned_, can_get_story_viewers(story_full_id, story).is_ok(),
|
||||||
|
story->interaction_info_.get_story_interaction_info_object(td_), std::move(privacy_rules),
|
||||||
get_story_content_object(td_, content),
|
get_story_content_object(td_, content),
|
||||||
get_formatted_text_object(story->caption_, true, get_story_content_duration(td_, content)));
|
get_formatted_text_object(story->caption_, true, get_story_content_duration(td_, content)));
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include "td/utils/common.h"
|
#include "td/utils/common.h"
|
||||||
#include "td/utils/Promise.h"
|
#include "td/utils/Promise.h"
|
||||||
|
#include "td/utils/Status.h"
|
||||||
#include "td/utils/WaitFreeHashMap.h"
|
#include "td/utils/WaitFreeHashMap.h"
|
||||||
#include "td/utils/WaitFreeHashSet.h"
|
#include "td/utils/WaitFreeHashSet.h"
|
||||||
|
|
||||||
@ -133,6 +134,8 @@ class StoryManager final : public Actor {
|
|||||||
|
|
||||||
bool on_update_read_stories(DialogId owner_dialog_id, StoryId max_read_story_id);
|
bool on_update_read_stories(DialogId owner_dialog_id, StoryId max_read_story_id);
|
||||||
|
|
||||||
|
Status can_get_story_viewers(StoryFullId story_full_id, const Story *story) const;
|
||||||
|
|
||||||
void on_get_story_views(const vector<StoryId> &story_ids,
|
void on_get_story_views(const vector<StoryId> &story_ids,
|
||||||
telegram_api::object_ptr<telegram_api::stories_storyViews> &&story_views);
|
telegram_api::object_ptr<telegram_api::stories_storyViews> &&story_views);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user