Apply embed unlisted setting consistently (#24294)

Applies the embed_unlisted site setting consistently across topic embeds, including those created via the WP Discourse plugin. Relatedly, adds a embed exception to can_create_unlisted_topic? check. Users creating embedded topics are not always staff.
This commit is contained in:
Angus McLeod
2023-12-12 15:35:26 +01:00
committed by GitHub
parent 7d0562f10e
commit 95c61b88dc
7 changed files with 57 additions and 20 deletions

View File

@@ -72,19 +72,11 @@ class TopicEmbed < ActiveRecord::Base
cook_method: cook_method,
category: category_id || eh.try(:category_id),
tags: SiteSetting.tagging_enabled ? tags : nil,
embed_url: url,
embed_content_sha1: content_sha1,
}
create_args[:visible] = false if SiteSetting.embed_unlisted?
creator = PostCreator.new(user, create_args)
post = creator.create
if post.present?
TopicEmbed.create!(
topic_id: post.topic_id,
embed_url: url,
content_sha1: content_sha1,
post_id: post.id,
)
end
post = PostCreator.create(user, create_args)
end
else
absolutize_urls(url, contents)