Skip to content

Commit

Permalink
Revert "Revert redis merge to fix bugs on master"
Browse files Browse the repository at this point in the history
This reverts commit 30698d6.
  • Loading branch information
Raphael committed Dec 2, 2010
1 parent 3688b39 commit 8798f05
Show file tree
Hide file tree
Showing 34 changed files with 707 additions and 365 deletions.
6 changes: 5 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,14 @@ gem 'mini_magick'
gem 'aws'
gem 'fastercsv', :require => false
gem 'jammit'

gem 'rest-client'
#Backups
gem "cloudfiles", :require => false

#Queue
gem 'resque'
gem 'SystemTimer'

group :test, :development do
gem 'factory_girl_rails'
gem 'ruby-debug19' if RUBY_VERSION.include? "1.9"
Expand Down
18 changes: 18 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ PATH
GEM
remote: http://rubygems.org/
specs:
SystemTimer (1.2.1)
abstract (1.0.0)
actionmailer (3.0.1)
actionpack (= 3.0.1)
Expand Down Expand Up @@ -296,6 +297,14 @@ GEM
rake (>= 0.8.4)
thor (~> 0.14.0)
rake (0.8.7)
redis (2.1.1)
redis-namespace (0.8.0)
redis (< 3.0.0)
resque (1.10.0)
json (~> 1.4.6)
redis-namespace (~> 0.8.0)
sinatra (>= 0.9.2)
vegas (~> 0.1.2)
rest-client (1.6.1)
mime-types (>= 1.16)
rspec (2.2.0)
Expand Down Expand Up @@ -330,6 +339,9 @@ GEM
ffi (~> 0.6.3)
json_pure
rubyzip
sinatra (1.1.0)
rack (~> 1.1)
tilt (~> 1.1)
subexec (0.0.4)
systemu (1.2.0)
term-ansicolor (1.0.5)
Expand All @@ -338,6 +350,7 @@ GEM
eventmachine (>= 0.12.6)
rack (>= 1.0.0)
thor (0.14.6)
tilt (1.1)
treetop (1.4.9)
polyglot (>= 0.3.1)
twitter (0.9.12)
Expand All @@ -347,6 +360,8 @@ GEM
oauth (~> 0.4.3)
tzinfo (0.3.23)
uuidtools (2.1.1)
vegas (0.1.8)
rack (>= 1.0.0)
warden (0.10.7)
rack (>= 1.0.0)
webmock (1.6.1)
Expand All @@ -360,6 +375,7 @@ PLATFORMS
ruby

DEPENDENCIES
SystemTimer
addressable
aws
bson (= 1.1)
Expand Down Expand Up @@ -393,6 +409,8 @@ DEPENDENCIES
omniauth
pubsubhubbub
rails (= 3.0.1)
resque
rest-client
roxml!
rspec (>= 2.0.0)
rspec-instafail
Expand Down
1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@

require File.expand_path('../config/application', __FILE__)
require 'rake'
require 'resque/tasks'

Diaspora::Application.load_tasks
10 changes: 1 addition & 9 deletions app/controllers/people_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,6 @@ def hashes_for_posts posts
end
end
def webfinger(account, opts = {})
finger = EMWebfinger.new(account)
finger.on_person do |response|
if response.class == Person
response.socket_to_uid(current_user.id, opts)
else
require File.join(Rails.root,'lib/diaspora/websocket')
Diaspora::WebSocket.queue_to_user(current_user.id, {:class => 'people', :status => 'fail', :query => account, :response => response}.to_json)
end
end
Resque.enqueue(Jobs::SocketWebfinger, current_user.id, account, opts)
end
end
7 changes: 1 addition & 6 deletions app/controllers/publics_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,7 @@ def receive
end

@user = person.owner

begin
@user.receive_salmon(params[:xml])
rescue Exception => e
Rails.logger.info("bad salmon: #{e.message}")
end
Resque.enqueue(Jobs::ReceiveSalmon, @user.id, params[:xml])

render :nothing => true, :status => 200
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/requests_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.

require File.join(Rails.root, 'lib/em-webfinger')
require File.join(Rails.root, 'lib/webfinger')

class RequestsController < ApplicationController
before_filter :authenticate_user!
Expand Down
2 changes: 1 addition & 1 deletion app/models/comment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def validate(document)
end

class Comment
require File.join(Rails.root, 'lib/diaspora/websocket')
require File.join(Rails.root, 'lib/diaspora/web_socket')
require File.join(Rails.root, 'lib/youtube_titles')
include YoutubeTitles
include MongoMapper::Document
Expand Down
10 changes: 10 additions & 0 deletions app/models/jobs/receive_salmon.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module Jobs
class ReceiveSalmon
@queue = :receive
def self.perform(user_id, xml)
user = User.find(user_id)
user.receive_salmon(xml)
end
end
end

15 changes: 15 additions & 0 deletions app/models/jobs/socket_webfinger.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module Jobs
class SocketWebfinger
@queue = :receive
def self.perform(user_id, account, opts={})
finger = Webfinger.new(account)
begin
result = finger.fetch
result.socket_to_uid(user_id, opts)
rescue
Diaspora::WebSocket.queue_to_user(user_id, {:class => 'people', :status => 'fail', :query => account, :response => I18n.t('people.webfinger.fail')}.to_json)
end
end
end
end

2 changes: 1 addition & 1 deletion app/models/person.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Person
include MongoMapper::Document
include ROXML
include Encryptor::Public
require File.join(Rails.root, 'lib/diaspora/websocket')
require File.join(Rails.root, 'lib/diaspora/web_socket')
include Diaspora::Socketable

xml_accessor :_id
Expand Down
2 changes: 1 addition & 1 deletion app/models/post.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class Post
require File.join(Rails.root, 'lib/encryptable')
require File.join(Rails.root, 'lib/diaspora/websocket')
require File.join(Rails.root, 'lib/diaspora/web_socket')
include MongoMapper::Document
include ApplicationHelper
include ROXML
Expand Down
2 changes: 1 addition & 1 deletion app/models/retraction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def perform receiving_user_id
if self.type.constantize.find_by_id(post_id)
unless Post.first(:diaspora_handle => person.diaspora_handle, :id => post_id)
Rails.logger.info("event=retraction status=abort reason='no post found authored by retractor' sender=#{person.diaspora_handle} post_id=#{post_id}")
raise "#{person.inspect} is trying to retract a post that either doesn't exist or is not by them"
return
end

begin
Expand Down
Loading

0 comments on commit 8798f05

Please sign in to comment.