Register quick reply messages with forwarded stories.
This commit is contained in:
parent
81b6860f3c
commit
14b66aec1b
@ -5464,7 +5464,7 @@ void register_message_content(Td *td, const MessageContent *content, MessageFull
|
||||
static_cast<const MessageSuggestProfilePhoto *>(content)->photo);
|
||||
case MessageContentType::Story:
|
||||
return td->story_manager_->register_story(static_cast<const MessageStory *>(content)->story_full_id,
|
||||
message_full_id, source);
|
||||
message_full_id, {}, source);
|
||||
default:
|
||||
return;
|
||||
}
|
||||
@ -5588,7 +5588,7 @@ void unregister_message_content(Td *td, const MessageContent *content, MessageFu
|
||||
message_full_id, source);
|
||||
case MessageContentType::Story:
|
||||
return td->story_manager_->unregister_story(static_cast<const MessageStory *>(content)->story_full_id,
|
||||
message_full_id, source);
|
||||
message_full_id, {}, source);
|
||||
default:
|
||||
return;
|
||||
}
|
||||
@ -5629,6 +5629,9 @@ void register_quick_reply_message_content(Td *td, const MessageContent *content,
|
||||
auto dice = static_cast<const MessageDice *>(content);
|
||||
return td->stickers_manager_->register_dice(dice->emoji, dice->dice_value, {}, message_full_id, source);
|
||||
}
|
||||
case MessageContentType::Story:
|
||||
return td->story_manager_->register_story(static_cast<const MessageStory *>(content)->story_full_id, {},
|
||||
message_full_id, source);
|
||||
default:
|
||||
return;
|
||||
}
|
||||
@ -5651,6 +5654,9 @@ void unregister_quick_reply_message_content(Td *td, const MessageContent *conten
|
||||
auto dice = static_cast<const MessageDice *>(content);
|
||||
return td->stickers_manager_->unregister_dice(dice->emoji, dice->dice_value, {}, message_full_id, source);
|
||||
}
|
||||
case MessageContentType::Story:
|
||||
return td->story_manager_->unregister_story(static_cast<const MessageStory *>(content)->story_full_id, {},
|
||||
message_full_id, source);
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "td/telegram/NotificationId.h"
|
||||
#include "td/telegram/NotificationManager.h"
|
||||
#include "td/telegram/OptionManager.h"
|
||||
#include "td/telegram/QuickReplyManager.h"
|
||||
#include "td/telegram/ReactionManager.h"
|
||||
#include "td/telegram/ReactionType.hpp"
|
||||
#include "td/telegram/ReportReason.h"
|
||||
@ -1529,10 +1530,11 @@ StoryManager::StoryManager(Td *td, ActorShared<> parent) : td_(td), parent_(std:
|
||||
}
|
||||
|
||||
StoryManager::~StoryManager() {
|
||||
Scheduler::instance()->destroy_on_scheduler(
|
||||
G()->get_gc_scheduler_id(), story_full_id_to_file_source_id_, stories_, stories_by_global_id_,
|
||||
inaccessible_story_full_ids_, deleted_story_full_ids_, failed_to_load_story_full_ids_, story_messages_,
|
||||
active_stories_, updated_active_stories_, max_read_story_ids_, failed_to_load_active_stories_);
|
||||
Scheduler::instance()->destroy_on_scheduler(G()->get_gc_scheduler_id(), story_full_id_to_file_source_id_, stories_,
|
||||
stories_by_global_id_, inaccessible_story_full_ids_,
|
||||
deleted_story_full_ids_, failed_to_load_story_full_ids_, story_messages_,
|
||||
story_quick_reply_messages_, active_stories_, updated_active_stories_,
|
||||
max_read_story_ids_, failed_to_load_active_stories_);
|
||||
}
|
||||
|
||||
void StoryManager::start_up() {
|
||||
@ -3295,27 +3297,45 @@ int32 StoryManager::get_story_duration(StoryFullId story_full_id) const {
|
||||
return get_story_content_duration(td_, content);
|
||||
}
|
||||
|
||||
void StoryManager::register_story(StoryFullId story_full_id, MessageFullId message_full_id, const char *source) {
|
||||
void StoryManager::register_story(StoryFullId story_full_id, MessageFullId message_full_id,
|
||||
QuickReplyMessageFullId quick_reply_message_full_id, const char *source) {
|
||||
if (td_->auth_manager_->is_bot()) {
|
||||
return;
|
||||
}
|
||||
CHECK(story_full_id.is_server());
|
||||
|
||||
LOG(INFO) << "Register " << story_full_id << " from " << message_full_id << " from " << source;
|
||||
story_messages_[story_full_id].insert(message_full_id);
|
||||
LOG(INFO) << "Register " << story_full_id << " from " << message_full_id << '/' << quick_reply_message_full_id
|
||||
<< " from " << source;
|
||||
if (quick_reply_message_full_id.is_valid()) {
|
||||
story_quick_reply_messages_[story_full_id].insert(quick_reply_message_full_id);
|
||||
} else {
|
||||
CHECK(message_full_id.get_dialog_id().is_valid());
|
||||
story_messages_[story_full_id].insert(message_full_id);
|
||||
}
|
||||
}
|
||||
|
||||
void StoryManager::unregister_story(StoryFullId story_full_id, MessageFullId message_full_id, const char *source) {
|
||||
void StoryManager::unregister_story(StoryFullId story_full_id, MessageFullId message_full_id,
|
||||
QuickReplyMessageFullId quick_reply_message_full_id, const char *source) {
|
||||
if (td_->auth_manager_->is_bot()) {
|
||||
return;
|
||||
}
|
||||
CHECK(story_full_id.is_server());
|
||||
LOG(INFO) << "Unregister " << story_full_id << " from " << message_full_id << " from " << source;
|
||||
auto &message_ids = story_messages_[story_full_id];
|
||||
auto is_deleted = message_ids.erase(message_full_id) > 0;
|
||||
LOG_CHECK(is_deleted) << source << ' ' << story_full_id << ' ' << message_full_id;
|
||||
if (message_ids.empty()) {
|
||||
story_messages_.erase(story_full_id);
|
||||
LOG(INFO) << "Unregister " << story_full_id << " from " << message_full_id << '/' << quick_reply_message_full_id
|
||||
<< " from " << source;
|
||||
if (quick_reply_message_full_id.is_valid()) {
|
||||
auto &message_ids = story_quick_reply_messages_[story_full_id];
|
||||
auto is_deleted = message_ids.erase(quick_reply_message_full_id) > 0;
|
||||
LOG_CHECK(is_deleted) << source << ' ' << story_full_id << ' ' << quick_reply_message_full_id;
|
||||
if (message_ids.empty()) {
|
||||
story_quick_reply_messages_.erase(story_full_id);
|
||||
}
|
||||
} else {
|
||||
auto &message_ids = story_messages_[story_full_id];
|
||||
auto is_deleted = message_ids.erase(message_full_id) > 0;
|
||||
LOG_CHECK(is_deleted) << source << ' ' << story_full_id << ' ' << message_full_id;
|
||||
if (message_ids.empty()) {
|
||||
story_messages_.erase(story_full_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -3951,6 +3971,19 @@ void StoryManager::on_story_changed(StoryFullId story_full_id, const Story *stor
|
||||
message_full_id, "on_story_changed", true);
|
||||
}
|
||||
}
|
||||
|
||||
if (story_quick_reply_messages_.count(story_full_id) != 0) {
|
||||
vector<QuickReplyMessageFullId> message_full_ids;
|
||||
story_quick_reply_messages_[story_full_id].foreach(
|
||||
[&message_full_ids](const QuickReplyMessageFullId &message_full_id) {
|
||||
message_full_ids.push_back(message_full_id);
|
||||
});
|
||||
CHECK(!message_full_ids.empty());
|
||||
for (const auto &message_full_id : message_full_ids) {
|
||||
send_closure_later(G()->quick_reply_manager(), &QuickReplyManager::on_external_update_message_content,
|
||||
message_full_id, "on_story_changed", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "td/telegram/MediaArea.h"
|
||||
#include "td/telegram/MessageEntity.h"
|
||||
#include "td/telegram/MessageFullId.h"
|
||||
#include "td/telegram/QuickReplyMessageFullId.h"
|
||||
#include "td/telegram/ReactionType.h"
|
||||
#include "td/telegram/StoryDb.h"
|
||||
#include "td/telegram/StoryFullId.h"
|
||||
@ -342,9 +343,11 @@ class StoryManager final : public Actor {
|
||||
|
||||
int32 get_story_duration(StoryFullId story_full_id) const;
|
||||
|
||||
void register_story(StoryFullId story_full_id, MessageFullId message_full_id, const char *source);
|
||||
void register_story(StoryFullId story_full_id, MessageFullId message_full_id,
|
||||
QuickReplyMessageFullId quick_reply_message_full_id, const char *source);
|
||||
|
||||
void unregister_story(StoryFullId story_full_id, MessageFullId message_full_id, const char *source);
|
||||
void unregister_story(StoryFullId story_full_id, MessageFullId message_full_id,
|
||||
QuickReplyMessageFullId quick_reply_message_full_id, const char *source);
|
||||
|
||||
td_api::object_ptr<td_api::story> get_story_object(StoryFullId story_full_id) const;
|
||||
|
||||
@ -663,6 +666,9 @@ class StoryManager final : public Actor {
|
||||
|
||||
WaitFreeHashMap<StoryFullId, WaitFreeHashSet<MessageFullId, MessageFullIdHash>, StoryFullIdHash> story_messages_;
|
||||
|
||||
WaitFreeHashMap<StoryFullId, WaitFreeHashSet<QuickReplyMessageFullId, QuickReplyMessageFullIdHash>, StoryFullIdHash>
|
||||
story_quick_reply_messages_;
|
||||
|
||||
WaitFreeHashMap<DialogId, unique_ptr<ActiveStories>, DialogIdHash> active_stories_;
|
||||
|
||||
WaitFreeHashSet<DialogId, DialogIdHash> updated_active_stories_;
|
||||
|
Loading…
Reference in New Issue
Block a user