don't post to feed; post to joindiaspora OG tag. also, whoever has the diaspora OG tag, can i haz?
This commit is contained in:
parent
8cecedc53b
commit
a52d8f221a
2 changed files with 13 additions and 8 deletions
|
|
@ -1,4 +1,6 @@
|
||||||
class Services::Facebook < Service
|
class Services::Facebook < Service
|
||||||
|
include Rails.application.routes.url_helpers
|
||||||
|
|
||||||
MAX_CHARACTERS = 420
|
MAX_CHARACTERS = 420
|
||||||
|
|
||||||
def provider
|
def provider
|
||||||
|
|
@ -7,7 +9,11 @@ class Services::Facebook < Service
|
||||||
|
|
||||||
def post(post, url='')
|
def post(post, url='')
|
||||||
Rails.logger.debug("event=post_to_service type=facebook sender_id=#{self.user_id}")
|
Rails.logger.debug("event=post_to_service type=facebook sender_id=#{self.user_id}")
|
||||||
Faraday.post("https://graph.facebook.com/me/joindiaspora:make", {:access_token => self.access_token}.to_param)
|
Faraday.post("https://graph.facebook.com/me/joindiaspora:make", create_post_params(post).to_param)
|
||||||
|
end
|
||||||
|
|
||||||
|
def create_post_params(post)
|
||||||
|
{:post => "#{AppConfig[:pod_url]}#{short_post_path(post)}", :access_token => self.access_token}
|
||||||
end
|
end
|
||||||
|
|
||||||
def public_message(post, url)
|
def public_message(post, url)
|
||||||
|
|
|
||||||
|
|
@ -11,25 +11,24 @@ describe Services::Facebook do
|
||||||
|
|
||||||
describe '#post' do
|
describe '#post' do
|
||||||
it 'posts a status message to facebook' do
|
it 'posts a status message to facebook' do
|
||||||
|
stub_request(:post, "https://graph.facebook.com/me/joindiaspora:make").
|
||||||
stub_request(:post, "https://graph.facebook.com/me/feed").
|
to_return(:status => 200, :body => "", :headers => {})
|
||||||
to_return(:status => 200)
|
|
||||||
@service.post(@post)
|
@service.post(@post)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'swallows exception raised by facebook always being down' do
|
it 'swallows exception raised by facebook always being down' do
|
||||||
pending "temporarily disabled to figure out while some requests are failing"
|
pending "temporarily disabled to figure out while some requests are failing"
|
||||||
|
|
||||||
stub_request(:post,"https://graph.facebook.com/me/feed").
|
stub_request(:post,"https://graph.facebook.com/me/joindiaspora:make").
|
||||||
to_raise(StandardError)
|
to_raise(StandardError)
|
||||||
@service.post(@post)
|
@service.post(@post)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should call public message' do
|
it 'should call public message' do
|
||||||
stub_request(:post, "https://graph.facebook.com/me/feed").
|
stub_request(:post, "https://graph.facebook.com/me/joindiaspora:make").
|
||||||
to_return(:status => 200)
|
to_return(:status => 200)
|
||||||
url = "foo"
|
url = "foo"
|
||||||
@service.should_receive(:public_message).with(@post, url)
|
@service.should_not_receive(:public_message)
|
||||||
@service.post(@post, url)
|
@service.post(@post, url)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue