Remove the topic_featured_link_onebox setting. We will always try to onebox a link and add it to the body if topic_featured_link_enabled is enabled.

This commit is contained in:
Neil Lalonde 2016-12-09 13:28:12 -05:00
parent f07443b488
commit a4c4f13901
7 changed files with 8 additions and 31 deletions

View File

@ -13,8 +13,7 @@ export default Ember.Component.extend({
'composer.canEditTitle:edit-title',
'composer.createdPost:created-post',
'composer.creatingTopic:topic',
'composer.whisper:composing-whisper',
'composer.showComposerEditor::topic-featured-link-only'],
'composer.whisper:composing-whisper'],
@computed('composer.composeState')
composeState(composeState) {

View File

@ -195,11 +195,6 @@ const Composer = RestModel.extend({
}.property('action', 'post', 'topic', 'topic.title'),
@computed('canEditTopicFeaturedLink')
showComposerEditor(canEditTopicFeaturedLink) {
return canEditTopicFeaturedLink ? !this.siteSettings.topic_featured_link_onebox : true;
},
// whether to disable the post button
cantSubmitPost: function() {

View File

@ -436,9 +436,6 @@ posting:
topic_featured_link_enabled:
client: true
default: false
topic_featured_link_onebox:
client: true
default: false
open_topic_featured_link_in_external_window:
client: true
default: true

View File

@ -104,11 +104,6 @@ class PostCreator
end
end
onebox_featured_link = SiteSetting.topic_featured_link_enabled && SiteSetting.topic_featured_link_onebox && guardian.can_edit_featured_link?(find_category_id)
if onebox_featured_link
@opts[:raw] = DiscourseFeaturedLink.cache_onebox_link(@opts[:featured_link])
end
setup_post
return true if skip_validations?
@ -122,7 +117,7 @@ class PostCreator
DiscourseEvent.trigger :before_create_post, @post
DiscourseEvent.trigger :validate_post, @post
post_validator = Validators::PostValidator.new(skip_topic: true, skip_post_body: onebox_featured_link)
post_validator = Validators::PostValidator.new(skip_topic: true)
post_validator.validate(@post)
valid = @post.errors.blank?

View File

@ -102,13 +102,6 @@ class PostRevisor
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

View File

@ -20,7 +20,7 @@ describe PostCreator do
let(:creator_with_category) { PostCreator.new(user, basic_topic_params.merge(category: category.id )) }
let(:creator_with_meta_data) { PostCreator.new(user, basic_topic_params.merge(meta_data: {hello: "world"} )) }
let(:creator_with_image_sizes) { PostCreator.new(user, basic_topic_params.merge(image_sizes: image_sizes)) }
let(:creator_with_featured_link) { PostCreator.new(user, title: "featured link topic", archetype_id: 1, featured_link: "http://discourse.org") }
let(:creator_with_featured_link) { PostCreator.new(user, title: "featured link topic", archetype_id: 1, featured_link: "http://www.discourse.org", raw: "http://www.discourse.org") }
it "can create a topic with null byte central" do
post = PostCreator.create(user, title: "hello\u0000world this is title", raw: "this is my\u0000 first topic")
@ -244,12 +244,10 @@ describe PostCreator do
end
end
it 'creates a post without raw' do
it 'creates a post with featured link' do
SiteSetting.topic_featured_link_enabled = true
SiteSetting.topic_featured_link_onebox = true
post = creator_with_featured_link.create
expect(post.topic.featured_link).to eq('http://discourse.org')
expect(post.raw).to eq('http://discourse.org')
expect(post.topic.featured_link).to eq('http://www.discourse.org')
end
describe "topic's auto close" do

View File

@ -41,9 +41,9 @@ test('missingReplyCharacters', function() {
missingReplyCharacters('hi', false, true, Discourse.SiteSettings.min_first_post_length - 2, 'too short first post');
missingReplyCharacters('hi', true, false, Discourse.SiteSettings.min_private_message_post_length - 2, 'too short private message');
Discourse.SiteSettings.topic_featured_link_onebox = true;
const composer = createComposer({ canEditTopicFeaturedLink: true });
equal(composer.get('missingReplyCharacters'), 0, "don't require any post content");
// TODO: test that presence of featured link makes this test pass
// const composer = createComposer({ canEditTopicFeaturedLink: true });
// equal(composer.get('missingReplyCharacters'), 0, "don't require any post content");
});
test('missingTitleCharacters', function() {