mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 20:44:40 +08:00
FIX: Allow expanding posts when anonymous, add specs
This commit is contained in:
@ -137,6 +137,16 @@ class TopicEmbed < ActiveRecord::Base
|
||||
# If there is no first paragaph, return the first div (onebox)
|
||||
doc.css('div').first
|
||||
end
|
||||
|
||||
def self.expanded_for(post)
|
||||
Rails.cache.fetch("embed-topic:#{post.topic_id}", expires_in: 10.minutes) do
|
||||
url = TopicEmbed.where(topic_id: post.topic_id).pluck(:embed_url).first
|
||||
title, body = TopicEmbed.find_remote(url)
|
||||
body << TopicEmbed.imported_from_html(url)
|
||||
body
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# == Schema Information
|
||||
|
Reference in New Issue
Block a user