diff options
author | Benjamin Neff <benjamin@coding4coffee.ch> | 2022-07-16 05:44:59 +0300 |
---|---|---|
committer | Benjamin Neff <benjamin@coding4coffee.ch> | 2022-07-16 05:44:59 +0300 |
commit | 5669ba6b48f2488e394789bc6fb8504358e966b7 (patch) | |
tree | d6a9e81d424f3e3003262de74a7fcbb40a995751 /app | |
parent | c6dda6cf2d776eb1be2ba02a554c2ea1fc4131a4 (diff) | |
parent | a5e5c7f3782e83d527b9b28a0e8f46fb1f83389b (diff) |
Merge branch 'next-minor' into develop
Diffstat (limited to 'app')
65 files changed, 249 insertions, 236 deletions
diff --git a/app/helpers/notifier_helper.rb b/app/helpers/notifier_helper.rb index e7a05af5f..9edcea043 100644 --- a/app/helpers/notifier_helper.rb +++ b/app/helpers/notifier_helper.rb @@ -4,21 +4,19 @@ module NotifierHelper include PostsHelper # @param post [Post] The post object. - # @param opts [Hash] Optional hash. Accepts :length parameters. + # @param opts [Hash] Optional hash. Accepts :html parameter. # @return [String] The formatted post. def post_message(post, opts={}) - if post.respond_to? :message - post.message.try(:plain_text_without_markdown).presence || post_page_title(post) - else - I18n.translate "notifier.a_post_you_shared" - end + rendered = opts[:html] ? post.message&.markdownified_for_mail : post.message&.plain_text_without_markdown + rendered.presence || post_page_title(post) end # @param comment [Comment] The comment to process. + # @param opts [Hash] Optional hash. Accepts :html parameter. # @return [String] The formatted comment. def comment_message(comment, opts={}) if comment.post.public? - comment.message.plain_text_without_markdown + opts[:html] ? comment.message.markdownified_for_mail : comment.message.plain_text_without_markdown else I18n.translate "notifier.a_limited_post_comment" end diff --git a/app/helpers/people_helper.rb b/app/helpers/people_helper.rb index 1a08bd6af..16b8eb823 100644 --- a/app/helpers/people_helper.rb +++ b/app/helpers/people_helper.rb @@ -27,10 +27,10 @@ module PeopleHelper def person_link(person, opts={}) css_class = person_link_class(person, opts[:class]) - remote_or_hovercard_link = Rails.application.routes.url_helpers.person_path(person).html_safe - "<a data-hovercard='#{remote_or_hovercard_link}' href='#{remote_or_hovercard_link}' class='#{css_class}'>"\ - "#{html_escape_once(opts[:display_name] || person.name)}</a>"\ - .html_safe + remote_or_hovercard_link = person_path(person) + tag.a('data-hovercard': remote_or_hovercard_link, href: remote_or_hovercard_link, class: css_class) do + opts[:display_name] || person.name + end end def person_image_tag(person, size = :thumb_small) @@ -44,15 +44,12 @@ module PeopleHelper if opts[:to] == :photos link_to person_image_tag(person, opts[:size]), person_photos_path(person) else - css_class = person_link_class(person, opts[:class]) - remote_or_hovercard_link = Rails.application.routes.url_helpers.person_path(person).html_safe - "<a href='#{remote_or_hovercard_link}' class='#{css_class}' #{('target=' + opts[:target]) if opts[:target]}> - #{person_image_tag(person, opts[:size])} - </a>".html_safe + tag.a(href: person_path(person), class: person_link_class(person, opts[:class])) do + person_image_tag(person, opts[:size]) + end end end - # Rails.application.routes.url_helpers is needed since this is indirectly called from a model def local_or_remote_person_path(person, opts={}) opts.merge!(:protocol => AppConfig.pod_uri.scheme, :host => AppConfig.pod_uri.authority) absolute = opts.delete(:absolute) @@ -61,19 +58,11 @@ module PeopleHelper username = person.username unless username.include?('.') opts.merge!(:username => username) - if absolute - return Rails.application.routes.url_helpers.user_profile_url(opts) - else - return Rails.application.routes.url_helpers.user_profile_path(opts) - end + return absolute ? user_profile_url(opts) : user_profile_path(opts) end end - if absolute - return Rails.application.routes.url_helpers.person_url(person, opts) - else - return Rails.application.routes.url_helpers.person_path(person, opts) - end + absolute ? person_url(person, opts) : person_path(person, opts) end private 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 diff --git a/app/views/devise/mailer/confirmation_instructions.html.haml b/app/views/devise/mailer/confirmation_instructions.html.haml new file mode 100644 index 000000000..f1824c54f --- /dev/null +++ b/app/views/devise/mailer/confirmation_instructions.html.haml @@ -0,0 +1,6 @@ +%p + = t("devise.mailer.welcome", username: @resource.username) +%p + = t(".you_can_confirm") +%p + = link_to t(".confirm"), confirmation_url(@resource, confirmation_token: @token) diff --git a/app/views/devise/mailer/confirmation_instructions.markerb b/app/views/devise/mailer/confirmation_instructions.markerb deleted file mode 100644 index 6e0211f1f..000000000 --- a/app/views/devise/mailer/confirmation_instructions.markerb +++ /dev/null @@ -1,7 +0,0 @@ -<%= t('devise.mailer.welcome', username: @resource.username) %> - -<%= t('.you_can_confirm') %> - -[<%= t('.confirm') %>][1] - -[1]: <%= confirmation_url(@resource, confirmation_token: @token) %> diff --git a/app/views/devise/mailer/confirmation_instructions.text.erb b/app/views/devise/mailer/confirmation_instructions.text.erb new file mode 100644 index 000000000..9ce086053 --- /dev/null +++ b/app/views/devise/mailer/confirmation_instructions.text.erb @@ -0,0 +1,4 @@ +<%= t("devise.mailer.welcome", username: @resource.username) %> + +<%= t(".you_can_confirm") %> +<%= confirmation_url(@resource, confirmation_token: @token) %> diff --git a/app/views/devise/mailer/invitation_instructions.markerb b/app/views/devise/mailer/invitation_instructions.markerb deleted file mode 100644 index 8d39da1c6..000000000 --- a/app/views/devise/mailer/invitation_instructions.markerb +++ /dev/null @@ -1 +0,0 @@ -<%= t('.message', :invite_url => invite_code_url(@invitation_code)) %> diff --git a/app/views/devise/mailer/reset_password_instructions.html.haml b/app/views/devise/mailer/reset_password_instructions.html.haml new file mode 100644 index 000000000..0c8f44a3f --- /dev/null +++ b/app/views/devise/mailer/reset_password_instructions.html.haml @@ -0,0 +1,12 @@ +%p + = t("devise.mailer.hello", username: @resource.username) +%p + = t(".someone_requested") +%p + = link_to t(".change"), edit_password_url(@resource, reset_password_token: @token) +%p + = t(".then_connect", username: @resource.username) +%p + = t(".wont_change") +%p + = t(".ignore") diff --git a/app/views/devise/mailer/reset_password_instructions.markerb b/app/views/devise/mailer/reset_password_instructions.markerb deleted file mode 100644 index ac800dd25..000000000 --- a/app/views/devise/mailer/reset_password_instructions.markerb +++ /dev/null @@ -1,13 +0,0 @@ -<%= t('devise.mailer.hello', username: @resource.username) %> - -<%= t('.someone_requested') %> - -[<%= t('.change') %>][1] - -[1]: <%= edit_password_url(@resource, reset_password_token: @token) %> - -<%= t('.then_connect', username: @resource.username) %> - -<%= t('.wont_change') %> - -<%= t('.ignore') %> diff --git a/app/views/devise/mailer/reset_password_instructions.text.erb b/app/views/devise/mailer/reset_password_instructions.text.erb new file mode 100644 index 000000000..48f1dfee4 --- /dev/null +++ b/app/views/devise/mailer/reset_password_instructions.text.erb @@ -0,0 +1,11 @@ +<%= t("devise.mailer.hello", username: @resource.username) %> + +<%= t(".someone_requested") %> + +<%= t(".change") %>: <%= edit_password_url(@resource, reset_password_token: @token) %> + +<%= t(".then_connect", username: @resource.username) %> + +<%= t(".wont_change") %> + +<%= t(".ignore") %> diff --git a/app/views/devise/mailer/unlock_instructions.html.haml b/app/views/devise/mailer/unlock_instructions.html.haml new file mode 100644 index 000000000..c16e8dee7 --- /dev/null +++ b/app/views/devise/mailer/unlock_instructions.html.haml @@ -0,0 +1,8 @@ +%p + = t("devise.mailer.hello", username: @resource.username) +%p + = t(".account_locked") +%p + = t(".click_to_unlock") +%p + = link_to t(".unlock"), unlock_url(@resource, unlock_token: @token) diff --git a/app/views/devise/mailer/unlock_instructions.markerb b/app/views/devise/mailer/unlock_instructions.markerb deleted file mode 100644 index d207a1bb9..000000000 --- a/app/views/devise/mailer/unlock_instructions.markerb +++ /dev/null @@ -1,9 +0,0 @@ -<%= t('devise.mailer.hello', username: @resource.username) %> - -<%= t('.account_locked') %> - -<%= t('.click_to_unlock') %> - -[<%= t('.unlock') %>][1] - -[1]: <%= unlock_url(@resource, unlock_token: @token) %> diff --git a/app/views/devise/mailer/unlock_instructions.text.erb b/app/views/devise/mailer/unlock_instructions.text.erb new file mode 100644 index 000000000..e89aa4353 --- /dev/null +++ b/app/views/devise/mailer/unlock_instructions.text.erb @@ -0,0 +1,6 @@ +<%= t("devise.mailer.hello", username: @resource.username) %> + +<%= t(".account_locked") %> + +<%= t(".click_to_unlock") %> +<%= unlock_url(@resource, unlock_token: @token) %> diff --git a/app/views/layouts/notifier.html.haml b/app/views/layouts/notifier.html.haml index 12172a606..c547f285c 100644 --- a/app/views/layouts/notifier.html.haml +++ b/app/views/layouts/notifier.html.haml @@ -1,7 +1,7 @@ %table{cellspacing: 0, cellpadding: 0, border: 0, style: "font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px"} %tr - - if @notification.try(:sender) + - if @notification&.sender.present? %td{width: "60px", style: "vertical-align: top"}> %div{style: "background-color: #eee; height: 50px; width: 50px"} = image_tag @notification.sender.profile.image_url(size: :thumb_small), alt: @notification.sender.name, diff --git a/app/views/layouts/notifier.text.haml b/app/views/layouts/notifier.text.haml index e018e0311..8a7a083a5 100644 --- a/app/views/layouts/notifier.text.haml +++ b/app/views/layouts/notifier.text.haml @@ -1,4 +1,5 @@ != yield + +!= "-- " != t("notifier.email_sent_by_diaspora", pod_name: pod_name) -!= t("notifier.to_change_your_notification_settings") -!= edit_user_url +!= "#{t('notifier.to_change_your_notification_settings')}: #{edit_user_url}" diff --git a/app/views/maintenance/account_removal_warning.markerb b/app/views/maintenance/account_removal_warning.markerb deleted file mode 100644 index 7303bafae..000000000 --- a/app/views/maintenance/account_removal_warning.markerb +++ /dev/null @@ -1,2 +0,0 @@ -<%= t('notifier.remove_old_user.body', pod_url: @pod_url, login_url: @login_url, after_days: @after_days, remove_after: @remove_after) %> - diff --git a/app/views/notifier/_notifier_css.haml b/app/views/notifier/_notifier_css.haml deleted file mode 100644 index 4ca518b2d..000000000 --- a/app/views/notifier/_notifier_css.haml +++ /dev/null @@ -1,28 +0,0 @@ -:css - body{ - width:600px; - font-family: 'Helvetica',sans-serif; - } - #container{ - } - header{ - margin-bottom: 25px; - } - p{ - padding:5px; - } - p.small{ - font-size:smaller; - color:#999; - font-style:italic; - } - a{ - color:#107FC9; - font-weight:bold; - } - a:hover{ - color: #22AAE0; - } - a:active{ - color: #005D9C; - } diff --git a/app/views/notifier/also_commented.html.haml b/app/views/notifier/also_commented.html.haml new file mode 100644 index 000000000..ec6fdfc94 --- /dev/null +++ b/app/views/notifier/also_commented.html.haml @@ -0,0 +1,4 @@ += comment_message(@notification.comment, html: true) +%p + = link_to t("notifier.comment_on_post.reply", name: @notification.comment.post.author_first_name), + post_url(@notification.comment.post, anchor: @notification.comment.guid) diff --git a/app/views/notifier/also_commented.markerb b/app/views/notifier/also_commented.markerb deleted file mode 100644 index 8c5023664..000000000 --- a/app/views/notifier/also_commented.markerb +++ /dev/null @@ -1,5 +0,0 @@ -<%= comment_message(@notification.comment, :process_newlines => true) %> - -[<%= t('notifier.comment_on_post.reply', :name => @notification.comment_post.author_first_name) %>][1] - -[1]: <%= post_url(@notification.comment_post, anchor: @notification.comment.guid) %> diff --git a/app/views/notifier/also_commented.text.erb b/app/views/notifier/also_commented.text.erb new file mode 100644 index 000000000..bce14edd8 --- /dev/null +++ b/app/views/notifier/also_commented.text.erb @@ -0,0 +1,4 @@ +<%= comment_message(@notification.comment) %> + +<%= t("notifier.comment_on_post.reply", name: @notification.comment.post.author_first_name) %> +<%= post_url(@notification.comment.post, anchor: @notification.comment.guid) %> diff --git a/app/views/notifier/comment_on_post.html.haml b/app/views/notifier/comment_on_post.html.haml new file mode 100644 index 000000000..ec6fdfc94 --- /dev/null +++ b/app/views/notifier/comment_on_post.html.haml @@ -0,0 +1,4 @@ += comment_message(@notification.comment, html: true) +%p + = link_to t("notifier.comment_on_post.reply", name: @notification.comment.post.author_first_name), + post_url(@notification.comment.post, anchor: @notification.comment.guid) diff --git a/app/views/notifier/comment_on_post.markerb b/app/views/notifier/comment_on_post.markerb deleted file mode 100644 index 7d4d86802..000000000 --- a/app/views/notifier/comment_on_post.markerb +++ /dev/null @@ -1,5 +0,0 @@ -<%= comment_message(@notification.comment, :process_newlines => true) %> - -[<%= t('notifier.comment_on_post.reply', :name => @notification.comment.parent_author_name) %>][1] - -[1]: <%= post_url(@notification.comment.post, anchor: @notification.comment.guid) %> diff --git a/app/views/notifier/comment_on_post.text.erb b/app/views/notifier/comment_on_post.text.erb new file mode 100644 index 000000000..bce14edd8 --- /dev/null +++ b/app/views/notifier/comment_on_post.text.erb @@ -0,0 +1,4 @@ +<%= comment_message(@notification.comment) %> + +<%= t("notifier.comment_on_post.reply", name: @notification.comment.post.author_first_name) %> +<%= post_url(@notification.comment.post, anchor: @notification.comment.guid) %> diff --git a/app/views/notifier/confirm_email.html.haml b/app/views/notifier/confirm_email.html.haml new file mode 100644 index 000000000..87e334688 --- /dev/null +++ b/app/views/notifier/confirm_email.html.haml @@ -0,0 +1,6 @@ +%p + = t("notifier.hello", name: @notification.recipient_first_name) +%p + = t("notifier.confirm_email.click_link", unconfirmed_email: @notification.recipient_unconfirmed_email) +%p + = link_to nil, confirm_email_url(token: @notification.recipient_confirm_email_token) diff --git a/app/views/notifier/confirm_email.markerb b/app/views/notifier/confirm_email.markerb deleted file mode 100644 index 6b32bfa0a..000000000 --- a/app/views/notifier/confirm_email.markerb +++ /dev/null @@ -1,5 +0,0 @@ -<%= t('notifier.hello', :name => @notification.recipient_first_name) %> - -<%= t('notifier.confirm_email.click_link', :unconfirmed_email => @notification.recipient_unconfirmed_email) %> - -<<%= confirm_email_url(:token => @notification.recipient_confirm_email_token) %>> diff --git a/app/views/notifier/confirm_email.text.erb b/app/views/notifier/confirm_email.text.erb new file mode 100644 index 000000000..4b310db63 --- /dev/null +++ b/app/views/notifier/confirm_email.text.erb @@ -0,0 +1,5 @@ +<%= t("notifier.hello", name: @notification.recipient_first_name) %> + +<%= t("notifier.confirm_email.click_link", unconfirmed_email: @notification.recipient_unconfirmed_email) %> + +<%= confirm_email_url(token: @notification.recipient_confirm_email_token) %> diff --git a/app/views/notifier/contacts_birthday.html.haml b/app/views/notifier/contacts_birthday.html.haml new file mode 100644 index 000000000..4402cf41d --- /dev/null +++ b/app/views/notifier/contacts_birthday.html.haml @@ -0,0 +1,5 @@ +%p + = t(".birthday", name: @notification.person.name) +%p + = link_to t(".view_profile", name: @notification.person.first_name), + local_or_remote_person_path(@notification.person, absolute: true) diff --git a/app/views/notifier/contacts_birthday.markerb b/app/views/notifier/contacts_birthday.markerb deleted file mode 100644 index ee4d27770..000000000 --- a/app/views/notifier/contacts_birthday.markerb +++ /dev/null @@ -1,6 +0,0 @@ - -<%= t(".birthday", name: @notification.person.name) %> - -[<%= t(".view_profile", name: @notification.person.name) %>][1] - -[1]: <%= local_or_remote_person_path(@notification.person, absolute: true) %> diff --git a/app/views/notifier/contacts_birthday.text.erb b/app/views/notifier/contacts_birthday.text.erb new file mode 100644 index 000000000..773fc41c1 --- /dev/null +++ b/app/views/notifier/contacts_birthday.text.erb @@ -0,0 +1,4 @@ +<%= t(".birthday", name: @notification.person.name) %> + +<%= t(".view_profile", name: @notification.person.first_name) %> +<%= local_or_remote_person_path(@notification.person, absolute: true) %> diff --git a/app/views/notifier/csrf_token_fail.html.haml b/app/views/notifier/csrf_token_fail.html.haml new file mode 100644 index 000000000..08c27d4b9 --- /dev/null +++ b/app/views/notifier/csrf_token_fail.html.haml @@ -0,0 +1,4 @@ +- message = t("notifier.csrf_token_fail.body", + name: @notification.recipient_first_name, + link: "https://owasp.org/www-community/attacks/csrf") +!= Redcarpet::Markdown.new(Diaspora::Markdownify::Email).render(message) diff --git a/app/views/notifier/csrf_token_fail.markerb b/app/views/notifier/csrf_token_fail.markerb deleted file mode 100644 index 22f3164ea..000000000 --- a/app/views/notifier/csrf_token_fail.markerb +++ /dev/null @@ -1 +0,0 @@ -<%= t("notifier.csrf_token_fail.body", name: @notification.recipient_first_name, link: "https://www.owasp.org/index.php/Cross-Site_Request_Forgery_(CSRF)") %> diff --git a/app/views/notifier/csrf_token_fail.text.erb b/app/views/notifier/csrf_token_fail.text.erb new file mode 100644 index 000000000..ef034ed02 --- /dev/null +++ b/app/views/notifier/csrf_token_fail.text.erb @@ -0,0 +1,3 @@ +<%= t("notifier.csrf_token_fail.body", + name: @notification.recipient_first_name, + link: "https://owasp.org/www-community/attacks/csrf") %> diff --git a/app/views/notifier/invite.markerb b/app/views/notifier/invite.markerb deleted file mode 100644 index 8c20a00c0..000000000 --- a/app/views/notifier/invite.markerb +++ /dev/null @@ -1,6 +0,0 @@ -<%= t('.message', - invite_url: invite_code_url(@invitation_code), - diasporafoundation_url: 'https://diasporafoundation.org/', - user: @inviter.try(:full_name).empty? ? @inviter.try(:diaspora_handle) : "#{@inviter.name} (#{@inviter.diaspora_handle})", - diaspora_id: @inviter.try(:diaspora_handle)) -%> diff --git a/app/views/notifier/liked.html.haml b/app/views/notifier/liked.html.haml new file mode 100644 index 000000000..96cf3770f --- /dev/null +++ b/app/views/notifier/liked.html.haml @@ -0,0 +1,10 @@ +- if @notification.like_target.public? + %p + #{t('.liked', name: @notification.sender_name)}: + = post_message(@notification.like_target, html: true) +- else + %p + #{t('notifier.liked.limited_post', name: @notification.sender_name)}. + +%p + = link_to t(".view_post"), post_url(@notification.like_target) diff --git a/app/views/notifier/liked.markerb b/app/views/notifier/liked.markerb deleted file mode 100644 index 8ed88a979..000000000 --- a/app/views/notifier/liked.markerb +++ /dev/null @@ -1,11 +0,0 @@ -<% if @notification.like_target.public? %> -<%= "#{t('.liked', :name => "#{@notification.sender_name}")}:" %> - -<%= post_message(@notification.like_target, :process_newlines => true) %> -<% else %> -<%= "#{t('notifier.liked.limited_post', :name => "#{@notification.sender_name}")}." %> -<% end %> - -[<%= t('.view_post') %>][1] - -[1]: <%= post_url(@notification.like_target) %> diff --git a/app/views/notifier/liked.text.erb b/app/views/notifier/liked.text.erb new file mode 100644 index 000000000..ce743ade3 --- /dev/null +++ b/app/views/notifier/liked.text.erb @@ -0,0 +1,10 @@ +<% if @notification.like_target.public? %> +<%= "#{t(".liked", name: @notification.sender_name)}:" %> + +<%= post_message(@notification.like_target) %> +<% else %> +<%= "#{t("notifier.liked.limited_post", name: @notification.sender_name)}." %> +<% end %> + +<%= t(".view_post") %> +<%= post_url(@notification.like_target) %> diff --git a/app/views/notifier/mentioned.html.haml b/app/views/notifier/mentioned.html.haml new file mode 100644 index 000000000..715de7647 --- /dev/null +++ b/app/views/notifier/mentioned.html.haml @@ -0,0 +1,9 @@ +- if @notification.post.public? + = post_message(@notification.post, html: true) +- else + %p + = t("notifier.mentioned.limited_post") + +%p + = link_to t("notifier.comment_on_post.reply", name: @notification.post.author_first_name), + post_url(@notification.post) diff --git a/app/views/notifier/mentioned.markerb b/app/views/notifier/mentioned.markerb deleted file mode 100644 index 414739665..000000000 --- a/app/views/notifier/mentioned.markerb +++ /dev/null @@ -1,9 +0,0 @@ -<% if @notification.post.public? %> -<%= post_message(@notification.post, :process_newlines => true) %> -<% else %> -<%= t('notifier.mentioned.limited_post') %> -<% end %> - -[<%= t("notifier.comment_on_post.reply", name: @notification.post_author_name) %>][1] - -[1]: <%= post_url(@notification.post) %> diff --git a/app/views/notifier/mentioned.text.erb b/app/views/notifier/mentioned.text.erb new file mode 100644 index 000000000..fbce0dbb4 --- /dev/null +++ b/app/views/notifier/mentioned.text.erb @@ -0,0 +1,8 @@ +<% if @notification.post.public? %> +<%= post_message(@notification.post) %> +<% else %> +<%= t("notifier.mentioned.limited_post") %> +<% end %> + +<%= t("notifier.comment_on_post.reply", name: @notification.post.author_first_name) %> +<%= post_url(@notification.post) %> diff --git a/app/views/notifier/mentioned_in_comment.html.haml b/app/views/notifier/mentioned_in_comment.html.haml new file mode 100644 index 000000000..89d04cb49 --- /dev/null +++ b/app/views/notifier/mentioned_in_comment.html.haml @@ -0,0 +1,9 @@ +- if @notification.comment.public? + = @notification.comment.message.markdownified_for_mail +- else + %p + = t("notifier.mentioned_in_comment.limited_post") + +%p + = link_to t("notifier.mentioned_in_comment.reply"), + post_url(@notification.comment.post, anchor: @notification.comment.guid) diff --git a/app/views/notifier/mentioned_in_comment.markerb b/app/views/notifier/mentioned_in_comment.text.erb index 3b86f409b..8f327a2a6 100644 --- a/app/views/notifier/mentioned_in_comment.markerb +++ b/app/views/notifier/mentioned_in_comment.text.erb @@ -4,6 +4,5 @@ <%= t("notifier.mentioned_in_comment.limited_post") %> <% end %> -[<%= t("notifier.mentioned_in_comment.reply") %>][1] - -[1]: <%= post_url(@notification.comment.parent, anchor: @notification.comment.guid) %> +<%= t("notifier.mentioned_in_comment.reply") %> +<%= post_url(@notification.comment.parent, anchor: @notification.comment.guid) %> diff --git a/app/views/notifier/plain_markdown_email.html.haml b/app/views/notifier/plain_markdown_email.html.haml new file mode 100644 index 000000000..a102d4ecb --- /dev/null +++ b/app/views/notifier/plain_markdown_email.html.haml @@ -0,0 +1,2 @@ +%div{style: "font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px"} + != Redcarpet::Markdown.new(Diaspora::Markdownify::Email).render(body) diff --git a/app/views/notifier/plain_markdown_email.text.haml b/app/views/notifier/plain_markdown_email.text.haml new file mode 100644 index 000000000..d2059e444 --- /dev/null +++ b/app/views/notifier/plain_markdown_email.text.haml @@ -0,0 +1 @@ +!= body diff --git a/app/views/notifier/private_message.html.haml b/app/views/notifier/private_message.html.haml new file mode 100644 index 000000000..bd4eb72f0 --- /dev/null +++ b/app/views/notifier/private_message.html.haml @@ -0,0 +1,4 @@ +%p + = t("notifier.a_private_message") +%p + = link_to t(".reply_to_or_view"), conversations_url(conversation_id: @notification.conversation) diff --git a/app/views/notifier/private_message.markerb b/app/views/notifier/private_message.markerb deleted file mode 100644 index e41a38cb4..000000000 --- a/app/views/notifier/private_message.markerb +++ /dev/null @@ -1,5 +0,0 @@ -<%= t('notifier.a_private_message') %> - -[<%= t('.reply_to_or_view') %>][1] - -[1]: <%= conversations_url(:conversation_id => @notification.conversation) %> diff --git a/app/views/notifier/private_message.text.erb b/app/views/notifier/private_message.text.erb new file mode 100644 index 000000000..6751ea454 --- /dev/null +++ b/app/views/notifier/private_message.text.erb @@ -0,0 +1,4 @@ +<%= t("notifier.a_private_message") %> + +<%= t(".reply_to_or_view") %> +<%= conversations_url(conversation_id: @notification.conversation) %> diff --git a/app/views/notifier/reshared.html.haml b/app/views/notifier/reshared.html.haml new file mode 100644 index 000000000..1450775e9 --- /dev/null +++ b/app/views/notifier/reshared.html.haml @@ -0,0 +1,5 @@ +%p + #{t('.reshared', name: @notification.sender_name)}: += post_message(@notification.reshare_root, html: true) +%p + = link_to t(".view_post"), post_url(@notification.reshare) diff --git a/app/views/notifier/reshared.markerb b/app/views/notifier/reshared.markerb deleted file mode 100644 index a1c43c6a1..000000000 --- a/app/views/notifier/reshared.markerb +++ /dev/null @@ -1,7 +0,0 @@ -<%= "#{t('.reshared', :name => "#{@notification.sender_name}")}:" %> - -<%= post_message(@notification.reshare_root, :process_newlines => true) %> - -[<%= t('.view_post') %>][1] - -[1]: <%= post_url(@notification.reshare) %> diff --git a/app/views/notifier/reshared.text.erb b/app/views/notifier/reshared.text.erb new file mode 100644 index 000000000..320b626b6 --- /dev/null +++ b/app/views/notifier/reshared.text.erb @@ -0,0 +1,6 @@ +<%= "#{t(".reshared", name: @notification.sender_name)}:" %> + +<%= post_message(@notification.reshare_root) %> + +<%= t(".view_post") %> +<%= post_url(@notification.reshare) %> diff --git a/app/views/notifier/single_admin.html.haml b/app/views/notifier/single_admin.html.haml new file mode 100644 index 000000000..304e2fb92 --- /dev/null +++ b/app/views/notifier/single_admin.html.haml @@ -0,0 +1,8 @@ +%p + = t("notifier.hello", name: @receiver.username) +%p + = @string +%p + = t("notifier.thanks") + %br/ + = t("notifier.single_admin.admin") diff --git a/app/views/notifier/single_admin.markerb b/app/views/notifier/single_admin.markerb deleted file mode 100644 index 0b9f23749..000000000 --- a/app/views/notifier/single_admin.markerb +++ /dev/null @@ -1,7 +0,0 @@ -<%= t('notifier.hello', :name => @receiver.username) %> - -<%= @string %> - -<%= t('notifier.thanks') %> - -<%= t('notifier.single_admin.admin') %> diff --git a/app/views/notifier/single_admin.text.erb b/app/views/notifier/single_admin.text.erb new file mode 100644 index 000000000..ed2c0a4e4 --- /dev/null +++ b/app/views/notifier/single_admin.text.erb @@ -0,0 +1,6 @@ +<%= t("notifier.hello", name: @receiver.username) %> + +<%= @string %> + +<%= t("notifier.thanks") %> +<%= t("notifier.single_admin.admin") %> diff --git a/app/views/notifier/started_sharing.html.haml b/app/views/notifier/started_sharing.html.haml new file mode 100644 index 000000000..bb5084ba7 --- /dev/null +++ b/app/views/notifier/started_sharing.html.haml @@ -0,0 +1,7 @@ +%p + = @notification.sender_name + = t(".sharing") + +%p + = link_to t(".view_profile", name: @notification.sender_first_name), + local_or_remote_person_path(@notification.sender, absolute: true) diff --git a/app/views/notifier/started_sharing.markerb b/app/views/notifier/started_sharing.markerb deleted file mode 100644 index d5e16d74c..000000000 --- a/app/views/notifier/started_sharing.markerb +++ /dev/null @@ -1,5 +0,0 @@ -<%= @notification.sender_name %> <%= t('.sharing') %> - -[<%= t('.view_profile', :name => @notification.sender_first_name) %>][1] - -[1]: <%= local_or_remote_person_path(@notification.sender, :absolute => true) %> diff --git a/app/views/notifier/started_sharing.text.erb b/app/views/notifier/started_sharing.text.erb new file mode 100644 index 000000000..6218f8d9e --- /dev/null +++ b/app/views/notifier/started_sharing.text.erb @@ -0,0 +1,4 @@ +<%= @notification.sender_name %> <%= t(".sharing") %> + +<%= t(".view_profile", name: @notification.sender_first_name) %> +<%= local_or_remote_person_path(@notification.sender, absolute: true) %> diff --git a/app/views/report/report_email.markerb b/app/views/report/report_email.markerb deleted file mode 100644 index 2729aa96b..000000000 --- a/app/views/report/report_email.markerb +++ /dev/null @@ -1,5 +0,0 @@ -<%= t("notifier.report_email.body", - url: resource[:url], - type: resource[:type], - id: resource[:id], - reason: resource[:reason]) %> diff --git a/app/views/users/export_email.markerb b/app/views/users/export_email.markerb deleted file mode 100644 index c345ae67a..000000000 --- a/app/views/users/export_email.markerb +++ /dev/null @@ -1 +0,0 @@ -<%= t('notifier.export_email.body', url: download_profile_user_url, name: @user.first_name) %> diff --git a/app/views/users/export_failure_email.markerb b/app/views/users/export_failure_email.markerb deleted file mode 100644 index 33da52efb..000000000 --- a/app/views/users/export_failure_email.markerb +++ /dev/null @@ -1 +0,0 @@ -<%= t('notifier.export_failure_email.body', name: @user.first_name) %> diff --git a/app/views/users/export_photos_email.markerb b/app/views/users/export_photos_email.markerb deleted file mode 100644 index 24bc4fd1d..000000000 --- a/app/views/users/export_photos_email.markerb +++ /dev/null @@ -1 +0,0 @@ -<%= t('notifier.export_photos_email.body', url: download_photos_user_url, name: @user.first_name) %> diff --git a/app/views/users/export_photos_failure_email.markerb b/app/views/users/export_photos_failure_email.markerb deleted file mode 100644 index 2067327c9..000000000 --- a/app/views/users/export_photos_failure_email.markerb +++ /dev/null @@ -1 +0,0 @@ -<%= t('notifier.export_photos_failure_email.body', name: @user.first_name) %> diff --git a/app/workers/export_photos.rb b/app/workers/export_photos.rb index 2fe4c007f..cf62cd144 100644 --- a/app/workers/export_photos.rb +++ b/app/workers/export_photos.rb @@ -4,7 +4,6 @@ # licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file. - module Workers class ExportPhotos < Base sidekiq_options queue: :low @@ -14,9 +13,9 @@ module Workers @user.perform_export_photos! if @user.reload.exported_photos_file.present? - ExportMailer.export_photos_complete_for(@user) + ExportMailer.export_photos_complete_for(@user).deliver_now else - ExportMailer.export_photos_failure_for(@user) + ExportMailer.export_photos_failure_for(@user).deliver_now end end end |