DG MS fixing webfinger, i hope to goodness

This commit is contained in:
maxwell 2010-09-15 13:28:06 -07:00
parent 57bd052c5b
commit 84c60e5f2e
16 changed files with 34 additions and 33 deletions

View file

@ -3,7 +3,7 @@
The privacy aware, personally controlled, do-it-all, open source social network. The privacy aware, personally controlled, do-it-all, open source social network.
**DISCLAIMER: THIS IS PRE-ALPHA SOFTWARE AND SHOULD BE TREATED ACCORDINGLY.** **DISCLAIMER: THIS IS PRE-ALPHA SOFTWARE AND SHOULD BE TREATED ACCORDINGLY.**
These instructions are for machines running [Ubuntu](http://www.ubuntu.com/) or Mac OS X. These instructions are for machines running [Ubuntu](http://www.ubuntu.com/) or Mac OS X. We are developing Diaspora for the latest and greatest browsers, so please update your Firefox, Chrome or Safari to the latest and greatest.
## Preparing your system ## Preparing your system
In order to run Diaspora, you will need to download the following dependencies (specific instructions follow): In order to run Diaspora, you will need to download the following dependencies (specific instructions follow):

View file

@ -11,13 +11,13 @@ class Person
include Encryptor::Public include Encryptor::Public
xml_accessor :_id xml_accessor :_id
xml_accessor :email xml_accessor :diaspora_handle
xml_accessor :url xml_accessor :url
xml_accessor :profile, :as => Profile xml_accessor :profile, :as => Profile
xml_reader :exported_key xml_reader :exported_key
key :url, String key :url, String
key :email, String, :unique => true key :diaspora_handle, String, :unique => true
key :serialized_key, String key :serialized_key, String
key :owner_id, ObjectId key :owner_id, ObjectId
@ -30,13 +30,13 @@ class Person
before_destroy :remove_all_traces before_destroy :remove_all_traces
before_validation :clean_url before_validation :clean_url
validates_presence_of :email, :url, :profile, :serialized_key validates_presence_of :diaspora_handle, :url, :profile, :serialized_key
validates_format_of :url, :with => validates_format_of :url, :with =>
/^(https?):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*(\.[a-z]{2,5})?(:[0-9]{1,5})?(\/.*)?$/ix /^(https?):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*(\.[a-z]{2,5})?(:[0-9]{1,5})?(\/.*)?$/ix
def self.search(query) def self.search(query)
Person.all('$where' => "function() { return this.email.match(/^#{query}/i) || Person.all('$where' => "function() { return this.diaspora_handle.match(/^#{query}/i) ||
this.profile.first_name.match(/^#{query}/i) || this.profile.first_name.match(/^#{query}/i) ||
this.profile.last_name.match(/^#{query}/i); }") this.profile.last_name.match(/^#{query}/i); }")
end end
@ -79,7 +79,8 @@ class Person
end end
def self.by_webfinger( identifier ) def self.by_webfinger( identifier )
local_person = Person.first(:email => identifier.gsub('acct:', '')) local_person = Person.first(:diaspora_handle => identifier.gsub('acct:', ''))
if local_person if local_person
local_person local_person
elsif !identifier.include?("localhost") elsif !identifier.include?("localhost")
@ -102,7 +103,7 @@ class Person
guid = profile.links.select{|x| x.rel == 'http://joindiaspora.com/guid'}.first.href guid = profile.links.select{|x| x.rel == 'http://joindiaspora.com/guid'}.first.href
new_person.id = guid new_person.id = guid
new_person.email = identifier new_person.diaspora_handle = identifier
hcard = HCard.find profile.hcard.first[:href] hcard = HCard.find profile.hcard.first[:href]
@ -124,7 +125,7 @@ class Person
:person => { :person => {
:id => self.id, :id => self.id,
:name => self.real_name, :name => self.real_name,
:email => self.email, :diaspora_handle => self.diaspora_handle,
:url => self.url, :url => self.url,
:exported_key => exported_key :exported_key => exported_key
} }

View file

@ -305,7 +305,7 @@ class User
def setup_person def setup_person
self.person.serialized_key ||= User.generate_key.export self.person.serialized_key ||= User.generate_key.export
self.person.email ||= email self.person.diaspora_handle ||= self.diaspora_handle
self.person.save! self.person.save!
end end

View file

@ -18,7 +18,7 @@
%table %table
%tr %tr
%th real name %th real name
%th email %th diaspora handle
%th url %th url
- for person in @people - for person in @people
%tr %tr
@ -27,7 +27,7 @@
- else - else
%td= person.real_name %td= person.real_name
%td= person.email %td= person.diaspora_handle
%td= person.url %td= person.url
-if current_user.friends.include? person -if current_user.friends.include? person
@ -46,5 +46,5 @@
%td %td
= form_for Request.new do |f| = form_for Request.new do |f|
= f.select(:aspect_id, @aspects_dropdown_array) = f.select(:aspect_id, @aspects_dropdown_array)
= f.hidden_field :destination_url, :value => person.email = f.hidden_field :destination_url, :value => person.diaspora_handle
= f.submit "add friend" = f.submit "add friend"

View file

@ -8,9 +8,9 @@
= form_for @person do |f| = form_for @person do |f|
= f.error_messages = f.error_messages
%p %p
= f.label :email = f.label :diaspora_handle
%br %br
= f.text_field :email = f.text_field :diaspora_handle
%p %p
= f.label :url = f.label :url
%br %br

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0"> <XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
<Subject>acct:<%=@person.email%></Subject> <Subject>acct:<%=@person.diaspora_handle%></Subject>
<Alias>"<%= @person.url %>"</Alias> <Alias>"<%= @person.url %>"</Alias>
<Link rel="http://microformats.org/profile/hcard" type="text/html" href="<%=@person.url%>hcard/users/<%=@person.id%>"/> <Link rel="http://microformats.org/profile/hcard" type="text/html" href="<%=@person.url%>hcard/users/<%=@person.id%>"/>
<Link rel="http://joindiaspora.com/seed_location" type = 'text/html' href="<%=@person.url%>"/> <Link rel="http://joindiaspora.com/seed_location" type = 'text/html' href="<%=@person.url%>"/>

View file

@ -82,7 +82,7 @@ module Salmon
<entry xmlns='http://www.w3.org/2005/Atom'> <entry xmlns='http://www.w3.org/2005/Atom'>
<author> <author>
<name>#{@author.real_name}</name> <name>#{@author.real_name}</name>
<uri>acct:#{@author.email}</uri> <uri>acct:#{@author.diaspora_handle}</uri>
</author> </author>
#{@magic_sig.to_xml} #{@magic_sig.to_xml}
</entry> </entry>

View file

@ -60,7 +60,7 @@ describe PublicsController do
end end
it 'should add the pending request to the right user if the target person does not exist locally' do it 'should add the pending request to the right user if the target person does not exist locally' do
Person.should_receive(:by_webfinger).with(@user2.person.email).and_return(@user2.person) Person.should_receive(:by_webfinger).with(@user2.person.diaspora_handle).and_return(@user2.person)
@user2.person.delete @user2.person.delete
@user2.delete @user2.delete
post :receive, :id => @user.person.id, :xml => @xml post :receive, :id => @user.person.id, :xml => @xml

View file

@ -15,7 +15,7 @@ Factory.define :profile do |p|
end end
Factory.define :person do |p| Factory.define :person do |p|
p.sequence(:email) {|n| "bob-person-#{n}@aol.com"} p.sequence(:diaspora_handle) {|n| "bob-person-#{n}@aol.com"}
p.sequence(:url) {|n| "http://google-#{n}.com/"} p.sequence(:url) {|n| "http://google-#{n}.com/"}
p.profile Factory.create(:profile) p.profile Factory.create(:profile)

View file

@ -5,7 +5,7 @@ Hash: SHA1
<message>jimmy's 1 whales</message> <message>jimmy's 1 whales</message>
<_id>4c3b7cf9312f91367f000004</_id> <_id>4c3b7cf9312f91367f000004</_id>
<person> <person>
<email>bob1@aol.com</email> <diaspora_handle>bob1@aol.com</diaspora_handle>
<url>http://www.example.com/</url> <url>http://www.example.com/</url>
<_id>4c3b7c64312f913664000005</_id> <_id>4c3b7c64312f913664000005</_id>
<key_fingerprint>0264242496D4B585297BF236BEEFE6DEBE3407AA</key_fingerprint> <key_fingerprint>0264242496D4B585297BF236BEEFE6DEBE3407AA</key_fingerprint>

View file

@ -15,7 +15,7 @@ describe Diaspora::Parser do
before do before do
@user = Factory.create(:user, :email => "bob@aol.com") @user = Factory.create(:user, :email => "bob@aol.com")
@aspect = @user.aspect(:name => 'spies') @aspect = @user.aspect(:name => 'spies')
@person = Factory.create(:person_with_private_key, :email => "bill@gates.com") @person = Factory.create(:person_with_private_key, :diaspora_handle => "bill@gates.com")
@user2 = Factory.create(:user) @user2 = Factory.create(:user)
end end
@ -25,7 +25,7 @@ describe Diaspora::Parser do
end end
it 'should be able to correctly handle comments with person in db' do it 'should be able to correctly handle comments with person in db' do
person = Factory.create(:person, :email => "test@testing.com") person = Factory.create(:person, :diaspora_handle => "test@testing.com")
post = Factory.create(:status_message, :person => @user.person) post = Factory.create(:status_message, :person => @user.person)
comment = Factory.build(:comment, :post => post, :person => person, :text => "Freedom!") comment = Factory.build(:comment, :post => post, :person => person, :text => "Freedom!")
xml = comment.to_diaspora_xml xml = comment.to_diaspora_xml
@ -49,7 +49,7 @@ describe Diaspora::Parser do
parsed_person = Diaspora::Parser::parse_or_find_person_from_xml(xml) parsed_person = Diaspora::Parser::parse_or_find_person_from_xml(xml)
parsed_person.save.should be true parsed_person.save.should be true
parsed_person.email.should == commenter.person.email parsed_person.diaspora_handle.should == commenter.person.diaspora_handle
parsed_person.profile.should_not be_nil parsed_person.profile.should_not be_nil
end end

View file

@ -35,8 +35,8 @@ describe Salmon do
@parsed_salmon.data.should == xml @parsed_salmon.data.should == xml
end end
it 'should parse out the author email' do it 'should parse out the authors diaspora_handle' do
@parsed_salmon.author_email.should == @user.person.email @parsed_salmon.author_email.should == @user.person.diaspora_handle
end end
it 'should reference a local author' do it 'should reference a local author' do

View file

@ -15,8 +15,8 @@ describe Person do
@aspect2 = @user2.aspect(:name => "Abscence of Babes") @aspect2 = @user2.aspect(:name => "Abscence of Babes")
end end
it 'should not allow two people with the same email' do it 'should not allow two people with the same diaspora_handle' do
person_two = Factory.build(:person, :url => @person.email) person_two = Factory.build(:person, :url => @person.diaspora_handle)
person_two.valid?.should == false person_two.valid?.should == false
end end
@ -147,10 +147,10 @@ describe Person do
people.include?(@friend_three).should == false people.include?(@friend_three).should == false
end end
it 'should search by email exactly' do it 'should search by diaspora_handle exactly' do
stub_success("tom@tom.joindiaspora.com") stub_success("tom@tom.joindiaspora.com")
Person.by_webfinger(@friend_one.email).should == @friend_one Person.by_webfinger(@friend_one.diaspora_handle).should == @friend_one
end end
it 'should create a stub for a remote user' do it 'should create a stub for a remote user' do

View file

@ -18,7 +18,7 @@ describe Post do
end end
it 'should serialize to xml with its person' do it 'should serialize to xml with its person' do
@message.to_xml.to_s.include?(@user.person.email).should == true @message.to_xml.to_s.include?(@user.person.diaspora_handle).should == true
end end
end end

View file

@ -25,14 +25,14 @@ describe Request do
xml = request.to_xml.to_s xml = request.to_xml.to_s
xml.include?(@user.person.email).should be true xml.include?(@user.person.diaspora_handle).should be true
xml.include?(@user.url).should be true xml.include?(@user.url).should be true
xml.include?(@user.profile.first_name).should be true xml.include?(@user.profile.first_name).should be true
xml.include?(@user.profile.last_name).should be true xml.include?(@user.profile.last_name).should be true
end end
it 'should allow me to see only friend requests sent to me' do it 'should allow me to see only friend requests sent to me' do
remote_person = Factory.build(:person, :email => "robert@grimm.com", :url => "http://king.com/") remote_person = Factory.build(:person, :diaspora_handle => "robert@grimm.com", :url => "http://king.com/")
Request.instantiate(:into => @aspect.id, :from => @user.person, :to => remote_person.receive_url).save Request.instantiate(:into => @aspect.id, :from => @user.person, :to => remote_person.receive_url).save
Request.instantiate(:into => @aspect.id, :from => @user.person, :to => remote_person.receive_url).save Request.instantiate(:into => @aspect.id, :from => @user.person, :to => remote_person.receive_url).save

View file

@ -16,12 +16,12 @@ describe 'user encryption' do
@person = Factory.create(:person_with_private_key, @person = Factory.create(:person_with_private_key,
:profile => Profile.new(:first_name => 'Remote', :profile => Profile.new(:first_name => 'Remote',
:last_name => 'Friend'), :last_name => 'Friend'),
:email => 'somewhere@else.com', :diaspora_handle => 'somewhere@else.com',
:url => 'http://distant-example.com/') :url => 'http://distant-example.com/')
@person2 = Factory.create(:person_with_private_key, @person2 = Factory.create(:person_with_private_key,
:profile => Profile.new(:first_name => 'Second', :profile => Profile.new(:first_name => 'Second',
:last_name => 'Friend'), :last_name => 'Friend'),
:email => 'elsewhere@else.com', :diaspora_handle => 'elsewhere@else.com',
:url => 'http://distanter-example.com/') :url => 'http://distanter-example.com/')
end end