Only parse opengraph if oembed is not available

This commit is contained in:
Fábián Tamás László 2013-08-04 12:54:38 +02:00 committed by Jonne Haß
parent 54b166bde9
commit ba3d60b00f
3 changed files with 11 additions and 2 deletions

View file

@ -31,6 +31,7 @@
* Use first header as title in the single post view, when possible [#4256](https://github.com/diaspora/diaspora/pull/4256) * Use first header as title in the single post view, when possible [#4256](https://github.com/diaspora/diaspora/pull/4256)
* Close publisher when clicking on the page outside of it [#4282](https://github.com/diaspora/diaspora/pull/4282) * Close publisher when clicking on the page outside of it [#4282](https://github.com/diaspora/diaspora/pull/4282)
* Deleting a post deletes it from Tumblr too [#4331](https://github.com/diaspora/diaspora/pull/4331) * Deleting a post deletes it from Tumblr too [#4331](https://github.com/diaspora/diaspora/pull/4331)
* OpenGraph support [#4215](https://github.com/diaspora/diaspora/pull/4215)
# 0.1.1.0 # 0.1.1.0

View file

@ -155,6 +155,7 @@ class StatusMessage < Post
end end
def contains_open_graph_url_in_text? def contains_open_graph_url_in_text?
return nil if self.contains_oembed_url_in_text?
self.open_graph_url = URI.extract(self.raw_message, ['http', 'https'])[0] self.open_graph_url = URI.extract(self.raw_message, ['http', 'https'])[0]
end end

View file

@ -391,8 +391,10 @@ STR
describe 'opengraph' do describe 'opengraph' do
before do before do
@ninegag_url = "http://9gag.com/gag/a1AMW16"
@youtube_url = "https://www.youtube.com/watch?v=3PtFwlKfvHI" @youtube_url = "https://www.youtube.com/watch?v=3PtFwlKfvHI"
@message_text = "#{@youtube_url} is so cool. so is this link -> https://joindiaspora.com" @message_text = "#{@ninegag_url} is so cool. so is this link -> https://joindiaspora.com"
@oemessage_text = "#{@youtube_url} is so cool. so is this link -> https://joindiaspora.com"
end end
it 'should queue a GatherOpenGraphData if it includes a link' do it 'should queue a GatherOpenGraphData if it includes a link' do
@ -405,7 +407,12 @@ STR
it 'returns the opengraph urls found in the raw message' do it 'returns the opengraph urls found in the raw message' do
sm = FactoryGirl.build(:status_message, :text => @message_text) sm = FactoryGirl.build(:status_message, :text => @message_text)
sm.contains_open_graph_url_in_text?.should_not be_nil sm.contains_open_graph_url_in_text?.should_not be_nil
sm.open_graph_url.should == @youtube_url sm.open_graph_url.should == @ninegag_url
end
it 'returns nil if the link is from trusted oembed provider' do
sm = FactoryGirl.build(:status_message, :text => @oemessage_text)
sm.contains_open_graph_url_in_text?.should be_nil
sm.open_graph_url.should be_nil
end end
end end
end end