Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/diaspora/diaspora.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/mailers')
-rw-r--r--app/mailers/export_mailer.rb37
-rw-r--r--app/mailers/maintenance.rb19
-rw-r--r--app/mailers/notification_mailers/base.rb13
-rw-r--r--app/mailers/notifier.rb29
-rw-r--r--app/mailers/report_mailer.rb5
5 files changed, 44 insertions, 59 deletions
diff --git a/app/mailers/export_mailer.rb b/app/mailers/export_mailer.rb
index da4af5f30..e7219353d 100644
--- a/app/mailers/export_mailer.rb
+++ b/app/mailers/export_mailer.rb
@@ -2,38 +2,31 @@
class ExportMailer < ApplicationMailer
def export_complete_for(user)
- @user = user
-
- mail(to: @user.email, subject: I18n.t('notifier.export_email.subject', name: @user.name)) do |format|
- format.html { render 'users/export_email' }
- format.text { render 'users/export_email' }
- end
+ send_mail(user, I18n.t("notifier.export_email.subject", name: user.name),
+ I18n.t("notifier.export_email.body", url: download_profile_user_url, name: user.first_name))
end
def export_failure_for(user)
- @user = user
-
- mail(to: @user.email, subject: I18n.t('notifier.export_failure_email.subject', name: @user.name)) do |format|
- format.html { render 'users/export_failure_email' }
- format.text { render 'users/export_failure_email' }
- end
+ send_mail(user, I18n.t("notifier.export_failure_email.subject", name: user.name),
+ I18n.t("notifier.export_failure_email.body", name: user.first_name))
end
def export_photos_complete_for(user)
- @user = user
-
- mail(to: @user.email, subject: I18n.t('notifier.export_photos_email.subject', name: @user.name)) do |format|
- format.html { render 'users/export_photos_email' }
- format.text { render 'users/export_photos_email' }
- end
+ send_mail(user, I18n.t("notifier.export_photos_email.subject", name: user.name),
+ I18n.t("notifier.export_photos_email.body", url: download_photos_user_url, name: user.first_name))
end
def export_photos_failure_for(user)
- @user = user
+ send_mail(user, I18n.t("notifier.export_photos_failure_email.subject", name: user.name),
+ I18n.t("notifier.export_photos_failure_email.body", name: user.first_name))
+ end
+
+ private
- mail(to: @user.email, subject: I18n.t('notifier.export_photos_failure_email.subject', name: @user.name)) do |format|
- format.html { render 'users/export_photos_failure_email' }
- format.text { render 'users/export_photos_failure_email' }
+ def send_mail(user, subject, body)
+ mail(to: user.email, subject: subject) do |format|
+ format.html { render "notifier/plain_markdown_email", locals: {body: body} }
+ format.text { render "notifier/plain_markdown_email", locals: {body: body} }
end
end
end
diff --git a/app/mailers/maintenance.rb b/app/mailers/maintenance.rb
index 1ff5d4ac3..5c23ce53d 100644
--- a/app/mailers/maintenance.rb
+++ b/app/mailers/maintenance.rb
@@ -2,16 +2,15 @@
class Maintenance < ApplicationMailer
def account_removal_warning(user)
- @user = user
- @login_url = new_user_session_url
- @pod_url = AppConfig.environment.url
- @after_days = AppConfig.settings.maintenance.remove_old_users.after_days.to_s
- @remove_after = @user.remove_after
-
- I18n.with_locale(@user.language) do
- mail(to: @user.email, subject: I18n.t("notifier.remove_old_user.subject")) do |format|
- format.text
- format.html
+ I18n.with_locale(user.language) do
+ body = I18n.t("notifier.remove_old_user.body",
+ pod_url: AppConfig.environment.url,
+ login_url: new_user_session_url,
+ after_days: AppConfig.settings.maintenance.remove_old_users.after_days.to_s,
+ remove_after: user.remove_after)
+ mail(to: user.email, subject: I18n.t("notifier.remove_old_user.subject")) do |format|
+ format.text { render "notifier/plain_markdown_email", locals: {body: body} }
+ format.html { render "notifier/plain_markdown_email", locals: {body: body} }
end
end
end
diff --git a/app/mailers/notification_mailers/base.rb b/app/mailers/notification_mailers/base.rb
index 8aa3d28c6..e4f56eb4b 100644
--- a/app/mailers/notification_mailers/base.rb
+++ b/app/mailers/notification_mailers/base.rb
@@ -35,16 +35,13 @@ module NotificationMailers
private
def default_headers
- headers = {
- from: "\"#{AppConfig.settings.pod_name}\" <#{AppConfig.mail.sender_address}>",
- host: "#{AppConfig.pod_uri.host}",
+ from_name = AppConfig.settings.pod_name
+ from_name += " (#{@sender.profile.full_name.empty? ? @sender.username : @sender.name})" if @sender.present?
+
+ {
+ from: name_and_address(from_name, AppConfig.mail.sender_address),
to: name_and_address(@recipient.name, @recipient.email)
}
- return headers if @sender.blank?
- sender_in_header = @sender.profile.full_name.empty? ? @sender.username : @sender.name
- headers[:from] = "\"#{AppConfig.settings.pod_name} (#{sender_in_header})\" <#{AppConfig.mail.sender_address}>"
-
- headers
end
def with_recipient_locale(&block)
diff --git a/app/mailers/notifier.rb b/app/mailers/notifier.rb
index 47c3b71bf..977883985 100644
--- a/app/mailers/notifier.rb
+++ b/app/mailers/notifier.rb
@@ -24,33 +24,28 @@ class Notifier < ApplicationMailer
}
end
- unless subject
- subject = I18n.t('notifier.single_admin.subject')
- end
+ subject ||= I18n.t("notifier.single_admin.subject")
- default_opts = {:to => @receiver.email,
- :from => AppConfig.mail.sender_address,
- :subject => subject, :host => AppConfig.pod_uri.host}
+ default_opts = {to: @receiver.email, from: AppConfig.mail.sender_address, subject: subject}
default_opts.merge!(opts)
- mail(default_opts) do |format|
- format.text
- format.html
- end
+ mail(default_opts)
end
def invite(email, inviter, invitation_code, locale)
- @inviter = inviter
- @invitation_code = invitation_code
-
I18n.with_locale(locale) do
mail_opts = {to: email, from: "\"#{AppConfig.settings.pod_name}\" <#{AppConfig.mail.sender_address}>",
- subject: I18n.t("notifier.invited_you", name: @inviter.name),
- host: AppConfig.pod_uri.host}
+ subject: I18n.t("notifier.invited_you", name: inviter.name)}
+ name = inviter.full_name.empty? ? inviter.diaspora_handle : "#{inviter.name} (#{inviter.diaspora_handle})"
+ body = I18n.t("notifier.invite.message",
+ invite_url: invite_code_url(invitation_code),
+ diasporafoundation_url: "https://diasporafoundation.org/",
+ user: name,
+ diaspora_id: inviter.diaspora_handle)
mail(mail_opts) do |format|
- format.text { render :layout => nil }
- format.html { render :layout => nil }
+ format.text { render "notifier/plain_markdown_email", layout: nil, locals: {body: body} }
+ format.html { render "notifier/plain_markdown_email", layout: nil, locals: {body: body} }
end
end
end
diff --git a/app/mailers/report_mailer.rb b/app/mailers/report_mailer.rb
index 507e02600..ad69332fd 100644
--- a/app/mailers/report_mailer.rb
+++ b/app/mailers/report_mailer.rb
@@ -26,9 +26,10 @@ class ReportMailer < ApplicationMailer
private
def format(resource)
+ body = I18n.t("notifier.report_email.body", resource)
mail(to: resource[:email], subject: I18n.t("notifier.report_email.subject", type: resource[:type])) do |format|
- format.html { render "report/report_email", locals: {resource: resource} }
- format.text { render "report/report_email", locals: {resource: resource} }
+ format.html { render "notifier/plain_markdown_email", locals: {body: body} }
+ format.text { render "notifier/plain_markdown_email", locals: {body: body} }
end
end
end