i think it works - max

This commit is contained in:
maxwell 2010-07-21 21:15:16 -07:00
parent 9b1fcdbab2
commit 6869384732
5 changed files with 28 additions and 21 deletions

View file

@ -26,6 +26,8 @@ class RequestsController < ApplicationController
def create
rel_hash = relationship_flow(params[:request][:destination_url])
puts rel_hash
@request = current_user.send_request(rel_hash)
if @request

View file

@ -25,7 +25,6 @@ module RequestsHelper
def subscription_url(action, profile)
if action == :subscribe
pp profile.links
profile.links.select{|x| x.rel == 'http://schemas.google.com/g/2010#updates-from'}.first.href
elsif action == :friend
profile.links.select{|x| x.rel == 'http://joindiaspora.com/seed_location'}.first.href

View file

@ -1,4 +1,6 @@
class User < Person
require 'lib/common'
include Diaspora::OStatusParser
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
@ -78,18 +80,18 @@ class User < Person
####ostatus######
#
def subscribe_to_pubsub(feed_url)
# THIS SHOULD REALLY BE IN A REQUESR>>>> FIGURE IT OUT
r = Request.instantiate(:to => feed_url, :from => self)
r.subscribe_to_ostatus(feed_url)
r
end
def send_request(thing)
if thing[:friend]
self.send_friend_request(thing[:friend])
elsif thing[:subscribe]
self.subscribe_to_pubsub(thing[:subscrube])
def send_request(rel_hash)
puts rel_hash.inspect
if rel_hash[:friend]
self.send_friend_request_to(rel_hash[:friend])
elsif rel_hash[:subscribe]
self.subscribe_to_pubsub(rel_hash[:subscribe])
else
raise "you can't do anything to that url"
end

View file

@ -71,8 +71,9 @@ module Diaspora
end
end
def subscribe_to_ostatus(hub, feed_url)
@@queue.add_subscription_request(hub, feed_url)
def subscribe_to_ostatus(feed_url)
puts feed_url
@@queue.add_subscription_request(feed_url)
@@queue.process
end

View file

@ -1,5 +1,6 @@
class MessageHandler
include Diaspora::OStatusParser
NUM_TRIES = 3
TIMEOUT = 5 #seconds
@ -26,15 +27,7 @@ class MessageHandler
end
def add_subscription_request(feed)
feed_action = lambda{
hub = Diaspora::OStatusParser::find_hub(http.response)
add_hub_subscription_request(hub, query.destination)
Diaspora::OStatus::parse_sender(http.response)
}
@queue.push(Message.new(:subscribe, feed, :callback => callback))
@queue.push(Message.new(:subscribe, feed))
end
def process
@ -48,8 +41,18 @@ class MessageHandler
http.callback {send_to_seed(query, http.response); process}
when :subscribe
puts query.destination
http = EventMachine::HttpRequest.new(query.destination).get :timeout => TIMEOUT
http.callback query.callback
http.callback {
require 'lib/common'
puts http.response
hub = Nokogiri::HTML(http.response).xpath('//link[@rel="hub"]').first.attribute("href").value
add_hub_subscription_request(hub, query.destination)
#Diaspora::OStatus::parse_sender(http.response)
process
}
when :pubhub
http = EventMachine::PubSubHubbub.new(query.destination).publish query.body, :timeout => TIMEOUT