diff --git a/lib/diaspora/user/receiving.rb b/lib/diaspora/user/receiving.rb index fe6b7d8c8..a16727c26 100644 --- a/lib/diaspora/user/receiving.rb +++ b/lib/diaspora/user/receiving.rb @@ -1,9 +1,8 @@ module Diaspora module UserModules module Receiving - def receive_salmon ciphertext - cleartext = decrypt( ciphertext) - salmon = Salmon::SalmonSlap.parse cleartext, self + def receive_salmon salmon_xml + salmon = Salmon::SalmonSlap.parse salmon_xml, self if salmon.verified_for_key?(salmon.author.public_key) Rails.logger.info("data in salmon: #{salmon.parsed_data}") self.receive(salmon.parsed_data) diff --git a/spec/controllers/publics_controller_spec.rb b/spec/controllers/publics_controller_spec.rb index 70d851a3e..83042ea55 100644 --- a/spec/controllers/publics_controller_spec.rb +++ b/spec/controllers/publics_controller_spec.rb @@ -5,16 +5,16 @@ require 'spec_helper' describe PublicsController do - render_views + render_views + let(:user) {Factory.create :user} before do - @user = Factory.create(:user) - sign_in :user, @user + sign_in :user, user end describe 'receive endpoint' do it 'should have a and endpoint and return a 200 on successful receipt of a request' do - post :receive, :id =>@user.person.id + post :receive, :id =>user.person.id response.code.should == '200' end @@ -22,14 +22,15 @@ describe PublicsController do user2 = Factory.create(:user) message = user2.build_post(:status_message, :message => "hi") - @user.reload - @user.visible_post_ids.include?(message.id).should be false - xml = @user.person.encrypt(user2.salmon(message, :to => @user.person).to_xml) + user.reload + user.visible_post_ids.include?(message.id).should be false + + xml = user2.salmon(message).xml_for(user.person) - post :receive, :id => @user.person.id, :xml => xml + post :receive, :id => user.person.id, :xml => xml - @user.reload - @user.visible_post_ids.include?(message.id).should be true + user.reload + user.visible_post_ids.include?(message.id).should be true end end @@ -47,9 +48,9 @@ describe PublicsController do @user3 = Factory.create(:user) - req = @user2.send_friend_request_to(@user.person, aspect) + req = @user2.send_friend_request_to(user.person, aspect) - @xml = @user.person.encrypt(@user2.salmon(req, :to => @user.person).to_xml) + @xml = @user2.salmon(req).xml_for(user.person) req.delete @user2.reload @@ -58,18 +59,18 @@ describe PublicsController do it 'should add the pending request to the right user if the target person exists locally' do @user2.delete - post :receive, :id => @user.person.id, :xml => @xml + post :receive, :id => user.person.id, :xml => @xml - assigns(:user).should eq(@user) + assigns(:user).should eq(user) 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.diaspora_handle).and_return(@user2.person) @user2.person.delete @user2.delete - post :receive, :id => @user.person.id, :xml => @xml + post :receive, :id => user.person.id, :xml => @xml - assigns(:user).should eq(@user) + assigns(:user).should eq(user) end end end