DEV: Allow passing cook_method to TopicEmbed.import to override default (#14209)

DEV: Allow passing cook_method to TopicEmbed.import to override default

This will be used in the rss-polling plugin when we want to have
oneboxes on feed content, like youtube for example.
This commit is contained in:
Rafael dos Santos Silva
2021-09-01 15:46:39 -03:00
committed by GitHub
parent c6f1818b85
commit ef0471d7ae
2 changed files with 15 additions and 4 deletions

View File

@@ -27,10 +27,10 @@ class TopicEmbed < ActiveRecord::Base
end
# Import an article from a source (RSS/Atom/Other)
def self.import(user, url, title, contents, category_id: nil)
def self.import(user, url, title, contents, category_id: nil, cook_method: nil)
return unless url =~ /^https?\:\/\//
if SiteSetting.embed_truncate
if SiteSetting.embed_truncate && cook_method.nil?
contents = first_paragraph_from(contents)
end
contents ||= ''
@@ -47,7 +47,7 @@ class TopicEmbed < ActiveRecord::Base
Topic.transaction do
eh = EmbeddableHost.record_for_url(url)
cook_method = if SiteSetting.embed_support_markdown
cook_method ||= if SiteSetting.embed_support_markdown
Post.cook_methods[:regular]
else
Post.cook_methods[:raw_html]