tried to git rid of error in em-http-request

This commit is contained in:
Maxwell Salzberg 2010-06-17 09:20:59 -07:00
parent 43207aeb41
commit 67535c1113
4 changed files with 59 additions and 71 deletions

View file

@ -3,7 +3,7 @@ source 'http://rubygems.org'
gem 'rails', '3.0.0.beta4'
gem 'mongrel'
gem 'thin'
gem 'em-http-request'
gem 'em-http-request', :git => 'git@github.com:maxwell/em-http-request.git'
gem 'addressable'
gem "mongoid", :git => "http://github.com/durran/mongoid.git"
gem "bson_ext", "1.0.1"

View file

@ -1,12 +1,14 @@
class Post
require 'lib/common'
require 'lib/message_handler'
# XML accessors must always preceed mongo field tags
include Mongoid::Document
include Mongoid::Timestamps
include ROXML
@@queue = MessageHandler.new
include Diaspora::Hookey
xml_accessor :owner
@ -21,7 +23,6 @@ class Post
#after_update :notify_friends
@@models = ["StatusMessage", "Bookmark", "Blog"]
def self.recent_ordered_posts

View file

@ -19,30 +19,19 @@ module Diaspora
module Hookey
class Curl
def self.post(s)
`curl -X POST -d #{s}`;;
end
def self.get(s)
`curl -X GET #{s}`
end
end
def self.included(klass)
klass.class_eval do
require 'lib/message_handler'
#include EventQueue::MessageHandler
before_save :notify_friends
def notify_friends
m = MessageHandler.new
@@queue = MessageHandler.new
xml = prep_webhook
#friends_with_permissions.each{ |friend| puts friend; Curl.post( "\"" + xml + "\" " + friend) }
m.add_post_request( friends_with_permissions, xml )
m.process
@@queue.add_post_request( friends_with_permissions, xml )
@@queue.process
end
def prep_webhook

View file

@ -4,7 +4,6 @@
class MessageHandler
NUM_TRIES = 3
TIMEOUT = 5 #seconds
@ -25,7 +24,7 @@
@queue.pop{ |query|
case query.type
when :post
http = EventMachine::HttpRequest.new(query.destination).post :timeout => TIMEOUT, :body =>query.body
http = EventMachine::HttpRequest.new(query.destination).post :timeout => TIMEOUT, :body => query.body
http.callback { process}
when :get
http = EventMachine::HttpRequest.new(query.destination).get :timeout => TIMEOUT
@ -60,5 +59,4 @@
@try_count = 0
end
end
end
end