fixed emails to show avatars, have subject lines that allow threading in email clients, and relevant content previews
This commit is contained in:
parent
8cfd2e02e1
commit
c4b715f3ff
20 changed files with 155 additions and 242 deletions
|
|
@ -15,9 +15,13 @@ module MarkdownifyHelper
|
||||||
message = process_youtube(message, options[:youtube_maps])
|
message = process_youtube(message, options[:youtube_maps])
|
||||||
message = process_vimeo(message, options[:vimeo_maps])
|
message = process_vimeo(message, options[:vimeo_maps])
|
||||||
message = process_emoticons(message) if options[:emoticons]
|
message = process_emoticons(message) if options[:emoticons]
|
||||||
|
message = process_newlines(message) if options[:newlines]
|
||||||
|
|
||||||
message.gsub!(/\n+/, '<br />') if options[:newlines]
|
message
|
||||||
|
end
|
||||||
|
|
||||||
|
def process_newlines(message)
|
||||||
|
message.gsub!(/\n+/, '<br />')
|
||||||
message
|
message
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,12 @@
|
||||||
class Notifier < ActionMailer::Base
|
class Notifier < ActionMailer::Base
|
||||||
helper :application
|
helper :application
|
||||||
|
helper :markdownify
|
||||||
|
|
||||||
default :from => AppConfig[:smtp_sender_address]
|
default :from => AppConfig[:smtp_sender_address]
|
||||||
|
|
||||||
ATTACHMENT = File.read("#{Rails.root}/public/images/logo_caps.png")
|
include ActionView::Helpers::TextHelper
|
||||||
|
|
||||||
|
TRUNCATION_LEN = 70
|
||||||
|
|
||||||
def self.admin(string, recipients, opts = {})
|
def self.admin(string, recipients, opts = {})
|
||||||
mails = []
|
mails = []
|
||||||
|
|
@ -16,7 +20,6 @@ class Notifier < ActionMailer::Base
|
||||||
def single_admin(string, recipient)
|
def single_admin(string, recipient)
|
||||||
@receiver = recipient
|
@receiver = recipient
|
||||||
@string = string.html_safe
|
@string = string.html_safe
|
||||||
attachments.inline['logo_caps.png'] = ATTACHMENT
|
|
||||||
mail(:to => @receiver.email,
|
mail(:to => @receiver.email,
|
||||||
:subject => I18n.t('notifier.single_admin.subject'), :host => AppConfig[:pod_uri].host)
|
:subject => I18n.t('notifier.single_admin.subject'), :host => AppConfig[:pod_uri].host)
|
||||||
end
|
end
|
||||||
|
|
@ -27,8 +30,6 @@ class Notifier < ActionMailer::Base
|
||||||
|
|
||||||
log_mail(recipient_id, sender_id, 'started_sharing')
|
log_mail(recipient_id, sender_id, 'started_sharing')
|
||||||
|
|
||||||
attachments.inline['logo_caps.png'] = ATTACHMENT
|
|
||||||
|
|
||||||
I18n.with_locale(@receiver.language) do
|
I18n.with_locale(@receiver.language) do
|
||||||
mail(:to => "\"#{@receiver.name}\" <#{@receiver.email}>",
|
mail(:to => "\"#{@receiver.name}\" <#{@receiver.email}>",
|
||||||
:subject => I18n.t('notifier.started_sharing.subject', :name => @sender.name), :host => AppConfig[:pod_uri].host)
|
:subject => I18n.t('notifier.started_sharing.subject', :name => @sender.name), :host => AppConfig[:pod_uri].host)
|
||||||
|
|
@ -42,23 +43,19 @@ class Notifier < ActionMailer::Base
|
||||||
|
|
||||||
log_mail(recipient_id, sender_id, 'liked')
|
log_mail(recipient_id, sender_id, 'liked')
|
||||||
|
|
||||||
attachments.inline['logo_caps.png'] = ATTACHMENT
|
|
||||||
|
|
||||||
I18n.with_locale(@receiver.language) do
|
I18n.with_locale(@receiver.language) do
|
||||||
mail(:to => "\"#{@receiver.name}\" <#{@receiver.email}>",
|
mail(:to => "\"#{@receiver.name}\" <#{@receiver.email}>",
|
||||||
:subject => I18n.t('notifier.liked.subject', :name => @sender.name), :host => AppConfig[:pod_uri].host)
|
:subject => I18n.t('notifier.liked.liked', :name => @sender.name), :host => AppConfig[:pod_uri].host)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def mentioned(recipient_id, sender_id, target_id)
|
def mentioned(recipient_id, sender_id, target_id)
|
||||||
@receiver = User.find_by_id(recipient_id)
|
@receiver = User.find_by_id(recipient_id)
|
||||||
@sender = Person.find_by_id(sender_id)
|
@sender = Person.find_by_id(sender_id)
|
||||||
@post = Mention.find_by_id(target_id).post
|
@post = Mention.find_by_id(target_id).post
|
||||||
|
|
||||||
log_mail(recipient_id, sender_id, 'mentioned')
|
log_mail(recipient_id, sender_id, 'mentioned')
|
||||||
|
|
||||||
attachments.inline['logo_caps.png'] = ATTACHMENT
|
|
||||||
|
|
||||||
I18n.with_locale(@receiver.language) do
|
I18n.with_locale(@receiver.language) do
|
||||||
mail(:to => "\"#{@receiver.name}\" <#{@receiver.email}>",
|
mail(:to => "\"#{@receiver.name}\" <#{@receiver.email}>",
|
||||||
:subject => I18n.t('notifier.mentioned.subject', :name => @sender.name), :host => AppConfig[:pod_uri].host)
|
:subject => I18n.t('notifier.mentioned.subject', :name => @sender.name), :host => AppConfig[:pod_uri].host)
|
||||||
|
|
@ -72,11 +69,10 @@ class Notifier < ActionMailer::Base
|
||||||
|
|
||||||
log_mail(recipient_id, sender_id, 'comment_on_post')
|
log_mail(recipient_id, sender_id, 'comment_on_post')
|
||||||
|
|
||||||
attachments.inline['logo_caps.png'] = ATTACHMENT
|
|
||||||
|
|
||||||
I18n.with_locale(@receiver.language) do
|
I18n.with_locale(@receiver.language) do
|
||||||
mail(:to => "\"#{@receiver.name}\" <#{@receiver.email}>",
|
mail(:from => "\"#{@sender.name} (Diaspora)\" <#{AppConfig[:smtp_sender_address]}>",
|
||||||
:subject => I18n.t('notifier.comment_on_post.subject', :name => @sender.name), :host => AppConfig[:pod_uri].host)
|
:to => "\"#{@receiver.name}\" <#{@receiver.email}>",
|
||||||
|
:subject => "Re: #{truncate(@comment.parent.formatted_message(:plain_text => true).strip, :length => TRUNCATION_LEN)}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -89,11 +85,10 @@ class Notifier < ActionMailer::Base
|
||||||
|
|
||||||
log_mail(recipient_id, sender_id, 'comment_on_post')
|
log_mail(recipient_id, sender_id, 'comment_on_post')
|
||||||
|
|
||||||
attachments.inline['logo_caps.png'] = ATTACHMENT
|
|
||||||
|
|
||||||
I18n.with_locale(@receiver.language) do
|
I18n.with_locale(@receiver.language) do
|
||||||
mail(:to => "\"#{@receiver.name}\" <#{@receiver.email}>",
|
mail(:from => "\"#{@sender.name} (Diaspora)\" <#{AppConfig[:smtp_sender_address]}>",
|
||||||
:subject => I18n.t('notifier.also_commented.subject', :name => @sender.name, :post_author => @post_author_name ), :host => AppConfig[:pod_uri].host)
|
:to => "\"#{@receiver.name}\" <#{@receiver.email}>",
|
||||||
|
:subject => "Re: #{truncate(@comment.parent.formatted_message(:plain_text => true).strip, :length => TRUNCATION_LEN)}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -107,11 +102,14 @@ class Notifier < ActionMailer::Base
|
||||||
|
|
||||||
log_mail(recipient_id, sender_id, 'private_message')
|
log_mail(recipient_id, sender_id, 'private_message')
|
||||||
|
|
||||||
attachments.inline['logo_caps.png'] = ATTACHMENT
|
subject = @conversation.subject.strip
|
||||||
|
subject = "Re: #{subject}" if @conversation.messages.size > 1
|
||||||
|
|
||||||
|
|
||||||
I18n.with_locale(@receiver.language) do
|
I18n.with_locale(@receiver.language) do
|
||||||
mail(:to => "\"#{@receiver.name}\" <#{@receiver.email}>",
|
mail(:from => "\"#{@sender.name} (Diaspora)\" <#{AppConfig[:smtp_sender_address]}>",
|
||||||
:subject => I18n.t('notifier.private_message.subject', :name => @sender.name), :host => AppConfig[:pod_uri].host)
|
:to => "\"#{@receiver.name}\" <#{@receiver.email}>",
|
||||||
|
:subject => subject)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
36
app/views/layouts/notifier.html.erb
Normal file
36
app/views/layouts/notifier.html.erb
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
<table cellspacing="0" cellpadding="0" border="0" align="center" width="100%" style="font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:14px;color:#333;">
|
||||||
|
<table cellspacing="0" cellpadding="0" border="0" align="center" width="100%" style="font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:14px;color:#333;">
|
||||||
|
<tr width="100%">
|
||||||
|
<% if @sender %>
|
||||||
|
<td style="vertical-align:top;" width="80px">
|
||||||
|
<div style="background-color:#eee;height:70px;width:70px;">
|
||||||
|
<img alt="<%=@sender.name%>" src="<%=@sender.profile.image_url(:medium)%>" style="border:0;display:block;display:relative;top:0;left:0;" height="70px" width="70px">
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<% end %>
|
||||||
|
<td style="vertical-align:top;">
|
||||||
|
<%= yield %>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<table cellspacing="0" cellpadding="0" border="0" align="center" width="100%" style="font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:12px;color:#999; padding-top:10px; margin-top:10px; border-top: 1px solid #ddd;">
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<%= t('notifier.email_sent_by_diaspora') %>
|
||||||
|
<a href="<%=edit_user_url%>">
|
||||||
|
<%= t('notifier.click_here') %>
|
||||||
|
</a>
|
||||||
|
<%=t('notifier.to_change_your_notification_settings')%>.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<table cellspacing="0" cellpadding="0" border="0" align="center" width="100%" style="font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:14px;color:#333;">
|
||||||
|
<tr>
|
||||||
|
<td style="text-align:center;padding:30px;">
|
||||||
|
<img src="<%=AppConfig[:pod_url]%>images/logo_caps.png" alt="DIASPORA*" width="95px" height="14px"/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
!!!
|
|
||||||
%html
|
|
||||||
%head
|
|
||||||
%meta{"http-equiv"=>"Content-Type", :content=>"text/html; charset=utf-8"}/
|
|
||||||
= render :partial => 'notifier_css'
|
|
||||||
%body
|
|
||||||
%header
|
|
||||||
= image_tag attachments['logo_caps.png'].url, :alt => "DIASPORA"
|
|
||||||
#container
|
|
||||||
= yield
|
|
||||||
%a{:href => "#{AppConfig[:pod_uri].scheme}://#{AppConfig[:pod_uri].host}#{edit_user_path}"}
|
|
||||||
= t('notifier.manage_your_email_settings')
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
!= yield
|
!= yield
|
||||||
!= t('notifier.manage_your_email_settings')
|
!= t('notifier.email_sent_by_diaspora')
|
||||||
!= "#{AppConfig[:pod_uri].scheme}://#{AppConfig[:pod_uri].host}#{edit_user_path}"
|
!= t('notifier.to_change_your_notification_settings')
|
||||||
|
!= edit_user_url
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,9 @@
|
||||||
:css
|
:css
|
||||||
body{
|
body{
|
||||||
width:600px;
|
width:600px;
|
||||||
font-family:'Arial','Helvetica',sans-serif;
|
font-family: 'Helvetica',sans-serif;
|
||||||
font-size:14px;
|
|
||||||
color:#333;
|
|
||||||
}
|
}
|
||||||
#container{
|
#container{
|
||||||
margin-bottom:25px
|
|
||||||
min-height:400px;
|
|
||||||
padding-left:15px;
|
|
||||||
}
|
}
|
||||||
header{
|
header{
|
||||||
margin-bottom: 25px;
|
margin-bottom: 25px;
|
||||||
|
|
@ -31,7 +26,3 @@
|
||||||
a:active{
|
a:active{
|
||||||
color: #005D9C;
|
color: #005D9C;
|
||||||
}
|
}
|
||||||
.large_text{
|
|
||||||
font-size:21px;
|
|
||||||
font-family:"Helvetica Neue",Arial,Helvetica,sans-serif;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,4 @@
|
||||||
%p
|
%p
|
||||||
= t('notifier.hello', :name => @receiver.profile.first_name)
|
= process_newlines(truncate(@comment.text, :length => 600))
|
||||||
%p
|
%p
|
||||||
= "#{@sender.name} (#{@sender.diaspora_handle})"
|
= link_to t('notifier.comment_on_post.reply', :name => @comment.post.author.first_name), post_url(@comment.post)
|
||||||
= t('.commented', :post_author => @post_author_name)
|
|
||||||
%br
|
|
||||||
%br
|
|
||||||
= @comment.text
|
|
||||||
|
|
||||||
%br
|
|
||||||
%br
|
|
||||||
= link_to t('.sign_in'), post_url(@comment.post)
|
|
||||||
|
|
||||||
%br
|
|
||||||
= t('notifier.love')
|
|
||||||
%br
|
|
||||||
= t('notifier.diaspora')
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1 @@
|
||||||
!= t('notifier.hello', :name => @receiver.profile.first_name)
|
!= truncate(@comment.text, :length => 600)
|
||||||
!= "#{@sender.name} (#{@sender.diaspora_handle})"
|
|
||||||
!= t('notifier.also_commented.commented', :post_author => @post_author_name)
|
|
||||||
|
|
||||||
!= @comment.text
|
|
||||||
|
|
||||||
!= "#{t('notifier.love')} \n"
|
|
||||||
!= t('notifier.diaspora')
|
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,4 @@
|
||||||
%p
|
%p
|
||||||
= t('notifier.hello', :name => @receiver.profile.first_name)
|
= process_newlines(truncate(@comment.text, :length => 600))
|
||||||
%p
|
%p
|
||||||
= "#{@sender.name} (#{@sender.diaspora_handle})"
|
= link_to t('notifier.comment_on_post.reply', :name => @comment.post.author.name), post_url(@comment.post)
|
||||||
= t('.commented')
|
|
||||||
|
|
||||||
= @comment.text
|
|
||||||
|
|
||||||
%br
|
|
||||||
= link_to t('.sign_in'), post_url(@comment.post)
|
|
||||||
|
|
||||||
%br
|
|
||||||
= t('notifier.love')
|
|
||||||
%br
|
|
||||||
= t('notifier.diaspora')
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1 @@
|
||||||
!= t('notifier.hello', :name => @receiver.profile.first_name)
|
!= truncate(@comment.text, :length => 600)
|
||||||
!= "#{@sender.name} (#{@sender.diaspora_handle})"
|
|
||||||
!= t('notifier.comment_on_post.commented')
|
|
||||||
|
|
||||||
!= @comment.text
|
|
||||||
|
|
||||||
!= post_url(@comment.post)
|
|
||||||
|
|
||||||
!= "#{t('notifier.love')} \n"
|
|
||||||
!= t('notifier.diaspora')
|
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,8 @@
|
||||||
%p
|
%p
|
||||||
= t('notifier.hello', :name => @receiver.profile.first_name)
|
= "#{t('.liked', :name => "#{@sender.name}")}:"
|
||||||
%p
|
|
||||||
= t('.liked', :name => "#{@sender.name} (#{@sender.diaspora_handle})")
|
%p{:style => "font-style:italic;color:#666"}
|
||||||
|
= process_newlines(truncate(@like.target.formatted_message(:plain_text => true), :length => 200))
|
||||||
|
|
||||||
%p
|
%p
|
||||||
= @like.target.formatted_message(:plain_text => true)
|
= link_to t('.view_post'), post_url(@like.target)
|
||||||
%p
|
|
||||||
|
|
||||||
%br
|
|
||||||
= link_to t('.sign_in'), post_url(@like.target)
|
|
||||||
%br
|
|
||||||
= t('notifier.love')
|
|
||||||
%br
|
|
||||||
= t('notifier.diaspora')
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,3 @@
|
||||||
!= t('notifier.hello', :name => @receiver.profile.first_name)
|
!= "#{t('notifier.liked.liked', :name => "#{@sender.name}")}:"
|
||||||
|
!= truncate(@like.target.formatted_message(:plain_text => true), :length => 200)
|
||||||
|
|
||||||
!= t('notifier.liked.liked', :name => "#{@sender.name} (#{@sender.diaspora_handle})")
|
|
||||||
|
|
||||||
!= @like.target.formatted_message(:plain_text => true)
|
|
||||||
|
|
||||||
!= t('notifier.love')
|
|
||||||
!= t('notifier.diaspora')
|
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,4 @@
|
||||||
%p
|
%p
|
||||||
= t('notifier.hello', :name => @receiver.profile.first_name)
|
= process_newlines(truncate(@post.formatted_message(:plain_text => true), :length => 600))
|
||||||
%p
|
%p
|
||||||
= "#{@sender.name} (#{@sender.diaspora_handle})"
|
= link_to t('notifier.comment_on_post.reply', :name => @post.author.name), post_url(@post)
|
||||||
= t('.mentioned')
|
|
||||||
%p
|
|
||||||
= @post.formatted_message(:plain_text => true)
|
|
||||||
%p
|
|
||||||
|
|
||||||
%br
|
|
||||||
= link_to t('.sign_in'), post_url(@post)
|
|
||||||
|
|
||||||
%br
|
|
||||||
= t('notifier.love')
|
|
||||||
%br
|
|
||||||
= t('notifier.diaspora')
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1 @@
|
||||||
!= t('notifier.hello', :name => @receiver.profile.first_name)
|
|
||||||
!= "#{@sender.name} (#{@sender.diaspora_handle})"
|
|
||||||
!= t('notifier.mentioned.mentioned')
|
|
||||||
|
|
||||||
!= @post.formatted_message(:plain_text => true)
|
!= @post.formatted_message(:plain_text => true)
|
||||||
|
|
||||||
!= "#{t('notifier.love')} \n"
|
|
||||||
!= t('notifier.diaspora')
|
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,4 @@
|
||||||
%p
|
%p
|
||||||
= t('notifier.hello', :name => @receiver.profile.first_name)
|
= markdownify(@message.text)
|
||||||
%p
|
%p
|
||||||
= "#{@sender.name} (#{@sender.diaspora_handle})"
|
= link_to t('.reply_to_or_view'), conversations_url(:conversation_id => @conversation)
|
||||||
= t('.private_message')
|
|
||||||
%p
|
|
||||||
= t('.message_subject', :subject => @conversation.subject)
|
|
||||||
%p
|
|
||||||
= @message.text
|
|
||||||
%p
|
|
||||||
|
|
||||||
%br
|
|
||||||
= link_to t('.sign_in'), conversations_url(:conversation_id => @conversation)
|
|
||||||
|
|
||||||
%br
|
|
||||||
= t('notifier.love')
|
|
||||||
%br
|
|
||||||
= t('notifier.diaspora')
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1 @@
|
||||||
!= t('notifier.hello', :name => @receiver.profile.first_name)
|
|
||||||
!= "#{@sender.name} (#{@sender.diaspora_handle})"
|
|
||||||
!= t('notifier.private_message.private_message')
|
|
||||||
|
|
||||||
!= t('notifier.private_message.message_subject', :subject => @conversation.subject)
|
|
||||||
!= @message.text
|
!= @message.text
|
||||||
|
|
||||||
!= "#{t('notifier.love')} \n"
|
|
||||||
!= t('notifier.diaspora')
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,5 @@
|
||||||
%p
|
%p
|
||||||
= t('notifier.hello', :name => @receiver.profile.first_name)
|
= @sender.name
|
||||||
%p
|
|
||||||
= "#{@sender.name} (#{@sender.diaspora_handle})"
|
|
||||||
= t('.sharing')
|
= t('.sharing')
|
||||||
|
%p
|
||||||
%br
|
= link_to t('.view_profile', :name => @sender.first_name), person_url(@sender)
|
||||||
= link_to t('.sign_in'), new_user_session_url
|
|
||||||
%br
|
|
||||||
= t('notifier.love')
|
|
||||||
%br
|
|
||||||
= t('notifier.diaspora')
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,4 @@
|
||||||
!= t('notifier.hello', :name => @receiver.profile.first_name)
|
!= "#{@sender.name}"
|
||||||
!= "#{@sender.name} (#{@sender.diaspora_handle})"
|
|
||||||
!= t('notifier.started_sharing.sharing')
|
!= t('notifier.started_sharing.sharing')
|
||||||
|
!= t('.view_profile', :name => @sender.first_name)
|
||||||
!= t('.sign_in')
|
!= person_url(@sender)
|
||||||
!= new_user_session_url
|
|
||||||
!= "#{t('notifier.love')} \n"
|
|
||||||
!= t('notifier.diaspora')
|
|
||||||
|
|
|
||||||
|
|
@ -397,39 +397,28 @@ en:
|
||||||
other: "%{count} new notifications"
|
other: "%{count} new notifications"
|
||||||
|
|
||||||
notifier:
|
notifier:
|
||||||
|
email_sent_by_diaspora: "This email was sent by Diaspora. If you'd like to stop getting emails like this,"
|
||||||
|
click_here: "click here"
|
||||||
hello: "Hello %{name}!"
|
hello: "Hello %{name}!"
|
||||||
love: "love,"
|
|
||||||
thanks: "Thanks,"
|
thanks: "Thanks,"
|
||||||
diaspora: "the diaspora email robot"
|
to_change_your_notification_settings: "to change your notification settings"
|
||||||
manage_your_email_settings: "manage your email settings"
|
|
||||||
single_admin:
|
single_admin:
|
||||||
subject: "A message about your Diaspora account:"
|
subject: "A message about your Diaspora account:"
|
||||||
admin: "Your Diaspora administrator"
|
admin: "Your Diaspora administrator"
|
||||||
started_sharing:
|
started_sharing:
|
||||||
subject: "%{name} has started sharing with you on Diaspora*"
|
subject: "%{name} started sharing with you on Diaspora*"
|
||||||
sharing: "has started sharing with you!"
|
sharing: "has started sharing with you!"
|
||||||
sign_in: "Sign in here"
|
view_profile: "View %{name}'s profile"
|
||||||
comment_on_post:
|
comment_on_post:
|
||||||
subject: "%{name} has commented on your post."
|
reply: "Reply or view %{name}'s post >"
|
||||||
commented: "has commented on your post:"
|
|
||||||
sign_in: "Sign in to view it."
|
|
||||||
also_commented:
|
|
||||||
subject: "%{name} has also commented on %{post_author}'s post."
|
|
||||||
commented: "has also commented on %{post_author}'s post:"
|
|
||||||
sign_in: "Sign in to view it."
|
|
||||||
mentioned:
|
mentioned:
|
||||||
subject: "%{name} has mentioned you on Diaspora*"
|
subject: "%{name} has mentioned you on Diaspora*"
|
||||||
mentioned: "mentioned you in a post:"
|
mentioned: "mentioned you in a post:"
|
||||||
sign_in: "Sign in to view it."
|
|
||||||
private_message:
|
private_message:
|
||||||
subject: "%{name} has sent you a private message on Diaspora*"
|
reply_to_or_view: "Reply to or view this conversation >"
|
||||||
private_message: "has sent you a private message:"
|
|
||||||
message_subject: "Subject: %{subject}"
|
|
||||||
sign_in: "Sign in to view it."
|
|
||||||
liked:
|
liked:
|
||||||
subject: "%{name} has just liked your post"
|
liked: "%{name} just liked your post:"
|
||||||
liked: "%{name} has just liked your post: "
|
view_post: "View post >"
|
||||||
sign_in: "Sign in to view it"
|
|
||||||
|
|
||||||
people:
|
people:
|
||||||
zero: "no people"
|
zero: "no people"
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
|
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe Notifier do
|
describe Notifier do
|
||||||
|
include ActionView::Helpers::TextHelper
|
||||||
|
|
||||||
let!(:user) {alice}
|
let!(:user) {alice}
|
||||||
let!(:user2) {eve}
|
let!(:user2) {eve}
|
||||||
|
|
||||||
|
|
@ -47,7 +48,7 @@ describe Notifier do
|
||||||
it 'has the layout' do
|
it 'has the layout' do
|
||||||
|
|
||||||
mail = Notifier.single_admin("Welcome to bureaucracy!", user)
|
mail = Notifier.single_admin("Welcome to bureaucracy!", user)
|
||||||
mail.body.encoded.should match /manage your email settings/
|
mail.body.encoded.should match /change your notification settings/
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -57,10 +58,6 @@ describe Notifier do
|
||||||
request_mail.to.should == [user.email]
|
request_mail.to.should == [user.email]
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'has the receivers name in the body' do
|
|
||||||
request_mail.body.encoded.include?(user.person.profile.first_name).should be true
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'has the name of person sending the request' do
|
it 'has the name of person sending the request' do
|
||||||
request_mail.body.encoded.include?(person.name).should be true
|
request_mail.body.encoded.include?(person.name).should be true
|
||||||
end
|
end
|
||||||
|
|
@ -73,21 +70,18 @@ describe Notifier do
|
||||||
describe ".mentioned" do
|
describe ".mentioned" do
|
||||||
before do
|
before do
|
||||||
@user = alice
|
@user = alice
|
||||||
@sm = Factory(:status_message)
|
@sm = Factory(:status_message)
|
||||||
@m = Mention.create(:person => @user.person, :post=> @sm)
|
@m = Mention.create(:person => @user.person, :post=> @sm)
|
||||||
|
|
||||||
@mail = Notifier.mentioned(@user.id, @sm.author.id, @m.id)
|
@mail = Notifier.mentioned(@user.id, @sm.author.id, @m.id)
|
||||||
end
|
end
|
||||||
it 'goes to the right person' do
|
|
||||||
|
it 'TO: goes to the right person' do
|
||||||
@mail.to.should == [@user.email]
|
@mail.to.should == [@user.email]
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'has the receivers name in the body' do
|
it 'SUBJECT: has the name of person mentioning in the subject' do
|
||||||
@mail.body.encoded.include?(@user.person.profile.first_name).should be_true
|
@mail.subject.should include(@sm.author.name)
|
||||||
end
|
|
||||||
|
|
||||||
it 'has the name of person mentioning in the body' do
|
|
||||||
@mail.body.encoded.include?(@sm.author.name).should be_true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'has the post text in the body' do
|
it 'has the post text in the body' do
|
||||||
|
|
@ -106,16 +100,16 @@ describe Notifier do
|
||||||
@mail = Notifier.liked(alice.id, @like.author.id, @like.id)
|
@mail = Notifier.liked(alice.id, @like.author.id, @like.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'goes to the right person' do
|
it 'TO: goes to the right person' do
|
||||||
@mail.to.should == [alice.email]
|
@mail.to.should == [alice.email]
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'has the receivers name in the body' do
|
it 'BODY: contains the truncated original post' do
|
||||||
@mail.body.encoded.include?(alice.person.profile.first_name).should be true
|
@mail.body.encoded.should include(@sm.formatted_message)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'has the name of person liking in the body' do
|
it 'BODY: contains the name of person liking' do
|
||||||
@mail.body.encoded.include?(@like.author.name).should be_true
|
@mail.body.encoded.should include(@like.author.name)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should not include translation missing' do
|
it 'should not include translation missing' do
|
||||||
|
|
@ -135,23 +129,28 @@ describe Notifier do
|
||||||
|
|
||||||
@mail = Notifier.private_message(user.id, @cnv.author.id, @cnv.messages.first.id)
|
@mail = Notifier.private_message(user.id, @cnv.author.id, @cnv.messages.first.id)
|
||||||
end
|
end
|
||||||
it 'goes to the right person' do
|
|
||||||
|
it 'TO: goes to the right person' do
|
||||||
@mail.to.should == [user.email]
|
@mail.to.should == [user.email]
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'has the recipients in the body' do
|
it "FROM: contains the sender's name" do
|
||||||
@mail.body.encoded.include?(user.person.first_name).should be true
|
pending
|
||||||
|
@mail.from.should == "\"#{person.name} (Diaspora)\" <#{AppConfig[:smtp_sender_address]}>"
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'has the name of the sender in the body' do
|
it 'SUBJECT: has a snippet of the post contents' do
|
||||||
@mail.body.encoded.include?(@cnv.author.name).should be true
|
@mail.subject.should == @cnv.subject
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'has the conversation subject in the body' do
|
it 'SUBJECT: has "Re:" if not the first message in a conversation' do
|
||||||
@mail.body.encoded.should include(@cnv.subject)
|
@cnv.messages << Message.new(:text => 'yo', :author => eve.person)
|
||||||
|
@mail = Notifier.private_message(user.id, @cnv.author.id, @cnv.messages.last.id)
|
||||||
|
|
||||||
|
@mail.subject.should == "Re: #{@cnv.subject}"
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'has the post text in the body' do
|
it 'BODY: contains the message text' do
|
||||||
@mail.body.encoded.should include(@cnv.messages.first.text)
|
@mail.body.encoded.should include(@cnv.messages.first.text)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -162,50 +161,61 @@ describe Notifier do
|
||||||
|
|
||||||
context "comments" do
|
context "comments" do
|
||||||
let!(:connect) { connect_users(user, aspect, user2, aspect2)}
|
let!(:connect) { connect_users(user, aspect, user2, aspect2)}
|
||||||
let!(:sm) {user.post(:status_message, :text => "Sunny outside", :to => :all)}
|
let!(:sm) {user.post(:status_message, :text => "It's really sunny outside today, and this is a super long status message! #notreally", :to => :all)}
|
||||||
let!(:comment) { user2.comment("Totally is", :post => sm )}
|
let!(:comment) { user2.comment("Totally is", :post => sm )}
|
||||||
describe ".comment_on_post" do
|
|
||||||
|
|
||||||
|
describe ".comment_on_post" do
|
||||||
let!(:comment_mail) {Notifier.comment_on_post(user.id, person.id, comment.id).deliver}
|
let!(:comment_mail) {Notifier.comment_on_post(user.id, person.id, comment.id).deliver}
|
||||||
|
|
||||||
it 'goes to the right person' do
|
it 'TO: goes to the right person' do
|
||||||
comment_mail.to.should == [user.email]
|
comment_mail.to.should == [user.email]
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'has the receivers name in the body' do
|
it "FROM: contains the sender's name" do
|
||||||
comment_mail.body.encoded.include?(user.person.profile.first_name).should be true
|
pending
|
||||||
|
comment_mail.from.should == "\"#{person.name} (Diaspora)\" <#{AppConfig[:smtp_sender_address]}>"
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'has the name of person commenting' do
|
it 'SUBJECT: has a snippet of the post contents' do
|
||||||
comment_mail.body.encoded.include?(person.name).should be true
|
comment_mail.subject.should == "Re: #{truncate(sm.text, :length => 70)}"
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'has the post link in the body' do
|
context 'BODY' do
|
||||||
comment_mail.body.encoded.include?("#{comment.post.id.to_s}").should be true
|
it "contains the comment" do
|
||||||
end
|
comment_mail.body.encoded.should include(comment.text)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "contains the original post's link" do
|
||||||
|
comment_mail.body.encoded.include?("#{comment.post.id.to_s}").should be true
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
describe ".also commented" do
|
|
||||||
|
|
||||||
|
describe ".also_commented" do
|
||||||
let!(:comment_mail) {Notifier.also_commented(user.id, person.id, comment.id)}
|
let!(:comment_mail) {Notifier.also_commented(user.id, person.id, comment.id)}
|
||||||
|
|
||||||
it 'goes to the right person' do
|
it 'TO: goes to the right person' do
|
||||||
comment_mail.to.should == [user.email]
|
comment_mail.to.should == [user.email]
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'has the receivers name in the body' do
|
it 'FROM: has the name of person commenting as the sender' do
|
||||||
comment_mail.body.encoded.include?(user.person.profile.first_name).should be true
|
pending
|
||||||
|
comment_mail.from.should == "\"#{person.name} (Diaspora)\" <#{AppConfig[:smtp_sender_address]}>"
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'has the name of person commenting' do
|
it 'SUBJECT: has a snippet of the post contents' do
|
||||||
comment_mail.body.encoded.include?(person.name).should be true
|
comment_mail.subject.should == "Re: #{truncate(sm.text, :length => 70)}"
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'has the post link in the body' do
|
context 'BODY' do
|
||||||
comment_mail.body.encoded.include?("#{comment.post.id.to_s}").should be true
|
it "contains the comment" do
|
||||||
end
|
comment_mail.body.encoded.should include(comment.text)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "contains the original post's link" do
|
||||||
|
comment_mail.body.encoded.include?("#{comment.post.id.to_s}").should be true
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue