Move comment email subject line code into models
This commit is contained in:
parent
ad5bd90b63
commit
a2043671ce
6 changed files with 23 additions and 3 deletions
|
|
@ -74,7 +74,7 @@ class Notifier < ActionMailer::Base
|
|||
I18n.with_locale(@receiver.language) do
|
||||
mail(:from => "\"#{@sender.name} (Diaspora)\" <#{AppConfig[:smtp_sender_address]}>",
|
||||
:to => "\"#{@receiver.name}\" <#{@receiver.email}>",
|
||||
:subject => "Re: #{post_message(@comment.parent, :length => TRUNCATION_LEN)}")
|
||||
:subject => "Re: #{comment_email_subject}")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -89,13 +89,16 @@ class Notifier < ActionMailer::Base
|
|||
log_mail(recipient_id, sender_id, 'comment_on_post')
|
||||
|
||||
I18n.with_locale(@receiver.language) do
|
||||
subject_message = post_message(@comment.parent, :length => TRUNCATION_LEN)
|
||||
mail(:from => "\"#{@sender.name} (Diaspora)\" <#{AppConfig[:smtp_sender_address]}>",
|
||||
:to => "\"#{@receiver.name}\" <#{@receiver.email}>",
|
||||
:subject => "Re: #{subject_message}")
|
||||
:subject => "Re: #{comment_email_subject}")
|
||||
end
|
||||
end
|
||||
|
||||
def comment_email_subject
|
||||
truncate(@comment.parent.comment_email_subject, :length => TRUNCATION_LEN)
|
||||
end
|
||||
|
||||
def private_message(recipient_id, sender_id, message_id)
|
||||
@receiver = User.find_by_id(recipient_id)
|
||||
@sender = Person.find_by_id(sender_id)
|
||||
|
|
|
|||
|
|
@ -53,5 +53,9 @@ class ActivityStreams::Photo < Post
|
|||
# A better solution is needed.
|
||||
# @return [Boolean] true
|
||||
def activity_streams?; true; end
|
||||
|
||||
def comment_email_subject
|
||||
I18n.t("photos.comment_email_subject", :name => author.name)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -117,6 +117,10 @@ class Post < ActiveRecord::Base
|
|||
false
|
||||
end
|
||||
|
||||
def comment_email_subject
|
||||
I18n.t('notifier.a_post_you_shared')
|
||||
end
|
||||
|
||||
# @return [Array<Comment>]
|
||||
def last_three_comments
|
||||
self.comments.order('created_at DESC').limit(3).includes(:author => :profile).reverse
|
||||
|
|
|
|||
|
|
@ -31,6 +31,9 @@ class Reshare < Post
|
|||
end
|
||||
end
|
||||
|
||||
def comment_email_subject
|
||||
I18n.t('reshares.comment_email_subject', :resharer => author.name, :author => root.author.name)
|
||||
end
|
||||
private
|
||||
|
||||
def after_parse
|
||||
|
|
|
|||
|
|
@ -132,6 +132,10 @@ class StatusMessage < Post
|
|||
end
|
||||
end
|
||||
|
||||
def comment_email_subject
|
||||
formatted_message(:plain_text => true)
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def message_or_photos_present?
|
||||
|
|
|
|||
|
|
@ -533,6 +533,7 @@ en:
|
|||
new_profile_photo:
|
||||
upload: "Upload a new profile photo!"
|
||||
or_select_one: "or select one from your already existing"
|
||||
comment_email_subject: "%{name}'s photo"
|
||||
|
||||
posts:
|
||||
show:
|
||||
|
|
@ -621,6 +622,7 @@ en:
|
|||
deleted: "Original post deleted by author."
|
||||
create:
|
||||
failure: "There was an error resharing this post."
|
||||
comment_email_subject: "%{resharer}'s reshare of %{author}'s post"
|
||||
services:
|
||||
index:
|
||||
logged_in_as: "logged in as"
|
||||
|
|
|
|||
Loading…
Reference in a new issue