mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
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:
committed by
GitHub
parent
c6f1818b85
commit
ef0471d7ae
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user