small updates, and it looks like we are mostly working

This commit is contained in:
Maxwell Salzberg 2012-02-09 00:02:01 -08:00 committed by danielgrippi
parent 7bac633987
commit 6b97b8044b
15 changed files with 44 additions and 297 deletions

View file

@ -11,12 +11,14 @@ class AdminsController < ApplicationController
end
def admin_inviter
user = User.find_by_email params[:idenitifer]
email = params[:idenitifer]
user = User.find_by_email(email)
unless user
Invitation.create(:service => 'email', :identifier => params[:identifier], :admin => true)
flash[:notice] = "invitation sent to #{params[:identifier]}"
EmailInviter.new(email).send!
flash[:notice] = "invitation sent to #{email}"
else
flash[:notice]= "error sending invite to #{params[:identifier]}"
flash[:notice]= "error sending invite to #{email}"
end
redirect_to user_search_path, :notice => flash[:notice]
end

View file

@ -27,6 +27,7 @@ class InvitationsController < ApplicationController
def create
inviter = EmailInviter.new(params[:email_inviter][:emails], params[:email_inviter])
inviter.send!
redirect_to :back, :notice => "Great! Invites were sent off to #{inviter.emails.join(', ')}"
end

View file

@ -69,38 +69,4 @@ class ServicesController < ApplicationController
@service = current_user.services.where(:type => "Services::#{params[:provider].titleize}").first
@friends = @service ? @service.finder(:remote => params[:remote]).paginate( :page => params[:page], :per_page => 15) : []
end
def inviter
@uid = params[:uid]
if i_id = params[:invitation_id]
invite = Invitation.find(i_id)
invited_user = invite.recipient
else
invite = Invitation.create(:service => params[:provider], :identifier => @uid, :sender => current_user, :aspect => current_user.aspects.find(params[:aspect_id]))
invited_user = invite.attach_recipient!
end
#to make sure a friend you just invited from facebook shows up as invited
service = current_user.services.where(:type => "Services::Facebook").first
su = ServiceUser.where(:service_id => service.id, :uid => @uid).first
su.attach_local_models
su.save
respond_to do |format|
format.html{ invite_redirect_url(invite, invited_user, su)}
format.json{ render :json => invite_redirect_json(invite, invited_user, su) }
end
end
def facebook_message_url(user, facebook_uid)
subject = t('services.inviter.join_me_on_diaspora')
message = <<MSG
#{t('services.inviter.click_link_to_accept_invitation')}:
\n
\n
#{invitation_code_url(user.invitation_code)}
MSG
"https://www.facebook.com/messages/#{facebook_uid}?msg_prefill=#{message}"
end
end

View file

@ -25,11 +25,10 @@ module NotifierHelper
end
def invite_email_title
names = @invites.collect{|x| x.sender.person.name}.uniq
if @invites.empty? && names.empty?
"Accept Your Diaspora* invite!"
if @inviter.present?
"#{@inviter.person.name} invited you to Diaspora*"
else
"#{names.to_sentence} invited you to Diaspora*"
"Accept Your Diaspora* invite!"
end
end
end

View file

@ -22,8 +22,6 @@ class Invitation < ActiveRecord::Base
validate :sender_owns_aspect?, :unless => :admin?
validates_uniqueness_of :sender_id, :scope => [:identifier, :service], :unless => :admin?
after_create :queue_send! #TODO make this after_commit :queue_saved!, :on => :create
# @note options hash is passed through to [Invitation.new]
# @see [Invitation.new]
@ -33,7 +31,7 @@ class Invitation < ActiveRecord::Base
# @option opts [Aspect] :aspect
# @option opts [String] :service
# @return [Array<Invitation>] An array of [Invitation] models
# the valid ones are saved, and the invalid ones are not.
# the valid optsnes are saved, and the invalid ones are not.
def self.batch_invite(emails, opts)
users_on_pod = User.where(:email => emails, :invitation_token => nil)
@ -66,36 +64,16 @@ class Invitation < ActiveRecord::Base
!email_like_identifer
end
# Attach a recipient [User] to the [Invitation] unless
# there is one already present.
#
# @return [User] The recipient.
def attach_recipient!
unless self.recipient.present?
self.recipient = User.find_or_create_by_invitation(self)
self.save
end
self.recipient
end
# Find or create user, and send that resultant User an
# invitation.
#
# @return [Invitation] self
def send!
self.attach_recipient!
# Sets an instance variable in User (set by devise invitable)
# This determines whether an email should be sent to the recipient.
recipient.skip_invitation = self.skip_email?
recipient.invite!
# Logging the invitation action
log_hash = {:event => :invitation_sent, :to => self[:identifier], :service => self[:service]}
log_hash.merge({:inviter => self.sender.diaspora_handle, :invitier_uid => self.sender.id, :inviter_created_at_unix => self.sender.created_at.to_i}) if self.sender
Rails.logger.info(log_hash)
if email_like_identifer
EmailInviter.new(self.identifier).send!
else
puts "broken facebook invitation_token"
end
self
end
@ -135,19 +113,7 @@ class Invitation < ActiveRecord::Base
when 'email'
self.identifier
when 'facebook'
if username = ServiceUser.username_of_service_user_by_uid(self.identifier)
unless username.include?('profile.php?')
"#{username}@facebook.com"
else
nil
end
end
end
end
def queue_send!
unless self.recipient.present?
Resque.enqueue(Jobs::Mail::InviteUserByEmail, self.id)
false
end
end

View file

@ -1,140 +0,0 @@
<%- self.extend NotifierHelper -%>
<head>
<title><%=invite_email_title %></title>
</head>
<p style="background-color: rgb(255, 255, 255); text-align: center; font-size: 11px;"><%= t('.displaying_correctly', :link => link_to(t('.view_in'), invite_email_url(:invitation_token => @resource.invitation_token), :style => "color: #3F8FBA; text-decoration: none;")).html_safe %> </p>
<table border="0" cellpadding="0" cellspacing="0" width="100%"><tbody><tr><td style="padding: 30px 15px 0pt; background-color: rgb(221, 221, 221);">
<table style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 16px; color: rgb(51, 51, 51);" align="center" border="0" cellpadding="0" cellspacing="0" width="600">
<tbody>
<tr>
<td style="background-color: rgb(0, 0, 0);">
<a style="display: block;" href="<%= invite_code_url(@invitation_code) %>" target="_blank">
<img alt="Diaspora" src="http://dl.dropbox.com/u/15865/diaspora%20logo.png" style="border: 0pt none ; display: block;" height="134" width="600">
</a>
</td>
</tr>
<tr>
<td style="padding: 10px 0pt 0px 20px; background: rgb(255, 255, 255) none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; font-size: 44px; font-weight: bold; color: rgb(0, 0, 0);">
<%= t('.finally') %><br>
</td>
</tr>
<tr><td style="padding: 0px 20px 0pt; background: rgb(255, 255, 255) none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" width="600" height='389'>
<a href="<%= invite_code_url(@invitation_code)%>" target="_blank"><img src="http://dl.dropbox.com/u/15865/diaspora_shots.jpg" style="border: 0pt none ; display: block;" width="560">
</a></td></tr>
<tr><td style="padding: 0pt 30px; background: rgb(255, 255, 255) none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; line-height: 20px;">
<%= t('.arrived', :strong_diaspora => content_tag(:strong, "DIASPORA*")).html_safe %>
<br>
<br>
<%= link_to(t('.sign_up_now').html_safe, invite_code_url(@invitation_code), :style => "color: #3F8FBA; text-decoration: underline; font-weight: bold; font-size: 20px;", :target => "_blank").html_safe %>
</td></tr>
<% if @inviter.present? %>
<%= @inviter.inspect %>
<% end %>
<tr><td style="padding: 20px 20px 0px; background: rgb(255, 255, 255) none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; font-size: 44px; font-weight: bold; color: rgb(0, 0, 0);">
1. <%= t('.get_connected') %></td></tr>
<tr><td>
<table style="padding: 0pt 20px; background: rgb(255, 255, 255) none repeat scroll 0%; font-size: 16px; color: rgb(51, 51, 51); -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" align="center" border="0" cellpadding="0" cellspacing="0" width="600">
<tbody><tr>
<td width="200">
<a href="<%=invite_code_url(@invitation_code) %>" target="_blank"><img style="border: 0pt none ; padding: 0pt 10px 0px 5px; display: block;" src="https://joindiaspora.s3.amazonaws.com/uploads/images/scaled_full_c7506ec0b3ae6694c64d.gif" height="156" width="200"></a>
</td>
<td style="line-height: 20px; width: 360px;">
<%= t('.get_connected_paragraph', :strong_diaspora => content_tag(:strong, "DIASPORA*")).html_safe %>
<br>
<!-- <a style="color: #3F8FBA; text-decoration: underline; font-weight: bold; font-size: 20px;" href="https://joindiaspora.com/channels" target="_blank">Tune in to your favorite Channels</a>-->
</td>
</tr>
</tbody></table>
</td></tr>
<tr><td style="padding: 20px 20px 0px; background: rgb(255, 255, 255) none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; font-size: 44px; font-weight: bold; color: rgb(0, 0, 0);">
2. <%= t('.be_yourself') %></td></tr>
<tr><td>
<table style="padding: 0pt 20px; background: rgb(255, 255, 255) none repeat scroll 0%; font-size: 16px; color: rgb(51, 51, 51); -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" align="center" border="0" cellpadding="0" cellspacing="0" width="600">
<tbody><tr>
<td style="line-height: 20px; width: 360px;">
<%= t('.be_yourself_paragraph', :strong_diaspora => content_tag(:strong, "DIASPORA*")).html_safe %>
<br>
<!-- <a style="color: #3F8FBA; text-decoration: underline; font-weight: bold; font-size: 20px;" href="#" target="_blank">Watch all the bumpers</a>-->
</td>
<td width="200">
<a href="<%= invite_code_url(@invitation_code)%>" target="_blank"><img style="border: 0pt none ; padding: 0pt 5px 0px 10px; display: block;" src="http://dl.dropbox.com/u/15865/apolonisaphrodisia.png" height="150" width="170"></a>
</td>
</tr>
</tbody></table>
</td></tr>
<tr><td style="padding: 20px 20px 0px; background: rgb(255, 255, 255) none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; font-size: 44px; font-weight: bold; color: rgb(0, 0, 0);">
3. <%= t('.have_fun') %></td></tr>
<tr><td>
<table style="padding: 0pt 20px; background: rgb(255, 255, 255) none repeat scroll 0%; font-size: 16px; color: rgb(51, 51, 51); -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" align="center" border="0" cellpadding="0" cellspacing="0" width="600">
<tbody><tr>
<td width="200">
<a href="<%= invite_code_url(@invitation_code)%>" target="_blank"><img style="border: 0pt none ; padding: 0pt 5px; display: block;" src="http://joindiaspora.com/images/cubbies_screenshot2.png" height="151" width="200"></a>
</td>
<td style="line-height: 20px; width: 360px;">
<%= t('.have_fun_paragraph', :strong_diaspora => content_tag(:strong, "DIASPORA*"), :link => link_to(t('.cubbies'), "https://cubbi.es", :style => "color: #3F8FBA; text-decoration: underline; font-weight: bold; font-size: 20px;", :target => "_blank")).html_safe %>
<!-- <a style="color: #3F8FBA; text-decoration: underline; font-weight: bold; font-size: 20px;" href="#" target="_blank">Watch all the bumpers</a>-->
</td>
</tr>
</tbody></table>
</td></tr>
<tr><td>
<table style="padding: 0pt 20px; background: rgb(255, 255, 255) none repeat scroll 0%; font-size: 16px; color: rgb(51, 51, 51); -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" align="center" border="0" cellpadding="0" cellspacing="0" width="600">
<tbody>
<tr>
<td style="padding: 40px 20px 20px; background: rgb(255, 255, 255) none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">
<%= link_to(t('.sign_up_now').html_safe, invite_code_url(@invitation_code), :style => "color: #3F8FBA; text-decoration: underline; font-weight: bold; font-size: 20px;", :target => "_blank").html_safe %>
</td>
</tr>
</tbody>
</table>
</td></tr>
<tr><td>
<table style="padding: 0pt 20px; background: rgb(255, 255, 255) none repeat scroll 0%; font-size: 16px; color: rgb(51, 51, 51); -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" align="center" border="0" cellpadding="0" cellspacing="0" width="600">
<tbody>
<tr>
<td style="padding: 20px 20px 0px; background: rgb(255, 255, 255) none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">
<%= t('.made_by_people', :strong_diaspora => content_tag(:strong, "DIASPORA*"), :jointeam => link_to(t('.join_team'), "https://github.com/diaspora/diaspora/wiki/Become-a-Contributor", :style =>"color: #3F8FBA; text-decoration: underline; font-weight: bold; font-size: 18px;", :target => "_blank"), :helpfund => link_to(t('.help_fund'), "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QG4L6VYD8YGPU", :style =>"color: #3F8FBA; text-decoration: underline; font-weight: bold; font-size: 18px;", :target => "_blank")).html_safe %>
</td>
</tr>
</tbody>
</table>
</td></tr>
<tr><td style="padding: 35px 20px 20px; background: rgb(255, 255, 255) none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">
<%= t('.love') %><br>
<%= t('.team_diaspora') %><br>
</td></tr>
<tr><td style="padding: 35px 40px; font-size: 11px; color: rgb(102, 102, 102); line-height: 16px;">
<% if AppConfig[:pod_uri].host.match(/joindiaspora.com/) %>
<%= t('.unsubscribe', :link => link_to(t('.here'), "http://joindiaspora.us1.list-manage.com/unsubscribe?u=d759919b94f9cdcf39d204f3f&id=7b5ceb2f8b", :style => "color: #3F8FBA; text-decoration: none;")).html_safe %>
<% end %>
<%= t('.email_us', :email => link_to(t('.email_address'), "mailto:questions@joindiaspora.com", :style => "color: #3F8FBA; text-decoration: none;")).html_safe %>
</td></tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>

View file

@ -2,7 +2,7 @@
<head>
<title><%=invite_email_title %></title>
</head>
<p style="background-color: rgb(255, 255, 255); text-align: center; font-size: 11px;"><%= t('.displaying_correctly', :link => link_to(t('.view_in'), invite_email_url(:invitation_token => @resource.invitation_token), :style => "color: #3F8FBA; text-decoration: none;")).html_safe %> </p>
<p style="background-color: rgb(255, 255, 255); text-align: center; font-size: 11px;"><%= t('devise.mailer.invitation_instructions.displaying_correctly', :link => link_to(t('devise.mailer.invitation_instructions.view_in'), invite_email_url(:invitation_code => @invitation_code), :style => "color: #3F8FBA; text-decoration: none;")).html_safe %> </p>
<table border="0" cellpadding="0" cellspacing="0" width="100%"><tbody><tr><td style="padding: 30px 15px 0pt; background-color: rgb(221, 221, 221);">
<table style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 16px; color: rgb(51, 51, 51);" align="center" border="0" cellpadding="0" cellspacing="0" width="600">
@ -19,7 +19,7 @@
<tr>
<td style="padding: 10px 0pt 0px 20px; background: rgb(255, 255, 255) none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; font-size: 44px; font-weight: bold; color: rgb(0, 0, 0);">
<%= t('.finally') %><br>
<%= t('devise.mailer.invitation_instructions.finally') %><br>
</td>
</tr>
@ -29,10 +29,10 @@
<tr><td style="padding: 0pt 30px; background: rgb(255, 255, 255) none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; line-height: 20px;">
<%= t('.arrived', :strong_diaspora => content_tag(:strong, "DIASPORA*")).html_safe %>
<%= t('devise.mailer.invitation_instructions.arrived', :strong_diaspora => content_tag(:strong, "DIASPORA*")).html_safe %>
<br>
<br>
<%= link_to(t('.sign_up_now').html_safe, invite_code_url(@invitation_code), :style => "color: #3F8FBA; text-decoration: underline; font-weight: bold; font-size: 20px;", :target => "_blank").html_safe %>
<%= link_to(t('devise.mailer.invitation_instructions.sign_up_now').html_safe, invite_code_url(@invitation_code), :style => "color: #3F8FBA; text-decoration: underline; font-weight: bold; font-size: 20px;", :target => "_blank").html_safe %>
</td></tr>
@ -43,7 +43,7 @@
<tr><td style="padding: 20px 20px 0px; background: rgb(255, 255, 255) none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; font-size: 44px; font-weight: bold; color: rgb(0, 0, 0);">
1. <%= t('.get_connected') %></td></tr>
1. <%= t('devise.mailer.invitation_instructions.get_connected') %></td></tr>
<tr><td>
<table style="padding: 0pt 20px; background: rgb(255, 255, 255) none repeat scroll 0%; font-size: 16px; color: rgb(51, 51, 51); -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" align="center" border="0" cellpadding="0" cellspacing="0" width="600">
<tbody><tr>
@ -51,7 +51,7 @@
<a href="<%=invite_code_url(@invitation_code) %>" target="_blank"><img style="border: 0pt none ; padding: 0pt 10px 0px 5px; display: block;" src="https://joindiaspora.s3.amazonaws.com/uploads/images/scaled_full_c7506ec0b3ae6694c64d.gif" height="156" width="200"></a>
</td>
<td style="line-height: 20px; width: 360px;">
<%= t('.get_connected_paragraph', :strong_diaspora => content_tag(:strong, "DIASPORA*")).html_safe %>
<%= t('devise.mailer.invitation_instructions.get_connected_paragraph', :strong_diaspora => content_tag(:strong, "DIASPORA*")).html_safe %>
<br>
<!-- <a style="color: #3F8FBA; text-decoration: underline; font-weight: bold; font-size: 20px;" href="https://joindiaspora.com/channels" target="_blank">Tune in to your favorite Channels</a>-->
</td>
@ -60,13 +60,13 @@
</td></tr>
<tr><td style="padding: 20px 20px 0px; background: rgb(255, 255, 255) none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; font-size: 44px; font-weight: bold; color: rgb(0, 0, 0);">
2. <%= t('.be_yourself') %></td></tr>
2. <%= t('devise.mailer.invitation_instructions.be_yourself') %></td></tr>
<tr><td>
<table style="padding: 0pt 20px; background: rgb(255, 255, 255) none repeat scroll 0%; font-size: 16px; color: rgb(51, 51, 51); -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" align="center" border="0" cellpadding="0" cellspacing="0" width="600">
<tbody><tr>
<td style="line-height: 20px; width: 360px;">
<%= t('.be_yourself_paragraph', :strong_diaspora => content_tag(:strong, "DIASPORA*")).html_safe %>
<%= t('devise.mailer.invitation_instructions.be_yourself_paragraph', :strong_diaspora => content_tag(:strong, "DIASPORA*")).html_safe %>
<br>
<!-- <a style="color: #3F8FBA; text-decoration: underline; font-weight: bold; font-size: 20px;" href="#" target="_blank">Watch all the bumpers</a>-->
@ -81,7 +81,7 @@
<tr><td style="padding: 20px 20px 0px; background: rgb(255, 255, 255) none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; font-size: 44px; font-weight: bold; color: rgb(0, 0, 0);">
3. <%= t('.have_fun') %></td></tr>
3. <%= t('devise.mailer.invitation_instructions.have_fun') %></td></tr>
<tr><td>
<table style="padding: 0pt 20px; background: rgb(255, 255, 255) none repeat scroll 0%; font-size: 16px; color: rgb(51, 51, 51); -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" align="center" border="0" cellpadding="0" cellspacing="0" width="600">
<tbody><tr>
@ -90,7 +90,7 @@
</td>
<td style="line-height: 20px; width: 360px;">
<%= t('.have_fun_paragraph', :strong_diaspora => content_tag(:strong, "DIASPORA*"), :link => link_to(t('.cubbies'), "https://cubbi.es", :style => "color: #3F8FBA; text-decoration: underline; font-weight: bold; font-size: 20px;", :target => "_blank")).html_safe %>
<%= t('devise.mailer.invitation_instructions.have_fun_paragraph', :strong_diaspora => content_tag(:strong, "DIASPORA*"), :link => link_to(t('devise.mailer.invitation_instructions.cubbies'), "https://cubbi.es", :style => "color: #3F8FBA; text-decoration: underline; font-weight: bold; font-size: 20px;", :target => "_blank")).html_safe %>
<!-- <a style="color: #3F8FBA; text-decoration: underline; font-weight: bold; font-size: 20px;" href="#" target="_blank">Watch all the bumpers</a>-->
</td>
</tr>
@ -102,7 +102,7 @@
<tbody>
<tr>
<td style="padding: 40px 20px 20px; background: rgb(255, 255, 255) none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">
<%= link_to(t('.sign_up_now').html_safe, invite_code_url(@invitation_code), :style => "color: #3F8FBA; text-decoration: underline; font-weight: bold; font-size: 20px;", :target => "_blank").html_safe %>
<%= link_to(t('devise.mailer.invitation_instructions.sign_up_now').html_safe, invite_code_url(@invitation_code), :style => "color: #3F8FBA; text-decoration: underline; font-weight: bold; font-size: 20px;", :target => "_blank").html_safe %>
</td>
</tr>
</tbody>
@ -114,7 +114,7 @@
<tbody>
<tr>
<td style="padding: 20px 20px 0px; background: rgb(255, 255, 255) none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">
<%= t('.made_by_people', :strong_diaspora => content_tag(:strong, "DIASPORA*"), :jointeam => link_to(t('.join_team'), "https://github.com/diaspora/diaspora/wiki/Become-a-Contributor", :style =>"color: #3F8FBA; text-decoration: underline; font-weight: bold; font-size: 18px;", :target => "_blank"), :helpfund => link_to(t('.help_fund'), "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QG4L6VYD8YGPU", :style =>"color: #3F8FBA; text-decoration: underline; font-weight: bold; font-size: 18px;", :target => "_blank")).html_safe %>
<%= t('devise.mailer.invitation_instructions.made_by_people', :strong_diaspora => content_tag(:strong, "DIASPORA*"), :jointeam => link_to(t('devise.mailer.invitation_instructions.join_team'), "https://github.com/diaspora/diaspora/wiki/Become-a-Contributor", :style =>"color: #3F8FBA; text-decoration: underline; font-weight: bold; font-size: 18px;", :target => "_blank"), :helpfund => link_to(t('devise.mailer.invitation_instructions.help_fund'), "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QG4L6VYD8YGPU", :style =>"color: #3F8FBA; text-decoration: underline; font-weight: bold; font-size: 18px;", :target => "_blank")).html_safe %>
</td>
</tr>
@ -123,14 +123,14 @@
</td></tr>
<tr><td style="padding: 35px 20px 20px; background: rgb(255, 255, 255) none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">
<%= t('.love') %><br>
<%= t('.team_diaspora') %><br>
<%= t('devise.mailer.invitation_instructions.love') %><br>
<%= t('devise.mailer.invitation_instructions.team_diaspora') %><br>
</td></tr>
<tr><td style="padding: 35px 40px; font-size: 11px; color: rgb(102, 102, 102); line-height: 16px;">
<% if AppConfig[:pod_uri].host.match(/joindiaspora.com/) %>
<%= t('.unsubscribe', :link => link_to(t('.here'), "http://joindiaspora.us1.list-manage.com/unsubscribe?u=d759919b94f9cdcf39d204f3f&id=7b5ceb2f8b", :style => "color: #3F8FBA; text-decoration: none;")).html_safe %>
<%= t('devise.mailer.invitation_instructions.unsubscribe', :link => link_to(t('devise.mailer.invitation_instructions.here'), "http://joindiaspora.us1.list-manage.com/unsubscribe?u=d759919b94f9cdcf39d204f3f&id=7b5ceb2f8b", :style => "color: #3F8FBA; text-decoration: none;")).html_safe %>
<% end %>
<%= t('.email_us', :email => link_to(t('.email_address'), "mailto:questions@joindiaspora.com", :style => "color: #3F8FBA; text-decoration: none;")).html_safe %>
<%= t('devise.mailer.invitation_instructions.email_us', :email => link_to(t('devise.mailer.invitation_instructions.email_address'), "mailto:questions@joindiaspora.com", :style => "color: #3F8FBA; text-decoration: none;")).html_safe %>
</td></tr>
</tbody>
</table>

View file

@ -4,7 +4,7 @@ You have been invited to join Diaspora*!
Click this link to get started
<%= invitation_code_url(@invitation_code)%>
<%= invite_code_url(@invitation_code)%>
Love,

View file

@ -40,6 +40,6 @@ Feature: invitation acceptance
Given a user with email "bob@bob.bob"
When I sign in as "bob@bob.bob"
And I follow "By email"
And I fill in "user_email" with "alex@example.com"
And I fill in "email_inviter_emails" with "alex@example.com"
And I press "Send an invitation"
Then I should have 1 Devise email delivery

View file

@ -26,15 +26,14 @@ Given /^a nsfw user with email "([^\"]*)"$/ do |email|
end
Given /^I have been invited by an admin$/ do
i = Invitation.create!(:admin => true, :service => 'email', :identifier => "new_invitee@example.com")
@me = i.attach_recipient!
i = EmailInviter.new("new_invitee@example.com")
i.send!
end
Given /^I have been invited by a user$/ do
@inviter = Factory(:user)
aspect = @inviter.aspects.create(:name => "Rocket Scientists")
i = Invitation.create!(:aspect => aspect, :sender => @inviter, :service => 'email', :identifier => "new_invitee@example.com", :message =>"Hey, tell me about your rockets!")
@me = i.attach_recipient!
i = EmailInviter.new("new_invitee@example.com", :inviter => @inviter)
i.send!
end
When /^I click on my name$/ do

View file

@ -20,7 +20,7 @@ module NavigationHelpers
when /^my profile page$/
person_path(@me.person)
when /^my acceptance form page$/
accept_user_invitation_path(:invitation_token => @me.invitation_token)
invite_code_path(InvitationCode.first)
when /^the requestors profile$/
person_path(Request.where(:recipient_id => @me.person.id).first.sender)
when /^"([^\"]*)"'s page$/

View file

@ -15,10 +15,11 @@ class EmailInviter
end
def invitation_code
@invitation_code ||= inviter.nil? ? self.admin_code : inviter.invitation_code
@invitation_code ||= inviter.nil? ? EmailInviter.admin_code : inviter.invitation_code
end
def self.admin_code
puts "FIX ME"
"foo"
end
@ -29,6 +30,6 @@ class EmailInviter
private
def mail(email)
Notifier.invite(email, message, inviter, invitation_code, locale)
Notifier.invite(email, message, inviter, invitation_code, locale).deliver!
end
end

View file

@ -29,7 +29,7 @@ module RakeHelpers
unless possible_user
puts "#{n}: sending email to: #{backer_name} #{backer_email}" unless Rails.env == 'test'
unless test
i = Invitation.new(:service => 'email', :identifier => backer_email, :admin => true)
i = EmailInviter.new(backer_email)
i.send!
end
else

View file

@ -143,51 +143,4 @@ describe ServicesController do
Nokogiri(response.body).css('.translation_missing').should be_empty
end
end
describe '#inviter' do
before do
@uid = "abc"
fb = Factory(:service, :type => "Services::Facebook", :user => @user)
fb = Services::Facebook.find(fb.id)
@su = Factory(:service_user, :service => fb, :uid => @uid)
@invite_params = {:provider => 'facebook', :uid => @uid, :aspect_id => @user.aspects.first.id}
end
it 'redirects to a prefilled facebook message url' do
put :inviter, @invite_params
response.location.should match(/https:\/\/www\.facebook\.com\/messages\/.*?msg_prefill=.*/)
end
it 'creates an invitation' do
lambda {
put :inviter, @invite_params
}.should change(Invitation, :count).by(1)
end
it 'sets the invitation_id on the service_user' do
post :inviter, @invite_params
@su.reload.invitation.should_not be_nil
end
it 'does not create a duplicate invitation' do
invited_user = Factory.build(:user, :username =>nil)
invited_user.save(:validate => false)
inv = Invitation.create!(:sender => @user, :recipient => invited_user, :aspect => @user.aspects.first, :identifier => eve.email)
@invite_params[:invitation_id] = inv.id
lambda {
put :inviter, @invite_params
}.should_not change(Invitation, :count)
end
it 'disregards the amount of invites if open_invitations are enabled' do
open_bit = AppConfig[:open_invitations]
AppConfig[:open_invitations] = true
lambda {
put :inviter, @invite_params
}.should change(Invitation, :count).by(1)
AppConfig[:open_invitations] = open_bit
end
end
end

View file