Merge branch 'master' of github.com:diaspora/diaspora_rails
This commit is contained in:
commit
a1a8fc1ea4
10 changed files with 336 additions and 15 deletions
|
|
@ -25,9 +25,11 @@ class RequestsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
url = relationship_flow(params[:request][:destination_url])[:friend]
|
rel_hash = relationship_flow(params[:request][:destination_url])
|
||||||
|
|
||||||
|
puts rel_hash
|
||||||
|
@request = current_user.send_request(rel_hash)
|
||||||
|
|
||||||
@request = current_user.send_friend_request_to(url) unless url.include?('@')|| url == ''
|
|
||||||
if @request
|
if @request
|
||||||
flash[:notice] = "a friend request was sent to #{@request.destination_url}"
|
flash[:notice] = "a friend request was sent to #{@request.destination_url}"
|
||||||
redirect_to requests_url
|
redirect_to requests_url
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@ module RequestsHelper
|
||||||
|
|
||||||
def subscription_url(action, profile)
|
def subscription_url(action, profile)
|
||||||
if action == :subscribe
|
if action == :subscribe
|
||||||
pp profile.links
|
|
||||||
profile.links.select{|x| x.rel == 'http://schemas.google.com/g/2010#updates-from'}.first.href
|
profile.links.select{|x| x.rel == 'http://schemas.google.com/g/2010#updates-from'}.first.href
|
||||||
elsif action == :friend
|
elsif action == :friend
|
||||||
profile.links.select{|x| x.rel == 'http://joindiaspora.com/seed_location'}.first.href
|
profile.links.select{|x| x.rel == 'http://joindiaspora.com/seed_location'}.first.href
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
class User < Person
|
class User < Person
|
||||||
|
require 'lib/common'
|
||||||
|
include Diaspora::OStatusParser
|
||||||
|
|
||||||
devise :database_authenticatable, :registerable,
|
devise :database_authenticatable, :registerable,
|
||||||
:recoverable, :rememberable, :trackable, :validatable
|
:recoverable, :rememberable, :trackable, :validatable
|
||||||
|
|
@ -75,6 +77,26 @@ class User < Person
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
####ostatus######
|
||||||
|
#
|
||||||
|
def subscribe_to_pubsub(feed_url)
|
||||||
|
r = Request.instantiate(:to => feed_url, :from => self)
|
||||||
|
r.subscribe_to_ostatus(feed_url)
|
||||||
|
r
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
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
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
###Helpers############
|
###Helpers############
|
||||||
def mine?(post)
|
def mine?(post)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,20 @@
|
||||||
module Diaspora
|
module Diaspora
|
||||||
module XMLParser
|
module OStatusParser
|
||||||
|
def self.find_hub(xml)
|
||||||
|
Nokogiri::HTML(xml).xpath('//link[@rel="hub"]').first.attribute("href").value
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.parse_sender(xml)
|
||||||
|
puts "you just won the game"
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.parse_objects(xml)
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
module XMLParser
|
||||||
def parse_owner_from_xml(xml)
|
def parse_owner_from_xml(xml)
|
||||||
doc = Nokogiri::XML(xml) { |cfg| cfg.noblanks }
|
doc = Nokogiri::XML(xml) { |cfg| cfg.noblanks }
|
||||||
email = doc.xpath("//person/email").text.to_s
|
email = doc.xpath("//person/email").text.to_s
|
||||||
|
|
@ -57,8 +71,13 @@ module Diaspora
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def push_to(recipients)
|
def subscribe_to_ostatus(feed_url)
|
||||||
|
puts feed_url
|
||||||
|
@@queue.add_subscription_request(feed_url)
|
||||||
|
@@queue.process
|
||||||
|
end
|
||||||
|
|
||||||
|
def push_to(recipients)
|
||||||
@@queue.add_hub_notification(APP_CONFIG[:pubsub_server], User.owner.url + self.class.to_s.pluralize.underscore + '.atom')
|
@@queue.add_hub_notification(APP_CONFIG[:pubsub_server], User.owner.url + self.class.to_s.pluralize.underscore + '.atom')
|
||||||
|
|
||||||
unless recipients.empty?
|
unless recipients.empty?
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
class MessageHandler
|
class MessageHandler
|
||||||
|
|
||||||
|
|
||||||
NUM_TRIES = 3
|
NUM_TRIES = 3
|
||||||
TIMEOUT = 5 #seconds
|
TIMEOUT = 5 #seconds
|
||||||
|
|
||||||
|
|
@ -11,14 +12,29 @@ class MessageHandler
|
||||||
destinations.each{ |dest| @queue.push(Message.new(:get, dest))}
|
destinations.each{ |dest| @queue.push(Message.new(:get, dest))}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def add_subscription_request(feed_url)
|
||||||
|
@queue.push(Message.new(:ostatus_subscribe, feed_url))
|
||||||
|
end
|
||||||
|
|
||||||
def add_post_request(destinations, body)
|
def add_post_request(destinations, body)
|
||||||
b = CGI::escape( body )
|
b = CGI::escape( body )
|
||||||
destinations.each{|dest| @queue.push(Message.new(:post, dest, b))}
|
destinations.each{|dest| @queue.push(Message.new(:post, dest, :body => b))}
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_hub_notification(destination, feed_location)
|
# pubsubhubbub
|
||||||
@queue.push(Message.new(:pubhub, destination, feed_location))
|
def add_hub_notification(hub_url, feed_url)
|
||||||
|
@queue.push(Message.new(:hub_publish, hub_url, :body => feed_url))
|
||||||
|
end
|
||||||
|
|
||||||
|
def add_hub_subscription_request(hub_url, feed_url)
|
||||||
|
@queue.push(Message.new(:hub_subscribe, hub_url, :body => feed_url))
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def process_ostatus_subscription(query_object, http)
|
||||||
|
hub = Diaspora::OStatusParser::find_hub(http.response)
|
||||||
|
add_hub_subscription_request(hub, query_object.destination)
|
||||||
|
Diaspora::OStatusParser::parse_sender(http.response)
|
||||||
end
|
end
|
||||||
|
|
||||||
def process
|
def process
|
||||||
|
|
@ -26,13 +42,23 @@ class MessageHandler
|
||||||
case query.type
|
case query.type
|
||||||
when :post
|
when :post
|
||||||
http = EventMachine::HttpRequest.new(query.destination).post :timeout => TIMEOUT, :body =>{:xml => query.body}
|
http = EventMachine::HttpRequest.new(query.destination).post :timeout => TIMEOUT, :body =>{:xml => query.body}
|
||||||
http.callback { puts query.destination; process; process}
|
http.callback { puts query.destination; process; process}
|
||||||
when :get
|
when :get
|
||||||
http = EventMachine::HttpRequest.new(query.destination).get :timeout => TIMEOUT
|
http = EventMachine::HttpRequest.new(query.destination).get :timeout => TIMEOUT
|
||||||
http.callback {send_to_seed(query, http.response); process}
|
http.callback {send_to_seed(query, http.response); process}
|
||||||
when :pubhub
|
|
||||||
|
when :ostatus_subscribe
|
||||||
|
puts query.destination
|
||||||
|
http = EventMachine::HttpRequest.new(query.destination).get :timeout => TIMEOUT
|
||||||
|
http.callback { process_ostatus_subscription(query, http); process}
|
||||||
|
|
||||||
|
when :hub_publish
|
||||||
http = EventMachine::PubSubHubbub.new(query.destination).publish query.body, :timeout => TIMEOUT
|
http = EventMachine::PubSubHubbub.new(query.destination).publish query.body, :timeout => TIMEOUT
|
||||||
http.callback { process}
|
http.callback { process}
|
||||||
|
|
||||||
|
when :hub_subscribe
|
||||||
|
http = EventMachine::PubSubHubbub.new(query.destination).subscribe query.body, User.owner.url, :timeout => TIMEOUT
|
||||||
|
http.callback { process}
|
||||||
else
|
else
|
||||||
raise "message is not a type I know!"
|
raise "message is not a type I know!"
|
||||||
end
|
end
|
||||||
|
|
@ -56,11 +82,12 @@ class MessageHandler
|
||||||
end
|
end
|
||||||
|
|
||||||
class Message
|
class Message
|
||||||
attr_accessor :type, :destination, :body, :try_count
|
attr_accessor :type, :destination, :body, :callback, :try_count
|
||||||
def initialize(type, dest, body= nil)
|
def initialize(type, dest, opts = {})
|
||||||
@type = type
|
@type = type
|
||||||
@destination = dest
|
@destination = dest
|
||||||
@body = body
|
@body = opts[:body]
|
||||||
|
@callback = opts[:callback] ||= lambda{ process; process }
|
||||||
@try_count = 0
|
@try_count = 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
166
spec/fixtures/identica_feed.atom
vendored
Normal file
166
spec/fixtures/identica_feed.atom
vendored
Normal file
|
|
@ -0,0 +1,166 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:georss="http://www.georss.org/georss" xmlns:activity="http://activitystrea.ms/spec/1.0/" xmlns:media="http://purl.org/syndication/atommedia" xmlns:poco="http://portablecontacts.net/spec/1.0" xmlns:ostatus="http://ostatus.org/schema/1.0" xmlns:statusnet="http://status.net/schema/api/1/">
|
||||||
|
<generator uri="http://status.net" version="0.9.3">StatusNet</generator>
|
||||||
|
<id>http://identi.ca/api/statuses/user_timeline/169966.atom</id>
|
||||||
|
<title>joindiaspora timeline</title>
|
||||||
|
<subtitle>Updates from joindiaspora on Identi.ca!</subtitle>
|
||||||
|
<logo>http://avatar.identi.ca/169966-96-20100426170852.png</logo>
|
||||||
|
<updated>2010-07-22T01:00:38+00:00</updated>
|
||||||
|
<author>
|
||||||
|
<name>joindiaspora</name>
|
||||||
|
<uri>http://identi.ca/user/169966</uri>
|
||||||
|
</author>
|
||||||
|
<link href="http://identi.ca/joindiaspora" rel="alternate" type="text/html"/>
|
||||||
|
<link href="http://identi.ca/main/sup#169966" rel="http://api.friendfeed.com/2008/03#sup" type="application/json"/>
|
||||||
|
<link href="http://identi.ca/main/push/hub" rel="hub"/>
|
||||||
|
<link href="http://identi.ca/main/salmon/user/169966" rel="http://salmon-protocol.org/ns/salmon-replies"/>
|
||||||
|
<link href="http://identi.ca/main/salmon/user/169966" rel="http://salmon-protocol.org/ns/salmon-mention"/>
|
||||||
|
<link href="http://identi.ca/api/statuses/user_timeline/169966.atom" rel="self" type="application/atom+xml"/>
|
||||||
|
<activity:subject>
|
||||||
|
<activity:object-type>http://activitystrea.ms/schema/1.0/person</activity:object-type>
|
||||||
|
<id>http://identi.ca/user/169966</id>
|
||||||
|
<title>Diaspora</title>
|
||||||
|
<link rel="alternate" type="text/html" href="http://identi.ca/joindiaspora"/>
|
||||||
|
<link rel="avatar" type="image/png" media:width="480" media:height="480" href="http://avatar.identi.ca/169966-480-20100426170851.png"/>
|
||||||
|
<link rel="avatar" type="image/png" media:width="96" media:height="96" href="http://avatar.identi.ca/169966-96-20100426170852.png"/>
|
||||||
|
<link rel="avatar" type="image/png" media:width="48" media:height="48" href="http://avatar.identi.ca/169966-48-20100426170852.png"/>
|
||||||
|
<link rel="avatar" type="image/png" media:width="24" media:height="24" href="http://avatar.identi.ca/169966-24-20100426170852.png"/>
|
||||||
|
<poco:preferredUsername>joindiaspora</poco:preferredUsername>
|
||||||
|
<poco:displayName>Diaspora</poco:displayName>
|
||||||
|
<poco:note>Diaspora is an awesome, distributed, open source social network in the making from some young hackers at NYU</poco:note>
|
||||||
|
<poco:urls>
|
||||||
|
<poco:type>homepage</poco:type>
|
||||||
|
<poco:value>http://joindiaspora.com</poco:value>
|
||||||
|
<poco:primary>true</poco:primary>
|
||||||
|
</poco:urls>
|
||||||
|
</activity:subject>
|
||||||
|
<entry>
|
||||||
|
<title>A month of Diaspora in action. First screenshots/video! http://bit.ly/clOFXx</title>
|
||||||
|
<link rel="alternate" type="text/html" href="http://identi.ca/notice/39231942"/>
|
||||||
|
<id>http://identi.ca/notice/39231942</id>
|
||||||
|
<published>2010-07-02T06:13:11+00:00</published>
|
||||||
|
<updated>2010-07-02T06:13:11+00:00</updated>
|
||||||
|
<statusnet:notice_info local_id="39231942" source="web" favorite="false" repeated="false"></statusnet:notice_info>
|
||||||
|
<link rel="ostatus:conversation" href="http://identi.ca/conversation/38985291"/>
|
||||||
|
<content type="html">A month of Diaspora in action. First screenshots/video! <a href="http://bit.ly/clOFXx" title="http://www.joindiaspora.com/2010/07/01/one-month-in.html" rel="external">http://bit.ly/clOFXx</a></content>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<title>http://www.reclaimprivacy.org/ check your FB privacy settings, automagically! !whyisntthisbuiltintofacebook :)</title>
|
||||||
|
<link rel="alternate" type="text/html" href="http://identi.ca/notice/32556574"/>
|
||||||
|
<id>http://identi.ca/notice/32556574</id>
|
||||||
|
<published>2010-05-17T18:18:28+00:00</published>
|
||||||
|
<updated>2010-05-17T18:18:28+00:00</updated>
|
||||||
|
<statusnet:notice_info local_id="32556574" source="web" favorite="false" repeated="false"></statusnet:notice_info>
|
||||||
|
<link rel="ostatus:conversation" href="http://identi.ca/conversation/32429253"/>
|
||||||
|
<content type="html"><a href="http://www.reclaimprivacy.org/" title="http://www.reclaimprivacy.org/" rel="external">http://www.reclaimprivacy.org/</a> check your FB privacy settings, automagically! !whyisntthisbuiltintofacebook :)</content>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<title>@cacheson, should already be there, at http://joindiaspora.com/atom.xml... hopefully that will do the trick...</title>
|
||||||
|
<link rel="alternate" type="text/html" href="http://identi.ca/notice/31824813"/>
|
||||||
|
<id>http://identi.ca/notice/31824813</id>
|
||||||
|
<published>2010-05-11T14:29:38+00:00</published>
|
||||||
|
<updated>2010-05-11T14:29:38+00:00</updated>
|
||||||
|
<statusnet:notice_info local_id="31824813" source="web" favorite="false" repeated="false"></statusnet:notice_info>
|
||||||
|
<link rel="ostatus:conversation" href="http://identi.ca/conversation/31712301"/>
|
||||||
|
<link rel="ostatus:attention" href="http://identi.ca/user/47185"/>
|
||||||
|
<content type="html">@<span class="vcard"><a href="http://identi.ca/user/47185" class="url" title="Chris Acheson"><span class="fn nickname">cacheson</span></a></span>, should already be there, at <a href="http://joindiaspora.com/atom.xml" title="http://joindiaspora.com/atom.xml" rel="external" class="attachment" id="attachment-15490501">http://joindiaspora.com/atom.xml</a>... hopefully that will do the trick...</content>
|
||||||
|
<link rel="enclosure" href="http://joindiaspora.com/atom.xml" type="application/xml" length="31902"/>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<title>@elmom, thanks for your support. we are excited to get started. helsinki is awesome, I hope to go back one day! good luck w/hackerspace!</title>
|
||||||
|
<link rel="alternate" type="text/html" href="http://identi.ca/notice/30760606"/>
|
||||||
|
<id>http://identi.ca/notice/30760606</id>
|
||||||
|
<published>2010-05-02T07:06:02+00:00</published>
|
||||||
|
<updated>2010-05-02T07:06:02+00:00</updated>
|
||||||
|
<statusnet:notice_info local_id="30760606" source="web" favorite="false" repeated="false"></statusnet:notice_info>
|
||||||
|
<link rel="ostatus:conversation" href="http://identi.ca/conversation/30668263"/>
|
||||||
|
<link rel="ostatus:attention" href="http://identi.ca/user/101533"/>
|
||||||
|
<content type="html">@<span class="vcard"><a href="http://identi.ca/user/101533" class="url" title="Elmo M&#xE4;ntynen"><span class="fn nickname">elmom</span></a></span>, thanks for your support. we are excited to get started. helsinki is awesome, I hope to go back one day! good luck w/hackerspace!</content>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<title>@tieguy, thanks for the great feedback, here is our response: http://bit.ly/aF2Fpl</title>
|
||||||
|
<link rel="alternate" type="text/html" href="http://identi.ca/notice/30549323"/>
|
||||||
|
<id>http://identi.ca/notice/30549323</id>
|
||||||
|
<published>2010-04-30T06:29:28+00:00</published>
|
||||||
|
<updated>2010-04-30T06:29:28+00:00</updated>
|
||||||
|
<statusnet:notice_info local_id="30549323" source="web" favorite="false" repeated="false"></statusnet:notice_info>
|
||||||
|
<link rel="ostatus:conversation" href="http://identi.ca/conversation/30461403"/>
|
||||||
|
<link rel="ostatus:attention" href="http://identi.ca/user/11"/>
|
||||||
|
<content type="html">@<span class="vcard"><a href="http://identi.ca/user/11" class="url" title="Luis Villa"><span class="fn nickname">tieguy</span></a></span>, thanks for the great feedback, here is our response: <a href="http://bit.ly/aF2Fpl" title="http://joindiaspora.com/2010/04/30/a-response-to-mr-villa.html" rel="external">http://bit.ly/aF2Fpl</a></content>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<title>RT @tieguy @joindiaspora hopefully constructive questions for you: http://ur1.ca/xbvq cc: @mlinksva @rejon @biella@brainbird.net</title>
|
||||||
|
<link rel="alternate" type="text/html" href="http://identi.ca/notice/30154486"/>
|
||||||
|
<id>http://identi.ca/notice/30154486</id>
|
||||||
|
<published>2010-04-27T06:22:14+00:00</published>
|
||||||
|
<updated>2010-04-27T06:22:14+00:00</updated>
|
||||||
|
<statusnet:notice_info local_id="30154486" source="web" favorite="false" repeated="false" repeat_of="30152015"></statusnet:notice_info>
|
||||||
|
<link rel="ostatus:conversation" href="http://identi.ca/conversation/30076242"/>
|
||||||
|
<ostatus:forward ref="http://identi.ca/notice/30152015" href="http://identi.ca/notice/30152015"></ostatus:forward>
|
||||||
|
<content type="html">RT @<span class="vcard"><a href="http://identi.ca/user/11" class="url" title="Luis Villa"><span class="fn nickname">tieguy</span></a></span> @<span class="vcard"><a href="http://identi.ca/user/169966" class="url" title="Diaspora"><span class="fn nickname">joindiaspora</span></a></span> hopefully constructive questions for you: <a href="http://ur1.ca/xbvq" title="http://tieguy.org/blog/2010/04/27/questions-for-the-diaspora/" rel="external">http://ur1.ca/xbvq</a> cc: @<span class="vcard"><a href="http://identi.ca/user/8" class="url" title="Mike Linksvayer"><span class="fn nickname">mlinksva</span></a></span> @<span class="vcard"><a href="http://identi.ca/user/37" class="url" title="Jon Phillips"><span class="fn nickname">rejon</span></a></span> @<span class="vcard"><a href="http://brainbird.net/biella" class="url"><span class="fn nickname">biella@brainbird.net</span></a></span></content>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<title>@tieguy it's on! ;) we have already thought about much of your comments, but give us a day or two to give you a good response.</title>
|
||||||
|
<link rel="alternate" type="text/html" href="http://identi.ca/notice/30152694"/>
|
||||||
|
<id>http://identi.ca/notice/30152694</id>
|
||||||
|
<published>2010-04-27T06:04:30+00:00</published>
|
||||||
|
<updated>2010-04-27T06:04:30+00:00</updated>
|
||||||
|
<statusnet:notice_info local_id="30152694" source="web" favorite="false" repeated="false"></statusnet:notice_info>
|
||||||
|
<link rel="ostatus:conversation" href="http://identi.ca/conversation/30074469"/>
|
||||||
|
<link rel="ostatus:attention" href="http://identi.ca/user/11"/>
|
||||||
|
<content type="html">@<span class="vcard"><a href="http://identi.ca/user/11" class="url" title="Luis Villa"><span class="fn nickname">tieguy</span></a></span> it's on! ;) we have already thought about much of your comments, but give us a day or two to give you a good response.</content>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<title>@mattkatz00 we really appreciate your kickstarter backing!</title>
|
||||||
|
<link rel="alternate" type="text/html" href="http://identi.ca/notice/30089749"/>
|
||||||
|
<id>http://identi.ca/notice/30089749</id>
|
||||||
|
<published>2010-04-26T19:32:19+00:00</published>
|
||||||
|
<updated>2010-04-26T19:32:19+00:00</updated>
|
||||||
|
<statusnet:notice_info local_id="30089749" source="web" favorite="false" repeated="false"></statusnet:notice_info>
|
||||||
|
<link rel="ostatus:conversation" href="http://identi.ca/conversation/30012647"/>
|
||||||
|
<content type="html">@mattkatz00 we really appreciate your kickstarter backing!</content>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<title>@danlatorre many thanks for your backing and support!</title>
|
||||||
|
<link rel="alternate" type="text/html" href="http://identi.ca/notice/30089410"/>
|
||||||
|
<id>http://identi.ca/notice/30089410</id>
|
||||||
|
<published>2010-04-26T19:29:27+00:00</published>
|
||||||
|
<updated>2010-04-26T19:29:27+00:00</updated>
|
||||||
|
<statusnet:notice_info local_id="30089410" source="web" favorite="false" repeated="false"></statusnet:notice_info>
|
||||||
|
<link rel="ostatus:conversation" href="http://identi.ca/conversation/30012313"/>
|
||||||
|
<link rel="ostatus:attention" href="http://identi.ca/user/16365"/>
|
||||||
|
<content type="html">@<span class="vcard"><a href="http://identi.ca/user/16365" class="url" title="Daniel Latorre"><span class="fn nickname">danlatorre</span></a></span> many thanks for your backing and support!</content>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<title>@adwilliamson thanks for backing diaspora!</title>
|
||||||
|
<link rel="alternate" type="text/html" href="http://identi.ca/notice/30089220"/>
|
||||||
|
<id>http://identi.ca/notice/30089220</id>
|
||||||
|
<published>2010-04-26T19:27:36+00:00</published>
|
||||||
|
<updated>2010-04-26T19:27:36+00:00</updated>
|
||||||
|
<statusnet:notice_info local_id="30089220" source="web" favorite="false" repeated="false"></statusnet:notice_info>
|
||||||
|
<link rel="ostatus:conversation" href="http://identi.ca/conversation/30012129"/>
|
||||||
|
<content type="html">@adwilliamson thanks for backing diaspora!</content>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<title>@thisisparker many thanks for your kickstarter backing!</title>
|
||||||
|
<link rel="alternate" type="text/html" href="http://identi.ca/notice/30088868"/>
|
||||||
|
<id>http://identi.ca/notice/30088868</id>
|
||||||
|
<published>2010-04-26T19:23:51+00:00</published>
|
||||||
|
<updated>2010-04-26T19:23:51+00:00</updated>
|
||||||
|
<statusnet:notice_info local_id="30088868" source="web" favorite="false" repeated="false"></statusnet:notice_info>
|
||||||
|
<link rel="ostatus:conversation" href="http://identi.ca/conversation/30011788"/>
|
||||||
|
<link rel="ostatus:attention" href="http://identi.ca/user/27657"/>
|
||||||
|
<content type="html">@<span class="vcard"><a href="http://identi.ca/user/27657" class="url" title="Parker Higgins"><span class="fn nickname">thisisparker</span></a></span> many thanks for your kickstarter backing!</content>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<title>We'll be building the interface for Diaspora to StatusNet, but for now, this will be from the web!</title>
|
||||||
|
<link rel="alternate" type="text/html" href="http://identi.ca/notice/30074166"/>
|
||||||
|
<id>http://identi.ca/notice/30074166</id>
|
||||||
|
<published>2010-04-26T17:07:49+00:00</published>
|
||||||
|
<updated>2010-04-26T17:07:49+00:00</updated>
|
||||||
|
<statusnet:notice_info local_id="30074166" source="web" favorite="false" repeated="false"></statusnet:notice_info>
|
||||||
|
<link rel="ostatus:conversation" href="http://identi.ca/conversation/29997414"/>
|
||||||
|
<content type="html">We'll be building the interface for Diaspora to StatusNet, but for now, this will be from the web!</content>
|
||||||
|
</entry>
|
||||||
|
</feed>
|
||||||
|
|
||||||
|
|
@ -131,6 +131,83 @@ describe MessageHandler do
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'ostatus_subscribe' do
|
||||||
|
it 'should be able to add a GET query to the queue with required destinations' do
|
||||||
|
request = FakeHttpRequest.new(:success)
|
||||||
|
request.should_receive(:get).exactly(1).times.and_return(request)
|
||||||
|
request.stub!(:callback).and_return(true)
|
||||||
|
|
||||||
|
EventMachine::HttpRequest.stub!(:new).and_return(request)
|
||||||
|
|
||||||
|
EventMachine.run{
|
||||||
|
@handler.add_subscription_request("http://evan.status.net/")
|
||||||
|
@handler.size.should == 1
|
||||||
|
|
||||||
|
@handler.process
|
||||||
|
EventMachine.stop
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'hub_publish' do
|
||||||
|
it 'should correctly queue up a pubsubhub publish request' do
|
||||||
|
destination = "http://identi.ca/hub/"
|
||||||
|
feed_location = "http://google.com/"
|
||||||
|
|
||||||
|
EventMachine.run {
|
||||||
|
@handler.add_hub_notification(destination, feed_location)
|
||||||
|
q = @handler.instance_variable_get(:@queue)
|
||||||
|
|
||||||
|
message = ""
|
||||||
|
q.pop{|m| message = m}
|
||||||
|
|
||||||
|
message.destination.should == destination
|
||||||
|
message.body.should == feed_location
|
||||||
|
|
||||||
|
EventMachine.stop
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should notify the hub about new content' do
|
||||||
|
request = FakeHttpRequest.new(:success)
|
||||||
|
request.should_receive(:publish).exactly(1).times.and_return(request)
|
||||||
|
EventMachine::PubSubHubbub.stub!(:new).and_return(request)
|
||||||
|
|
||||||
|
EventMachine.run {
|
||||||
|
@handler.add_hub_notification("http://identi.ca/hub", "http://google.com/feed")
|
||||||
|
@handler.size.should == 1
|
||||||
|
@handler.process
|
||||||
|
@handler.size.should == 0
|
||||||
|
EventMachine.stop
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'hub_subscribe' do
|
||||||
|
|
||||||
|
it 'should process an ostatus subscription' do
|
||||||
|
request = FakeHttpRequest.new(:success)
|
||||||
|
|
||||||
|
Diaspora::OStatusParser.stub!(:find_hub).and_return("http://hub.google.com")
|
||||||
|
MessageHandler.stub!(:add_hub_subscription_request).and_return(true)
|
||||||
|
|
||||||
|
Diaspora::OStatusParser.stub!(:parse_sender)
|
||||||
|
Diaspora::OStatusParser.should_receive(:find_hub)
|
||||||
|
@handler.should_receive(:add_hub_subscription_request)
|
||||||
|
Diaspora::OStatusParser.should_receive(:parse_sender)
|
||||||
|
|
||||||
|
g = mock("Message")
|
||||||
|
g.stub!(:destination).and_return("google")
|
||||||
|
|
||||||
|
@handler.process_ostatus_subscription(g, request)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
class FakeHttpRequest
|
class FakeHttpRequest
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
require File.dirname(__FILE__) + '/../spec_helper'
|
require File.dirname(__FILE__) + '/../spec_helper'
|
||||||
|
|
||||||
include ApplicationHelper
|
include ApplicationHelper
|
||||||
|
include Diaspora::OStatusParser
|
||||||
|
|
||||||
describe "parser in application helper" do
|
describe "parser in application helper" do
|
||||||
before do
|
before do
|
||||||
|
|
@ -59,6 +60,15 @@ describe "parser in application helper" do
|
||||||
Post.count.should == 0
|
Post.count.should == 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'ostatus parsing' do
|
||||||
|
it 'should be able to get the hub of an ostatus feed' do
|
||||||
|
xml_path = File.dirname(__FILE__) + '/../fixtures/identica_feed.atom'
|
||||||
|
xml = File.open(xml_path).read
|
||||||
|
|
||||||
|
Diaspora::OStatusParser::find_hub(xml).should == 'http://identi.ca/main/push/hub'
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
describe "parsing compliant XML object" do
|
describe "parsing compliant XML object" do
|
||||||
before do
|
before do
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,6 @@ describe User do
|
||||||
@user.send_friend_request_to( @friend.url ).should be nil
|
@user.send_friend_request_to( @friend.url ).should be nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
it 'should be able to give me the terse url for webfinger' do
|
it 'should be able to give me the terse url for webfinger' do
|
||||||
user = Factory.create(:user)
|
user = Factory.create(:user)
|
||||||
user.terse_url.should == 'example.com'
|
user.terse_url.should == 'example.com'
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue