From 067f40657201936f6ae7be83977fdc1091a844d8 Mon Sep 17 00:00:00 2001 From: Igor Sirotin Date: Tue, 18 Jun 2024 11:08:14 +0100 Subject: [PATCH] feat: limit message link previews count (#15214) --- .../main/chat_section/chat_content/input_area/controller.nim | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/app/modules/main/chat_section/chat_content/input_area/controller.nim b/src/app/modules/main/chat_section/chat_content/input_area/controller.nim index fc6fca5675..99c72b3807 100644 --- a/src/app/modules/main/chat_section/chat_content/input_area/controller.nim +++ b/src/app/modules/main/chat_section/chat_content/input_area/controller.nim @@ -13,6 +13,8 @@ import ../../../../../core/eventemitter import ../../../../../core/unique_event_emitter import ./link_preview_cache +const MESSAGE_LINK_PREVIEWS_LIMIT = 5 + type Controller* = ref object of RootObj delegate: io_interface.AccessInterface @@ -195,6 +197,9 @@ proc handleUnfurlingPlan*(self: Controller, unfurlNewUrls: bool) = allAllowedUrls.add(metadata.url) continue + if allAllowedUrls.len == MESSAGE_LINK_PREVIEWS_LIMIT: + continue + # Split unfurling into 2 packs, which will be different RPCs. # In most cases we expect status links to ufurl immediately. # In future we could unfurl each link in a separate RPC,