Reload viewers of replied stories.
This commit is contained in:
parent
312006a207
commit
af9351bdfe
@ -34987,6 +34987,16 @@ MessagesManager::Message *MessagesManager::add_message_to_dialog(Dialog *d, uniq
|
||||
on_dialog_updated(dialog_id, "update_has_contact_registered_message");
|
||||
}
|
||||
|
||||
if (m->sender_user_id.is_valid()) {
|
||||
auto story_full_id = get_message_content_story_full_id(td_, m->content.get());
|
||||
if (story_full_id.is_valid()) {
|
||||
td_->story_manager_->on_story_replied(story_full_id, m->sender_user_id);
|
||||
}
|
||||
if (m->reply_to_story_full_id.is_valid()) {
|
||||
td_->story_manager_->on_story_replied(m->reply_to_story_full_id, m->sender_user_id);
|
||||
}
|
||||
}
|
||||
|
||||
reget_message_from_server_if_needed(dialog_id, m);
|
||||
|
||||
add_message_file_sources(dialog_id, m);
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "td/telegram/ContactsManager.h"
|
||||
#include "td/telegram/Td.h"
|
||||
|
||||
#include "td/utils/algorithm.h"
|
||||
#include "td/utils/logging.h"
|
||||
|
||||
namespace td {
|
||||
@ -43,6 +44,10 @@ void StoryInteractionInfo::set_recent_viewer_user_ids(vector<UserId> &&user_ids)
|
||||
recent_viewer_user_ids_ = std::move(user_ids);
|
||||
}
|
||||
|
||||
bool StoryInteractionInfo::definitely_has_no_user(UserId user_id) const {
|
||||
return !is_empty() && view_count_ <= MAX_RECENT_VIEWERS && !contains(recent_viewer_user_ids_, user_id);
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::storyInteractionInfo> StoryInteractionInfo::get_story_interaction_info_object(Td *td) const {
|
||||
if (is_empty()) {
|
||||
return nullptr;
|
||||
|
@ -48,6 +48,8 @@ class StoryInteractionInfo {
|
||||
return view_count_;
|
||||
}
|
||||
|
||||
bool definitely_has_no_user(UserId user_id) const;
|
||||
|
||||
void set_recent_viewer_user_ids(vector<UserId> &&user_ids);
|
||||
|
||||
td_api::object_ptr<td_api::storyInteractionInfo> get_story_interaction_info_object(Td *td) const;
|
||||
|
@ -1322,6 +1322,21 @@ void StoryManager::view_story_message(StoryFullId story_full_id) {
|
||||
}
|
||||
}
|
||||
|
||||
void StoryManager::on_story_replied(StoryFullId story_full_id, UserId replier_user_id) {
|
||||
if (!replier_user_id.is_valid() || replier_user_id == td_->contacts_manager_->get_my_id()) {
|
||||
return;
|
||||
}
|
||||
const Story *story = get_story(story_full_id);
|
||||
if (story == nullptr || !story_full_id.get_story_id().is_server() || !is_story_owned(story_full_id.get_dialog_id())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (story->content_ != nullptr && is_active_story(story) &&
|
||||
story->interaction_info_.definitely_has_no_user(replier_user_id)) {
|
||||
reload_story(story_full_id, Promise<Unit>());
|
||||
}
|
||||
}
|
||||
|
||||
void StoryManager::schedule_interaction_info_update() {
|
||||
if (interaction_info_update_timeout_.has_timeout()) {
|
||||
return;
|
||||
|
@ -155,6 +155,8 @@ class StoryManager final : public Actor {
|
||||
|
||||
void view_story_message(StoryFullId story_full_id);
|
||||
|
||||
void on_story_replied(StoryFullId story_full_id, UserId replier_user_id);
|
||||
|
||||
void get_story_viewers(StoryId story_id, const td_api::messageViewer *offset, int32 limit,
|
||||
Promise<td_api::object_ptr<td_api::messageViewers>> &&promise);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user