queue works. needs cleanup.
This commit is contained in:
parent
67535c1113
commit
d91cec0881
4 changed files with 42 additions and 18 deletions
5
Gemfile
5
Gemfile
|
|
@ -3,7 +3,7 @@ source 'http://rubygems.org'
|
|||
gem 'rails', '3.0.0.beta4'
|
||||
gem 'mongrel'
|
||||
gem 'thin'
|
||||
gem 'em-http-request', :git => 'git@github.com:maxwell/em-http-request.git'
|
||||
gem 'em-http-request'
|
||||
gem 'addressable'
|
||||
gem "mongoid", :git => "http://github.com/durran/mongoid.git"
|
||||
gem "bson_ext", "1.0.1"
|
||||
|
|
@ -12,6 +12,9 @@ gem "devise", :git => "git://github.com/plataformatec/devise.git"
|
|||
gem 'roxml', :git => "git://github.com/Empact/roxml.git"
|
||||
|
||||
|
||||
|
||||
gem "dm-core"
|
||||
|
||||
group :test do
|
||||
gem 'rspec', '>= 2.0.0.beta.10'
|
||||
gem 'rspec-rails', ">= 2.0.0.beta.8"
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
class Post
|
||||
require 'lib/common'
|
||||
require 'lib/message_handler'
|
||||
|
||||
|
||||
|
|
@ -8,8 +7,6 @@ class Post
|
|||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
include ROXML
|
||||
@@queue = MessageHandler.new
|
||||
include Diaspora::Hookey
|
||||
|
||||
xml_accessor :owner
|
||||
xml_accessor :snippet
|
||||
|
|
@ -21,7 +18,31 @@ class Post
|
|||
|
||||
before_create :set_defaults
|
||||
#after_update :notify_friends
|
||||
after_save :notify_friends
|
||||
|
||||
@@queue = MessageHandler.new
|
||||
|
||||
def notify_friends
|
||||
puts "hello"
|
||||
|
||||
xml = prep_webhook
|
||||
#friends_with_permissions.each{ |friend| puts friend; Curl.post( "\"" + xml + "\" " + friend) }
|
||||
@@queue.add_post_request( friends_with_permissions, xml )
|
||||
@@queue.process
|
||||
end
|
||||
|
||||
def prep_webhook
|
||||
self.to_xml.to_s.chomp
|
||||
end
|
||||
|
||||
def friends_with_permissions
|
||||
#friends = Friend.only(:url).map{|x| x = x.url + "/receive/"}
|
||||
#3.times {friends = friends + friends}
|
||||
#friends
|
||||
googles = []
|
||||
100.times{ googles <<"http://google.com/"} #"http://localhost:4567/receive/"} #"http://google.com/"}
|
||||
googles
|
||||
end
|
||||
|
||||
@@models = ["StatusMessage", "Bookmark", "Blog"]
|
||||
|
||||
|
|
@ -46,10 +67,5 @@ class Post
|
|||
end
|
||||
|
||||
|
||||
#def notify_friends
|
||||
#friends = Permissions.get_list_for(self)
|
||||
#xml = self.to_xml_to_s
|
||||
#friends.each{|friend| ping friend :with => xml }
|
||||
#end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -22,12 +22,12 @@ module Diaspora
|
|||
def self.included(klass)
|
||||
|
||||
klass.class_eval do
|
||||
#include EventQueue::MessageHandler
|
||||
include EventQueue::MessageHandler
|
||||
before_save :notify_friends
|
||||
|
||||
def notify_friends
|
||||
puts "hello"
|
||||
|
||||
@@queue = MessageHandler.new
|
||||
xml = prep_webhook
|
||||
#friends_with_permissions.each{ |friend| puts friend; Curl.post( "\"" + xml + "\" " + friend) }
|
||||
@@queue.add_post_request( friends_with_permissions, xml )
|
||||
|
|
@ -40,8 +40,8 @@ module Diaspora
|
|||
|
||||
def friends_with_permissions
|
||||
#Friend.only(:url).map{|x| x = x.url + "/receive/"}
|
||||
googles = []
|
||||
5.times{ googles <<"http://google.com/"} #"http://localhost:4567/receive/"} #"http://google.com/"}
|
||||
#googles = []
|
||||
#5.times{ googles <<"http://google.com/"} #"http://localhost:4567/receive/"} #"http://google.com/"}
|
||||
googles
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,7 +1,12 @@
|
|||
require 'em-http'
|
||||
require 'eventmachine'
|
||||
require 'addressable/uri'
|
||||
|
||||
require 'active_support'
|
||||
require 'active_support/core_ext'
|
||||
require 'roxml'
|
||||
require 'dm-core'
|
||||
require 'eventmachine'
|
||||
require 'em-http'
|
||||
|
||||
|
||||
|
||||
class MessageHandler
|
||||
|
||||
NUM_TRIES = 3
|
||||
|
|
@ -25,7 +30,7 @@
|
|||
case query.type
|
||||
when :post
|
||||
http = EventMachine::HttpRequest.new(query.destination).post :timeout => TIMEOUT, :body => query.body
|
||||
http.callback { process}
|
||||
http.callback {puts "YAR"; process}
|
||||
when :get
|
||||
http = EventMachine::HttpRequest.new(query.destination).get :timeout => TIMEOUT
|
||||
http.callback {send_to_seed(query, http.response); process}
|
||||
|
|
|
|||
Loading…
Reference in a new issue