Update message content when story from web page is changed.
This commit is contained in:
parent
62e7640701
commit
e4382ee206
@ -20,6 +20,7 @@
|
|||||||
#include "td/telegram/StoryContentType.h"
|
#include "td/telegram/StoryContentType.h"
|
||||||
#include "td/telegram/Td.h"
|
#include "td/telegram/Td.h"
|
||||||
#include "td/telegram/UpdatesManager.h"
|
#include "td/telegram/UpdatesManager.h"
|
||||||
|
#include "td/telegram/WebPagesManager.h"
|
||||||
|
|
||||||
#include "tddb/td/db/binlog/BinlogEvent.h"
|
#include "tddb/td/db/binlog/BinlogEvent.h"
|
||||||
#include "tddb/td/db/binlog/BinlogHelper.h"
|
#include "tddb/td/db/binlog/BinlogHelper.h"
|
||||||
@ -879,6 +880,7 @@ void StoryManager::on_story_changed(StoryFullId story_full_id, const Story *stor
|
|||||||
|
|
||||||
send_closure_later(G()->messages_manager(),
|
send_closure_later(G()->messages_manager(),
|
||||||
&MessagesManager::update_story_max_reply_media_timestamp_in_replied_messages, story_full_id);
|
&MessagesManager::update_story_max_reply_media_timestamp_in_replied_messages, story_full_id);
|
||||||
|
send_closure_later(G()->web_pages_manager(), &WebPagesManager::on_story_changed, story_full_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -395,6 +395,7 @@ class WebPagesManager::WebPage {
|
|||||||
}
|
}
|
||||||
if (has_story_full_ids) {
|
if (has_story_full_ids) {
|
||||||
parse(story_full_ids, parser);
|
parse(story_full_ids, parser);
|
||||||
|
td::remove_if(story_full_ids, [](StoryFullId story_full_id) { return !story_full_id.is_valid(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (has_instant_view) {
|
if (has_instant_view) {
|
||||||
@ -609,6 +610,21 @@ void WebPagesManager::update_web_page(unique_ptr<WebPage> web_page, WebPageId we
|
|||||||
is_changed = false;
|
is_changed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (page->story_full_ids != web_page->story_full_ids) {
|
||||||
|
for (auto story_full_id : page->story_full_ids) {
|
||||||
|
auto it = story_web_pages_.find(story_full_id);
|
||||||
|
if (it != story_web_pages_.end()) {
|
||||||
|
it->second.erase(web_page_id);
|
||||||
|
if (it->second.empty()) {
|
||||||
|
story_web_pages_.erase(it);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (auto story_full_id : web_page->story_full_ids) {
|
||||||
|
story_web_pages_[story_full_id].insert(web_page_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
old_instant_view = std::move(page->instant_view);
|
old_instant_view = std::move(page->instant_view);
|
||||||
web_page->log_event_id = page->log_event_id;
|
web_page->log_event_id = page->log_event_id;
|
||||||
} else {
|
} else {
|
||||||
@ -1380,6 +1396,20 @@ void WebPagesManager::on_web_page_changed(WebPageId web_page_id, bool have_web_p
|
|||||||
pending_web_pages_timeout_.cancel_timeout(web_page_id.get());
|
pending_web_pages_timeout_.cancel_timeout(web_page_id.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WebPagesManager::on_story_changed(StoryFullId story_full_id) {
|
||||||
|
auto story_it = story_web_pages_.find(story_full_id);
|
||||||
|
if (story_it == story_web_pages_.end()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
vector<WebPageId> web_page_ids;
|
||||||
|
for (auto web_page_id : story_it->second) {
|
||||||
|
web_page_ids.push_back(web_page_id);
|
||||||
|
}
|
||||||
|
for (auto web_page_id : web_page_ids) {
|
||||||
|
on_web_page_changed(web_page_id, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const WebPagesManager::WebPage *WebPagesManager::get_web_page(WebPageId web_page_id) const {
|
const WebPagesManager::WebPage *WebPagesManager::get_web_page(WebPageId web_page_id) const {
|
||||||
return web_pages_.get_pointer(web_page_id);
|
return web_pages_.get_pointer(web_page_id);
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include "td/telegram/files/FileSourceId.h"
|
#include "td/telegram/files/FileSourceId.h"
|
||||||
#include "td/telegram/FullMessageId.h"
|
#include "td/telegram/FullMessageId.h"
|
||||||
#include "td/telegram/SecretInputMedia.h"
|
#include "td/telegram/SecretInputMedia.h"
|
||||||
|
#include "td/telegram/StoryFullId.h"
|
||||||
#include "td/telegram/td_api.h"
|
#include "td/telegram/td_api.h"
|
||||||
#include "td/telegram/telegram_api.h"
|
#include "td/telegram/telegram_api.h"
|
||||||
#include "td/telegram/WebPageId.h"
|
#include "td/telegram/WebPageId.h"
|
||||||
@ -86,6 +87,8 @@ class WebPagesManager final : public Actor {
|
|||||||
|
|
||||||
int32 get_web_page_media_duration(WebPageId web_page_id) const;
|
int32 get_web_page_media_duration(WebPageId web_page_id) const;
|
||||||
|
|
||||||
|
void on_story_changed(StoryFullId story_full_id);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class WebPage;
|
class WebPage;
|
||||||
|
|
||||||
@ -180,6 +183,8 @@ class WebPagesManager final : public Actor {
|
|||||||
FlatHashMap<WebPageId, vector<std::pair<string, Promise<td_api::object_ptr<td_api::webPage>>>>, WebPageIdHash>
|
FlatHashMap<WebPageId, vector<std::pair<string, Promise<td_api::object_ptr<td_api::webPage>>>>, WebPageIdHash>
|
||||||
pending_get_web_pages_;
|
pending_get_web_pages_;
|
||||||
|
|
||||||
|
FlatHashMap<StoryFullId, FlatHashSet<WebPageId, WebPageIdHash>, StoryFullIdHash> story_web_pages_;
|
||||||
|
|
||||||
FlatHashMap<string, WebPageId> url_to_web_page_id_;
|
FlatHashMap<string, WebPageId> url_to_web_page_id_;
|
||||||
|
|
||||||
FlatHashMap<string, FileSourceId> url_to_file_source_id_;
|
FlatHashMap<string, FileSourceId> url_to_file_source_id_;
|
||||||
|
Loading…
Reference in New Issue
Block a user