DG MS; queue still working. half-way finished cleaning up code.
This commit is contained in:
parent
d91cec0881
commit
4cecb522b6
3 changed files with 57 additions and 90 deletions
|
|
@ -1,4 +1,5 @@
|
|||
class Post
|
||||
require 'lib/common'
|
||||
require 'lib/message_handler'
|
||||
|
||||
|
||||
|
|
@ -7,6 +8,7 @@ class Post
|
|||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
include ROXML
|
||||
include Diaspora::Hookey
|
||||
|
||||
xml_accessor :owner
|
||||
xml_accessor :snippet
|
||||
|
|
@ -17,32 +19,6 @@ class Post
|
|||
field :snippet
|
||||
|
||||
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"]
|
||||
|
||||
|
|
@ -65,7 +41,5 @@ class Post
|
|||
self.source ||= user_email
|
||||
self.snippet ||= user_email
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -22,14 +22,12 @@ module Diaspora
|
|||
def self.included(klass)
|
||||
|
||||
klass.class_eval do
|
||||
include EventQueue::MessageHandler
|
||||
before_save :notify_friends
|
||||
|
||||
def notify_friends
|
||||
puts "hello"
|
||||
@@queue = MessageHandler.new
|
||||
|
||||
def notify_friends
|
||||
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
|
||||
|
|
@ -39,10 +37,7 @@ module Diaspora
|
|||
end
|
||||
|
||||
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
|
||||
Friend.only(:url).map{|x| x = x.url + "/receive/"}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -5,9 +5,7 @@ require 'dm-core'
|
|||
require 'eventmachine'
|
||||
require 'em-http'
|
||||
|
||||
|
||||
|
||||
class MessageHandler
|
||||
class MessageHandler
|
||||
|
||||
NUM_TRIES = 3
|
||||
TIMEOUT = 5 #seconds
|
||||
|
|
@ -64,4 +62,4 @@ require 'em-http'
|
|||
@try_count = 0
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue