From 84c60e5f2e484a30133999a9e5d1644c3349ef5d Mon Sep 17 00:00:00 2001 From: maxwell Date: Wed, 15 Sep 2010 13:28:06 -0700 Subject: [PATCH] DG MS fixing webfinger, i hope to goodness --- README.md | 2 +- app/models/person.rb | 15 ++++++++------- app/models/user.rb | 2 +- app/views/people/index.html.haml | 6 +++--- app/views/people/new.html.haml | 4 ++-- app/views/publics/webfinger.erb | 2 +- lib/salmon/salmon.rb | 2 +- spec/controllers/publics_controller_spec.rb | 2 +- spec/factories.rb | 2 +- spec/fixtures/msg.xml.clear.asc | 2 +- spec/lib/diaspora_parser_spec.rb | 6 +++--- spec/lib/salmon_salmon_spec.rb | 4 ++-- spec/models/person_spec.rb | 8 ++++---- spec/models/post_spec.rb | 2 +- spec/models/request_spec.rb | 4 ++-- spec/user_encryption_spec.rb | 4 ++-- 16 files changed, 34 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 0cbe5a45928..85e52b7c84b 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ The privacy aware, personally controlled, do-it-all, open source social network. **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 In order to run Diaspora, you will need to download the following dependencies (specific instructions follow): diff --git a/app/models/person.rb b/app/models/person.rb index 836a810ecd3..b1aa8641d7d 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -11,13 +11,13 @@ class Person include Encryptor::Public xml_accessor :_id - xml_accessor :email + xml_accessor :diaspora_handle xml_accessor :url xml_accessor :profile, :as => Profile xml_reader :exported_key key :url, String - key :email, String, :unique => true + key :diaspora_handle, String, :unique => true key :serialized_key, String key :owner_id, ObjectId @@ -30,13 +30,13 @@ class Person before_destroy :remove_all_traces 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 => /^(https?):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*(\.[a-z]{2,5})?(:[0-9]{1,5})?(\/.*)?$/ix 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.last_name.match(/^#{query}/i); }") end @@ -79,7 +79,8 @@ def exported_key= new_key end 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 local_person elsif !identifier.include?("localhost") @@ -102,7 +103,7 @@ def self.from_webfinger_profile( identifier, profile) guid = profile.links.select{|x| x.rel == 'http://joindiaspora.com/guid'}.first.href new_person.id = guid - new_person.email = identifier + new_person.diaspora_handle = identifier hcard = HCard.find profile.hcard.first[:href] @@ -124,7 +125,7 @@ def as_json(opts={}) :person => { :id => self.id, :name => self.real_name, - :email => self.email, + :diaspora_handle => self.diaspora_handle, :url => self.url, :exported_key => exported_key } diff --git a/app/models/user.rb b/app/models/user.rb index 185c5ea5506..9eb33f2d73a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -305,7 +305,7 @@ def do_bad_things def setup_person self.person.serialized_key ||= User.generate_key.export - self.person.email ||= email + self.person.diaspora_handle ||= self.diaspora_handle self.person.save! end diff --git a/app/views/people/index.html.haml b/app/views/people/index.html.haml index 88dfef672c0..b495aef309d 100644 --- a/app/views/people/index.html.haml +++ b/app/views/people/index.html.haml @@ -18,7 +18,7 @@ %table %tr %th real name - %th email + %th diaspora handle %th url - for person in @people %tr @@ -27,7 +27,7 @@ - else %td= person.real_name - %td= person.email + %td= person.diaspora_handle %td= person.url -if current_user.friends.include? person @@ -46,5 +46,5 @@ %td = form_for Request.new do |f| = 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" diff --git a/app/views/people/new.html.haml b/app/views/people/new.html.haml index 933c267783e..66d70882a1d 100644 --- a/app/views/people/new.html.haml +++ b/app/views/people/new.html.haml @@ -8,9 +8,9 @@ = form_for @person do |f| = f.error_messages %p - = f.label :email + = f.label :diaspora_handle %br - = f.text_field :email + = f.text_field :diaspora_handle %p = f.label :url %br diff --git a/app/views/publics/webfinger.erb b/app/views/publics/webfinger.erb index f695c4c97df..47b76e6e609 100644 --- a/app/views/publics/webfinger.erb +++ b/app/views/publics/webfinger.erb @@ -1,6 +1,6 @@ - acct:<%=@person.email%> + acct:<%=@person.diaspora_handle%> "<%= @person.url %>" diff --git a/lib/salmon/salmon.rb b/lib/salmon/salmon.rb index d1a4d7a1f6d..ea25b9f9d20 100644 --- a/lib/salmon/salmon.rb +++ b/lib/salmon/salmon.rb @@ -82,7 +82,7 @@ def to_xml #{@author.real_name} - acct:#{@author.email} + acct:#{@author.diaspora_handle} #{@magic_sig.to_xml} diff --git a/spec/controllers/publics_controller_spec.rb b/spec/controllers/publics_controller_spec.rb index a49aaf6f4e9..ab7d5a6028c 100644 --- a/spec/controllers/publics_controller_spec.rb +++ b/spec/controllers/publics_controller_spec.rb @@ -60,7 +60,7 @@ end 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.delete post :receive, :id => @user.person.id, :xml => @xml diff --git a/spec/factories.rb b/spec/factories.rb index 2fc272c5fd7..374c6c76bf0 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -15,7 +15,7 @@ end 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.profile Factory.create(:profile) diff --git a/spec/fixtures/msg.xml.clear.asc b/spec/fixtures/msg.xml.clear.asc index e80a6a26f76..cf14e109be8 100644 --- a/spec/fixtures/msg.xml.clear.asc +++ b/spec/fixtures/msg.xml.clear.asc @@ -5,7 +5,7 @@ Hash: SHA1 jimmy's 1 whales <_id>4c3b7cf9312f91367f000004 - bob1@aol.com + bob1@aol.com http://www.example.com/ <_id>4c3b7c64312f913664000005 0264242496D4B585297BF236BEEFE6DEBE3407AA diff --git a/spec/lib/diaspora_parser_spec.rb b/spec/lib/diaspora_parser_spec.rb index d4cf63442cd..5fa064958ba 100644 --- a/spec/lib/diaspora_parser_spec.rb +++ b/spec/lib/diaspora_parser_spec.rb @@ -15,7 +15,7 @@ before do @user = Factory.create(:user, :email => "bob@aol.com") @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) end @@ -25,7 +25,7 @@ end 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) comment = Factory.build(:comment, :post => post, :person => person, :text => "Freedom!") xml = comment.to_diaspora_xml @@ -49,7 +49,7 @@ parsed_person = Diaspora::Parser::parse_or_find_person_from_xml(xml) 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 end diff --git a/spec/lib/salmon_salmon_spec.rb b/spec/lib/salmon_salmon_spec.rb index 4beb8786691..18854391e75 100644 --- a/spec/lib/salmon_salmon_spec.rb +++ b/spec/lib/salmon_salmon_spec.rb @@ -35,8 +35,8 @@ @parsed_salmon.data.should == xml end - it 'should parse out the author email' do - @parsed_salmon.author_email.should == @user.person.email + it 'should parse out the authors diaspora_handle' do + @parsed_salmon.author_email.should == @user.person.diaspora_handle end it 'should reference a local author' do diff --git a/spec/models/person_spec.rb b/spec/models/person_spec.rb index 05bb0a716ae..98f1c3b73dc 100644 --- a/spec/models/person_spec.rb +++ b/spec/models/person_spec.rb @@ -15,8 +15,8 @@ @aspect2 = @user2.aspect(:name => "Abscence of Babes") end - it 'should not allow two people with the same email' do - person_two = Factory.build(:person, :url => @person.email) + it 'should not allow two people with the same diaspora_handle' do + person_two = Factory.build(:person, :url => @person.diaspora_handle) person_two.valid?.should == false end @@ -147,10 +147,10 @@ people.include?(@friend_three).should == false end - it 'should search by email exactly' do + it 'should search by diaspora_handle exactly' do 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 it 'should create a stub for a remote user' do diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb index 2cb428a949b..9fe37b98e0e 100644 --- a/spec/models/post_spec.rb +++ b/spec/models/post_spec.rb @@ -18,7 +18,7 @@ end 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 diff --git a/spec/models/request_spec.rb b/spec/models/request_spec.rb index dda6a06696b..12b781b0f64 100644 --- a/spec/models/request_spec.rb +++ b/spec/models/request_spec.rb @@ -25,14 +25,14 @@ 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.profile.first_name).should be true xml.include?(@user.profile.last_name).should be true end 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 diff --git a/spec/user_encryption_spec.rb b/spec/user_encryption_spec.rb index 70cdb5683b4..08e69e561b5 100644 --- a/spec/user_encryption_spec.rb +++ b/spec/user_encryption_spec.rb @@ -16,12 +16,12 @@ @person = Factory.create(:person_with_private_key, :profile => Profile.new(:first_name => 'Remote', :last_name => 'Friend'), - :email => 'somewhere@else.com', + :diaspora_handle => 'somewhere@else.com', :url => 'http://distant-example.com/') @person2 = Factory.create(:person_with_private_key, :profile => Profile.new(:first_name => 'Second', :last_name => 'Friend'), - :email => 'elsewhere@else.com', + :diaspora_handle => 'elsewhere@else.com', :url => 'http://distanter-example.com/') end