TIMELINE TIME.
This commit is contained in:
parent
bec7b96de7
commit
8cecedc53b
2 changed files with 1 additions and 20 deletions
|
|
@ -7,17 +7,7 @@ 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}")
|
||||||
message = public_message(post, url)
|
Faraday.post("https://graph.facebook.com/me/joindiaspora:make", {:access_token => self.access_token}.to_param)
|
||||||
post_params = self.create_post_params(message)
|
|
||||||
Faraday.post("https://graph.facebook.com/me/feed", post_params.to_param)
|
|
||||||
end
|
|
||||||
|
|
||||||
def create_post_params(message)
|
|
||||||
hash = {:message => message, :access_token => self.access_token}
|
|
||||||
if /https?:\/\/(\S+)/ =~ message
|
|
||||||
hash.merge!({:link => /https?:\/\/(\S+)/.match(message)[0]})
|
|
||||||
end
|
|
||||||
return hash
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def public_message(post, url)
|
def public_message(post, url)
|
||||||
|
|
|
||||||
|
|
@ -33,15 +33,6 @@ describe Services::Facebook do
|
||||||
@service.post(@post, url)
|
@service.post(@post, url)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#create_post_params' do
|
|
||||||
it 'should have a link when the message has a link' do
|
|
||||||
@service.create_post_params("http://example.com/ test message")[:link].should == "http://example.com/"
|
|
||||||
end
|
|
||||||
it 'should not have a link when the message has no link' do
|
|
||||||
@service.create_post_params("test message")[:link].should == nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'finder' do
|
context 'finder' do
|
||||||
before do
|
before do
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue