frustrated

This commit is contained in:
maxwell 2010-12-02 14:55:35 -08:00
parent b9131c0e46
commit 11f04a060e
6 changed files with 54 additions and 43 deletions

View file

@ -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

View file

@ -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!

View file

@ -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'])

View file

@ -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']

View file

@ -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:

11
service_spec.rb Normal file
View file

@ -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