FIX: Make sure max_oneboxes_per_post is enforced (#16215)

PostAnalyzer and CookedPostProcessor both replace URLs with oneboxes.
PostAnalyzer did not use the max_oneboxes_per_post site and setting and
CookedPostProcessor replaced at most max_oneboxes_per_post URLs ignoring
the oneboxes that were replaced already by PostAnalyzer.
This commit is contained in:
Bianca Nenciu
2022-03-23 17:36:08 +02:00
committed by GitHub
parent 147ffadcf3
commit cbaf7c949b
4 changed files with 40 additions and 3 deletions

View File

@@ -31,7 +31,11 @@ class PostAnalyzer
cooked = PrettyText.cook(raw, opts)
end
limit = SiteSetting.max_oneboxes_per_post
result = Oneboxer.apply(cooked) do |url|
next if limit <= 0
limit -= 1
@onebox_urls << url
if opts[:invalidate_oneboxes]
Oneboxer.invalidate(url)