From 5222d41546162acd8edf6bdd8e9e68db9b31e7d3 Mon Sep 17 00:00:00 2001 From: Essem Date: Fri, 10 Nov 2023 15:16:29 -0600 Subject: [PATCH] Add notification emails for reactions --- app/javascript/images/mailer/icon_add.png | Bin 0 -> 1417 bytes app/mailers/notification_mailer.rb | 13 ++++- app/models/user_settings.rb | 1 + .../notification_mailer/reaction.html.haml | 45 ++++++++++++++++++ .../notification_mailer/reaction.text.erb | 5 ++ .../preferences/notifications/show.html.haml | 1 + config/locales-glitch/simple_form.en.yml | 1 + 7 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 app/javascript/images/mailer/icon_add.png create mode 100644 app/views/notification_mailer/reaction.html.haml create mode 100644 app/views/notification_mailer/reaction.text.erb diff --git a/app/javascript/images/mailer/icon_add.png b/app/javascript/images/mailer/icon_add.png new file mode 100644 index 0000000000000000000000000000000000000000..93263cffd8af13df492a1b093910a8e0badaa553 GIT binary patch literal 1417 zcmeAS@N?(olHy`uVBq!ia0vp^2SAvE4M+yv$zcaloCO|{#S9E(G9b*j{7}U!prB-l zYeY$Kep*R+Vo@qXd3m{BW?pu2a$-TMUVc&f>~}U&3=FJdo-U3d6^w8124=-Z^RQgB zsQ4FLc7liJP|nG%_sY*r+ZA>6?@49(`1ttxKkW`v58Tfx*eUqKzk%VMf^P%E%U`YP z4bmRM3J$yK9&$clyTrmVVO@L$(~d?HMy4gN#pf~P4Kigv{5k689QY!i^zX+<-owm) zm|9MY-`y|#hV2o{AEqPx3*_cAeC6(VuI})M;nhdZfc*^>bt6dl|7V7V^~~1)o^)OR zT>nR9&db|%jLTSR>t``A`dv@|smaLX!};qUFmC6pJO3$|iDib+m%o`zEEcizpDt(N zFi?H*`!Wkh!7jVg{+t2{UKhSE=M;EQQaf$Fkivl}3*P$+D;#+FOUGW-p+VE}{(Lou zhRa_g>%1Bmf}8f)`#w1IpMS%z_mk@v|9yG?`TlwTr91BZ72MD8{>JP*4GfH8QxaOs zSvWrQ?LEoOA&}t68CK!mFe*t_Ak^sHc({H2hmW_Jp642*i))4v-sGW7^nJuqTq zipe|wE}4l%Lix*qR3?@kcjnza4onhmFB(q+lf+Kj-TlBM(Q|=$IxtBLb_);K^G)Sw VbJ)bI3M@t$JYD@<);T3K0RVF@NC5x< literal 0 HcmV?d00001 diff --git a/app/mailers/notification_mailer.rb b/app/mailers/notification_mailer.rb index 5eecfed104..737ce9d418 100644 --- a/app/mailers/notification_mailer.rb +++ b/app/mailers/notification_mailer.rb @@ -6,8 +6,8 @@ class NotificationMailer < ApplicationMailer :routing before_action :process_params - before_action :set_status, only: [:mention, :favourite, :reblog] - before_action :set_account, only: [:follow, :favourite, :reblog, :follow_request] + before_action :set_status, only: [:mention, :favourite, :reaction, :reblog] + before_action :set_account, only: [:follow, :favourite, :reaction, :reblog, :follow_request] after_action :set_list_headers! default to: -> { email_address_with_name(@user.email, @me.username) } @@ -38,6 +38,15 @@ class NotificationMailer < ApplicationMailer end end + def reaction + return unless @user.functional? && @status.present? + + locale_for_account(@me) do + thread_by_conversation(@status.conversation) + mail subject: default_i18n_subject(name: @account.acct) + end + end + def reblog return unless @user.functional? && @status.present? diff --git a/app/models/user_settings.rb b/app/models/user_settings.rb index 55543ee303..e85dbdd35d 100644 --- a/app/models/user_settings.rb +++ b/app/models/user_settings.rb @@ -45,6 +45,7 @@ class UserSettings setting :follow, default: true setting :reblog, default: false setting :favourite, default: false + setting :reaction, default: false setting :mention, default: true setting :follow_request, default: true setting :report, default: true diff --git a/app/views/notification_mailer/reaction.html.haml b/app/views/notification_mailer/reaction.html.haml new file mode 100644 index 0000000000..83ae41927d --- /dev/null +++ b/app/views/notification_mailer/reaction.html.haml @@ -0,0 +1,45 @@ +%table.email-table{ cellspacing: 0, cellpadding: 0 } + %tbody + %tr + %td.email-body + .email-container + %table.content-section{ cellspacing: 0, cellpadding: 0 } + %tbody + %tr + %td.content-cell.hero + .email-row + .col-6 + %table.column{ cellspacing: 0, cellpadding: 0 } + %tbody + %tr + %td.column-cell.text-center.padded + %table.hero-icon{ align: 'center', cellspacing: 0, cellpadding: 0 } + %tbody + %tr + %td + = image_tag full_pack_url('media/images/mailer/icon_add.png'), alt: '' + + %h1= t 'notification_mailer.reaction.title' + %p.lead= t('notification_mailer.reaction.body', name: @account.pretty_acct) + += render 'status', status: @status, time_zone: @me.user_time_zone + +%table.email-table{ cellspacing: 0, cellpadding: 0 } + %tbody + %tr + %td.email-body + .email-container + %table.content-section{ cellspacing: 0, cellpadding: 0 } + %tbody + %tr + %td.content-cell.content-start.border-top + %table.column{ cellspacing: 0, cellpadding: 0 } + %tbody + %tr + %td.column-cell.button-cell + %table.button{ align: 'center', cellspacing: 0, cellpadding: 0 } + %tbody + %tr + %td.button-primary + = link_to web_url("@#{@status.account.pretty_acct}/#{@status.id}") do + %span= t 'application_mailer.view_status' diff --git a/app/views/notification_mailer/reaction.text.erb b/app/views/notification_mailer/reaction.text.erb new file mode 100644 index 0000000000..fa30d708ea --- /dev/null +++ b/app/views/notification_mailer/reaction.text.erb @@ -0,0 +1,5 @@ +<%= raw t('application_mailer.salutation', name: display_name(@me)) %> + +<%= raw t('notification_mailer.reaction.body', name: @account.pretty_acct) %> + +<%= render 'status', status: @status %> diff --git a/app/views/settings/preferences/notifications/show.html.haml b/app/views/settings/preferences/notifications/show.html.haml index e0cbe36d1e..11b3c6a947 100644 --- a/app/views/settings/preferences/notifications/show.html.haml +++ b/app/views/settings/preferences/notifications/show.html.haml @@ -17,6 +17,7 @@ = ff.input :'notification_emails.follow_request', wrapper: :with_label, label: I18n.t('simple_form.labels.notification_emails.follow_request') = ff.input :'notification_emails.reblog', wrapper: :with_label, label: I18n.t('simple_form.labels.notification_emails.reblog') = ff.input :'notification_emails.favourite', wrapper: :with_label, label: I18n.t('simple_form.labels.notification_emails.favourite') + = ff.input :'notification_emails.reaction', wrapper: :with_label, label: I18n.t('simple_form.labels.notification_emails.reaction') = ff.input :'notification_emails.mention', wrapper: :with_label, label: I18n.t('simple_form.labels.notification_emails.mention') .fields-group diff --git a/config/locales-glitch/simple_form.en.yml b/config/locales-glitch/simple_form.en.yml index 9de3f945ce..a9361bf192 100644 --- a/config/locales-glitch/simple_form.en.yml +++ b/config/locales-glitch/simple_form.en.yml @@ -22,6 +22,7 @@ en: setting_system_emoji_font: Use system's default font for emojis (applies to Glitch flavour only) setting_visible_reactions: Number of visible emoji reactions notification_emails: + reaction: Someone reacted to your post trending_link: New trending link requires review trending_status: New trending post requires review trending_tag: New trending tag requires review