fixed twitter, added logging for constants, added job for local recieve
This commit is contained in:
parent
acc8803cee
commit
c43077d318
4 changed files with 42 additions and 4 deletions
|
|
@ -35,7 +35,9 @@ class ServicesController < ApplicationController
|
|||
|
||||
|
||||
def failure
|
||||
puts params.inspect
|
||||
Rails.logger.info "error in oauth #{params.inspect}"
|
||||
flash[:error] = "there was an error connecting that service"
|
||||
redirect_to services_url
|
||||
end
|
||||
|
||||
def destroy
|
||||
|
|
|
|||
10
app/models/jobs/receive.rb
Normal file
10
app/models/jobs/receive.rb
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
module Jobs
|
||||
class Receive
|
||||
@queue = :receive
|
||||
def self.perform(user_id, xml, salmon_author_id)
|
||||
user = User.find(user_id)
|
||||
salmon_author = Person.find(salmon_author_id)
|
||||
user.receive(xml, salmon_author)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -194,10 +194,16 @@ class User
|
|||
end
|
||||
|
||||
def post_to_twitter(service, message)
|
||||
twitter_key = SERVICES['twitter']['consumer_key']
|
||||
twitter_consumer_secret = SERVICES['twitter']['consumer_secret']
|
||||
|
||||
if twitter_consumer_secret.blank? || twitter_consumer_secret.blank?
|
||||
Rails.logger.info "you have a blank twitter key or secret.... you should look into that"
|
||||
end
|
||||
|
||||
Twitter.configure do |config|
|
||||
config.consumer_key = SERVICES['twitter']['consumer_key']
|
||||
config.consumer_secret = SERVICES['twitter']['consumer_secret']
|
||||
config.consumer_key = twitter_key
|
||||
config.consumer_secret = twitter_consumer_secret
|
||||
config.oauth_token = service.access_token
|
||||
config.oauth_token_secret = service.access_secret
|
||||
end
|
||||
|
|
@ -260,7 +266,7 @@ class User
|
|||
# calling nil? performs a necessary evaluation.
|
||||
if person.owner_id
|
||||
Rails.logger.info("event=push_to_person route=local sender=#{self.diaspora_handle} recipient=#{person.diaspora_handle} payload_type=#{post.class}")
|
||||
person.owner.receive(post.to_diaspora_xml, self.person)
|
||||
Resque.enqueue(Jobs::Receive, person.owner_id, post.to_diaspora_xml, self.person.id)
|
||||
else
|
||||
xml = salmon.xml_for person
|
||||
Rails.logger.info("event=push_to_person route=remote sender=#{self.diaspora_handle} recipient=#{person.diaspora_handle} payload_type=#{post.class}")
|
||||
|
|
|
|||
20
spec/models/jobs/receive_spec.rb
Normal file
20
spec/models/jobs/receive_spec.rb
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Jobs::Receive do
|
||||
before do
|
||||
@user = make_user
|
||||
@person = Factory(:person)
|
||||
@xml = '<xml></xml>'
|
||||
User.stub(:find){ |id|
|
||||
if id == @user.id
|
||||
@user
|
||||
else
|
||||
nil
|
||||
end
|
||||
}
|
||||
end
|
||||
it 'calls receive' do
|
||||
@user.should_receive(:receive).with(@xml, @person).once
|
||||
Jobs::Receive.perform(@user.id, @xml, @person.id)
|
||||
end
|
||||
end
|
||||
Loading…
Reference in a new issue