Skip to content
Extraits de code Groupes Projets
Valider 5701c3a8 rédigé par maxwell's avatar maxwell
Parcourir les fichiers

should send the email when a new request is received. emails in dev should be...

should send the email when a new request is received.  emails in dev should be intercepted to email@joindiaspora.com for now
parent 80cd4761
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -4,11 +4,7 @@ class Notifier < ActionMailer::Base
def new_request(recipient, sender)
@receiver = recipient
@sender = sender
mail(:to => recipient.email) do |format|
format.text { render :text => "This is text!" }
format.html { render :text => "<h1>#{@receiver.person.profile.first_name}This is HTML</h1>" }
end
mail(:to => "#{recipient.real_name} <#{recipient.email}>",
:subject => "new friend request from #{@sender.inspect}")
end
end
......@@ -46,16 +46,13 @@
= image_tag '/images/diaspora_white.png'
#container
%p
Hello #{@receiver.first_name}!
Hello #{@receiver.profile.first_name}!
%p
#{(@resource.inviters.count == 1)? ( @resource.inviters.first.real_name + " (#{@resource.inviters.first.diaspora_handle})" + " has") : (@resource.inviters.map{|inv| inv.real_name + " (#{inv.diaspora_handle})"}.join(",") + " have")} invited you to join Diaspora at #{root_url}, you can accept it through the link below.
- @resource.inviters.each do |inv|
- if @resource.invite_messages[inv.id.to_s]
= "#{inv.real_name}:"
= @resource.invite_messages[inv.id.to_s]
%p
%p= link_to 'Accept invitation', accept_invitation_url(@resource, :invitation_token => @resource.invitation_token), :class => "large_text"
%p.small
If you don't want to accept the invitation, please ignore this email.
%br/
Your account won't be created until you access the link above and sign up.
= "#{@sender.real_name} (#{@sender.diaspora_handle})"
just sent you a friend request on Diaspora*
You should really think about checking it out.
= link_to "sign in here", new_user_session_path
love,
the diaspora email robot
= "hey #{@receiver.profile.first_name},"
= "#{@sender.real_name} (#{@sender.diaspora_handle})"
just sent you a friend request on Diaspora*
You should really think about checking it out.
= "sign in here: #{new_user_session_path}"
love,
the diaspora email robot
ActionMailer::Base.register_interceptor(DevelopmentMailInterceptor) if Rails.env.development?
class DevelopmentMailInterceptor
def self.delivering_email(message)
message.subject = "[#{message.to}] #{message.subject}"
message.to = "email@joindiaspora.com"
end
end
......@@ -74,7 +74,7 @@ module Diaspora
else
self.pending_requests << friend_request
self.save
Notifier.new_request(self, friend_request.person)
Notifier.new_request(self, friend_request.person).deliver
Rails.logger.info("#{self.real_name} has received a friend request")
friend_request.save
end
......
......@@ -8,14 +8,15 @@
#This inclsion, because gpg-agent(not needed) is never run and hence never sets any env. variables on a MAC
Factory.define :profile do |p|
p.first_name "Robert"
p.last_name "Grimm"
p.sequence(:first_name){|n| "Robert#{n}"}
p.sequence(:last_name){|n| "Grimm#{n}"}
end
Factory.define :person do |p|
p.sequence(:diaspora_handle) {|n| "bob-person-#{n}@aol.com"}
p.sequence(:url) {|n| "http://google-#{n}.com/"}
p.profile Factory.create(:profile)
p.profile Factory.create(:profile, :first_name => "eugene", :last_name => "weinstien")
p.serialized_public_key OpenSSL::PKey::RSA.generate(1024).public_key.export
end
......@@ -32,7 +33,7 @@ Factory.define :user do |u|
u.password_confirmation "bluepin7"
u.serialized_private_key OpenSSL::PKey::RSA.generate(1024).export
u.after_build do |user|
user.person = Factory.build(:person, :owner_id => user._id,
user.person = Factory.build(:person, :profile => Factory.create(:profile), :owner_id => user._id,
:serialized_public_key => user.encryption_key.public_key.export,
:diaspora_handle => "#{user.username}@#{APP_CONFIG[:pod_url].gsub(/(https?:|www\.)\/\//, '').chop!}")
end
......
......@@ -3,9 +3,9 @@ require 'spec_helper'
describe Notifier do
let(:user) {Factory.create :user}
let(:person) {Factory.create :person}
let(:request_mail) {Notifier.new_request(user, person)}
let!(:user) {Factory.create :user}
let!(:person) {Factory.create :person}
let!(:request_mail) {Notifier.new_request(user, person)}
describe "#new_request" do
it 'goes to the right person' do
......@@ -13,7 +13,12 @@ describe Notifier do
end
it 'has the receivers name in the body' do
request_mail.body.encoded.includes?(user.first_name).should be true
request_mail.body.encoded.include?(user.person.profile.first_name).should be true
end
it 'has the name of person sending the request' do
request_mail.body.encoded.include?(person.real_name).should be true
end
end
end
......@@ -4,7 +4,7 @@
require 'spec_helper'
describe User do
describe "attack vectors" do
let(:user) { Factory(:user) }
let(:aspect) { user.aspect(:name => 'heroes') }
......@@ -73,10 +73,11 @@ describe User do
profile.first_name = "Not BOB"
user2.reload
user2.profile.first_name.should == "Robert"
first_name = user2.profile.first_name
proc{user.receive_salmon(user3.salmon(profile).xml_for(user.person))}.should raise_error /Malicious Post/
user2.reload
user2.profile.first_name.should == "Robert"
user2.profile.first_name.should == first_name
end
it 'should not overwrite another persons profile through comment' do
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter