FEATURE: Allow posting a link with topics

This commit is contained in:
Erick Guan
2016-12-05 17:20:54 +01:00
parent e82084405e
commit 52763f5115
50 changed files with 503 additions and 77 deletions
+17
View File
@@ -95,6 +95,23 @@ class PostRevisor
end
end
track_topic_field(:featured_link) do |topic_changes, featured_link|
if SiteSetting.topic_featured_link_enabled &&
featured_link.present? &&
topic_changes.guardian.can_edit_featured_link?(topic_changes.topic.category_id)
topic_changes.record_change('featured_link', topic_changes.topic.featured_link, featured_link)
topic_changes.topic.featured_link = featured_link
if SiteSetting.topic_featured_link_onebox
post = topic_changes.topic.first_post
post.raw = DiscourseFeaturedLink.cache_onebox_link(featured_link)
post.save!
post.rebake!
end
end
end
# AVAILABLE OPTIONS:
# - revised_at: changes the date of the revision
# - force_new_version: bypass ninja-edit window