diff --git a/Changelog.md b/Changelog.md index 38efeec22..01f130c5b 100644 --- a/Changelog.md +++ b/Changelog.md @@ -31,6 +31,7 @@ * 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) * 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 diff --git a/app/models/status_message.rb b/app/models/status_message.rb index f5bb096ed..472fbcff1 100644 --- a/app/models/status_message.rb +++ b/app/models/status_message.rb @@ -155,6 +155,7 @@ class StatusMessage < Post end 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] end diff --git a/spec/models/status_message_spec.rb b/spec/models/status_message_spec.rb index 0395cffcd..28db3a47a 100644 --- a/spec/models/status_message_spec.rb +++ b/spec/models/status_message_spec.rb @@ -391,8 +391,10 @@ STR describe 'opengraph' do before do + @ninegag_url = "http://9gag.com/gag/a1AMW16" @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 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 sm = FactoryGirl.build(:status_message, :text => @message_text) 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