From 11f04a060e9799b3266565a56b5b7e6a665b9803 Mon Sep 17 00:00:00 2001 From: maxwell Date: Thu, 2 Dec 2010 14:55:35 -0800 Subject: [PATCH] frustrated --- Gemfile | 2 +- Gemfile.lock | 65 ++++++++++++-------------- app/controllers/services_controller.rb | 11 +++-- app/models/user.rb | 6 +-- config/deploy_config.yml | 2 +- service_spec.rb | 11 +++++ 6 files changed, 54 insertions(+), 43 deletions(-) create mode 100644 service_spec.rb diff --git a/Gemfile b/Gemfile index a5dfb8156..103d93a5d 100644 --- a/Gemfile +++ b/Gemfile @@ -13,7 +13,7 @@ gem 'devise-mongo_mapper', :git => 'git://github.com/collectiveidea/devise-mongo gem 'devise_invitable','0.3.5' #Authentication -gem 'omniauth', :git => 'https://github.com/intridea/omniauth.git' +gem 'omniauth', '0.1.6' gem 'twitter', :git => 'https://github.com/jnunemaker/twitter.git' #Mongo diff --git a/Gemfile.lock b/Gemfile.lock index c3954fb35..91552e874 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -63,40 +63,6 @@ GIT carrierwave (0.5.0) activesupport (~> 3.0) -GIT - remote: https://github.com/intridea/omniauth.git - revision: 3cdb4908d1a79df038be75e28077738584547cb6 - specs: - oa-basic (0.2.0.beta1) - multi_json (~> 0.0.2) - nokogiri (~> 1.4.2) - oa-core (= 0.2.0.beta1) - rest-client (~> 1.6.0) - oa-core (0.2.0.beta1) - rack (~> 1.1) - oa-enterprise (0.2.0.beta1) - net-ldap (~> 0.1.1) - nokogiri (~> 1.4.2) - oa-core (= 0.2.0.beta1) - pyu-ruby-sasl (~> 0.0.3.1) - rubyntlm (~> 0.1.1) - oa-oauth (0.2.0.beta1) - multi_json (~> 0.0.2) - nokogiri (~> 1.4.2) - oa-core (= 0.2.0.beta1) - oauth (~> 0.4.0) - oauth2 (~> 0.1.0) - oa-openid (0.2.0.beta1) - oa-core (= 0.2.0.beta1) - rack-openid (~> 1.2.0) - ruby-openid-apps-discovery - omniauth (0.2.0.beta1) - oa-basic (= 0.2.0.beta1) - oa-core (= 0.2.0.beta1) - oa-enterprise (= 0.2.0.beta1) - oa-oauth (= 0.2.0.beta1) - oa-openid (= 0.2.0.beta1) - GIT remote: https://github.com/jnunemaker/twitter.git revision: 4ba1444ea061c130836d671d0b451040687f757b @@ -274,6 +240,29 @@ GEM multipart-post (1.0.1) net-ldap (0.1.1) nokogiri (1.4.3.1) + oa-basic (0.1.6) + multi_json (~> 0.0.2) + nokogiri (~> 1.4.2) + oa-core (= 0.1.6) + rest-client (~> 1.6.0) + oa-core (0.1.6) + rack (~> 1.1) + oa-enterprise (0.1.6) + net-ldap (~> 0.1.1) + nokogiri (~> 1.4.2) + oa-core (= 0.1.6) + pyu-ruby-sasl (~> 0.0.3.1) + rubyntlm (~> 0.1.1) + oa-oauth (0.1.6) + multi_json (~> 0.0.2) + nokogiri (~> 1.4.2) + oa-core (= 0.1.6) + oauth (~> 0.4.0) + oauth2 (~> 0.1.0) + oa-openid (0.1.6) + oa-core (= 0.1.6) + rack-openid (~> 1.2.0) + ruby-openid-apps-discovery oauth (0.4.4) oauth2 (0.1.0) faraday (~> 0.5.0) @@ -285,6 +274,12 @@ GEM mixlib-config mixlib-log systemu + omniauth (0.1.6) + oa-basic (= 0.1.6) + oa-core (= 0.1.6) + oa-enterprise (= 0.1.6) + oa-oauth (= 0.1.6) + oa-openid (= 0.1.6) plucky (0.3.6) mongo (~> 1.1) polyglot (0.3.1) @@ -404,7 +399,7 @@ DEPENDENCIES mongo_mapper! mongrel nokogiri (= 1.4.3.1) - omniauth! + omniauth (= 0.1.6) pubsubhubbub rails (= 3.0.1) roxml! diff --git a/app/controllers/services_controller.rb b/app/controllers/services_controller.rb index e5fe5830e..9850243a2 100644 --- a/app/controllers/services_controller.rb +++ b/app/controllers/services_controller.rb @@ -13,15 +13,20 @@ class ServicesController < ApplicationController def create auth = request.env['omniauth.auth'] - pp auth + pp auth['credentials'] + + toke = auth['credentials']['token'] + secret = auth['credentials']['secret'] + + provider = auth['provider'] user = auth['user_info'] if provider == 'twitter' access_token = auth['extra']['access_token'] current_user.services.create(:nickname => user['nickname'], - :access_token => access_token.token, - :access_secret => access_token.secret, + :access_token => toke, + :access_secret => secret, :provider => provider, :uid => auth['uid']) diff --git a/app/models/user.rb b/app/models/user.rb index fc3af996b..6fa9b4c2a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -4,7 +4,7 @@ require File.join(Rails.root, 'lib/diaspora/user') require File.join(Rails.root, 'lib/salmon/salmon') - +require 'rest-client' class User include MongoMapper::Document include Diaspora::UserModules @@ -179,13 +179,13 @@ class User def post_to_facebook(service, message) Rails.logger.info("Sending a message: #{message} to Facebook") begin - RestClient.post("https://graph.facebook.com/me/feed?message=#{message}&access_token=#{service.access_token}") + RestClient.post("https://graph.facebook.com/me/feed", :message => message, :access_token => service.access_token) rescue Exception => e Rails.logger.info("#{e.message} failed to post to facebook") end end - def post_to_twitter(service, message) + def post_to_twitter(service, message) Twitter.configure do |config| config.consumer_key = SERVICES['twitter']['consumer_token'] diff --git a/config/deploy_config.yml b/config/deploy_config.yml index 06a6747e1..2ee5923c5 100644 --- a/config/deploy_config.yml +++ b/config/deploy_config.yml @@ -6,7 +6,7 @@ cross_server: deploy_to: '/usr/local/app/diaspora' user: 'root' repo: 'git://github.com/diaspora/diaspora.git' - branch: 'master' + branch: 'public-permalinks' default_env: 'development' servers: tom: diff --git a/service_spec.rb b/service_spec.rb new file mode 100644 index 000000000..3595431c7 --- /dev/null +++ b/service_spec.rb @@ -0,0 +1,11 @@ +# Copyright (c) 2010, Diaspora Inc. This file is +# licensed under the Affero General Public License version 3 or later. See +# the COPYRIGHT file. + +require 'spec_helper' + +describe Service do + + let(:user) { make_user } + +end