more tests pass
This commit is contained in:
parent
1e349e6a61
commit
6d139ab946
4 changed files with 52 additions and 33 deletions
|
|
@ -54,12 +54,17 @@ class RequestsController < ApplicationController
|
|||
#socket to tell people this failed?
|
||||
end
|
||||
}
|
||||
|
||||
rescue Exception => e
|
||||
flash[:error] = e.message
|
||||
end
|
||||
|
||||
|
||||
if params[:getting_started]
|
||||
redirect_to getting_started_path(:step=>params[:getting_started])
|
||||
else
|
||||
flash[:notice] = "we tried our best to send a message to #{account}" unless flash[:error]
|
||||
redirect_to aspects_manage_path
|
||||
respond_with :location => aspects_manage_path
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -20,6 +20,23 @@ module Diaspora
|
|||
Rails.logger.debug("Receiving object for #{self.real_name}:\n#{object.inspect}")
|
||||
Rails.logger.debug("From: #{object.person.inspect}") if object.person
|
||||
|
||||
|
||||
if object.is_a?(Comment)
|
||||
e = EMWebfinger.new(object.diaspora_handle)
|
||||
|
||||
e.on_person { |person|
|
||||
|
||||
if person.class == Person
|
||||
sender_in_xml = sender(object, xml, person)
|
||||
if (salmon_author != sender_in_xml)
|
||||
raise "Malicious Post, #{salmon_author.real_name} with id #{salmon_author.id} is sending a #{object.class} as #{sender_in_xml.real_name} with id #{sender_in_xml.id} "
|
||||
end
|
||||
|
||||
receive_comment object, xml
|
||||
end
|
||||
}
|
||||
|
||||
else
|
||||
sender_in_xml = sender(object, xml)
|
||||
|
||||
if (salmon_author != sender_in_xml)
|
||||
|
|
@ -35,14 +52,13 @@ module Diaspora
|
|||
receive_retraction object, xml
|
||||
elsif object.is_a? Profile
|
||||
receive_profile object, xml
|
||||
elsif object.is_a?(Comment)
|
||||
receive_comment object, xml
|
||||
else
|
||||
receive_post object, xml
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def sender(object, xml)
|
||||
def sender(object, xml, webfingered_person = nil)
|
||||
if object.is_a? Retraction
|
||||
sender = object.person
|
||||
elsif object.is_a? Request
|
||||
|
|
@ -50,7 +66,7 @@ module Diaspora
|
|||
elsif object.is_a? Profile
|
||||
sender = Diaspora::Parser.owner_id_from_xml xml
|
||||
elsif object.is_a?(Comment)
|
||||
object.person = Person.by_webfinger(object.diaspora_handle)
|
||||
object.person = webfingered_person
|
||||
sender = (owns?(object.post))? object.person : object.post.person
|
||||
else
|
||||
sender = object.person
|
||||
|
|
|
|||
|
|
@ -9,8 +9,7 @@ class EMWebfinger
|
|||
# Raise an error if identifier has a port number
|
||||
raise "Identifier is invalid" if(@account.strip.match(/\:\d+$/))
|
||||
# Raise an error if identifier is not a valid email (generous regexp)
|
||||
raise "Identifier is invalid" if !(@account=~ /\A.*\@.*\..*\Z/)
|
||||
end
|
||||
raise "Identifier is invalid" if !(@account=~ /^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/)
|
||||
|
||||
def fetch
|
||||
raise 'you need to set a callback before calling fetch' if @callbacks.empty?
|
||||
|
|
|
|||
|
|
@ -73,7 +73,6 @@ describe Comment do
|
|||
it 'should send a comment a person made on your post to all people' do
|
||||
comment = Comment.new(:person_id => @person.id, :diaspora_handle => @person.diaspora_handle, :text => "cats", :post => @user_status)
|
||||
User::QUEUE.should_receive(:add_post_request).twice
|
||||
Person.should_receive(:by_webfinger).and_return(@person)
|
||||
user.receive comment.to_diaspora_xml, @person
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue