feat: limit message link previews count (#15214)

This commit is contained in:
Igor Sirotin 2024-06-18 11:08:14 +01:00 committed by GitHub
parent 4170f589b3
commit 067f406572
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 0 deletions

View File

@ -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,