From 6788e8ea7203722e84cf874ba9c7b991dd1ac00d Mon Sep 17 00:00:00 2001 From: Jorge Manrubia Date: Fri, 7 Nov 2025 12:40:25 +0100 Subject: [PATCH] Don't render SVG avatars in emails since mail services won't render them https://app.fizzy.do/5986089/cards/1740 --- app/helpers/avatars_helper.rb | 10 ++++++++++ .../notification/bundle_mailer/_notification.html.erb | 2 +- .../previews/notification/bundle_mailer_preview.rb | 1 - 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/helpers/avatars_helper.rb b/app/helpers/avatars_helper.rb index 3dccac678..4e409d0ff 100644 --- a/app/helpers/avatars_helper.rb +++ b/app/helpers/avatars_helper.rb @@ -19,6 +19,16 @@ module AvatarsHelper end end + def mail_avatar_tag(user, size: 48, **options) + if user.avatar.attached? + image_tag user_avatar_url(notification.creator), alt: notification.creator.name, class: "avatar", **options + else + tag.span class: "avatar" do + user.initials + end + end + end + def avatar_preview_tag(user, hidden_for_screen_reader: false, **options) tag.span class: class_names("avatar", options.delete(:class)), aria: { hidden: hidden_for_screen_reader, label: user.name }, diff --git a/app/views/mailers/notification/bundle_mailer/_notification.html.erb b/app/views/mailers/notification/bundle_mailer/_notification.html.erb index 5dfddcf31..0d5d00d70 100644 --- a/app/views/mailers/notification/bundle_mailer/_notification.html.erb +++ b/app/views/mailers/notification/bundle_mailer/_notification.html.erb @@ -1,6 +1,6 @@ - +
<%= image_tag user_avatar_url(notification.creator), alt: notification.creator.name, class: "avatar", size: 48 %><%= mail_avatar_tag(notification.creator) %> <%= render "notification/bundle_mailer/header", notification: notification %> <%= render "notification/bundle_mailer/#{notification.source_type.underscore}/body", notification: notification %> diff --git a/test/mailers/previews/notification/bundle_mailer_preview.rb b/test/mailers/previews/notification/bundle_mailer_preview.rb index 3c279e916..9242aaa60 100644 --- a/test/mailers/previews/notification/bundle_mailer_preview.rb +++ b/test/mailers/previews/notification/bundle_mailer_preview.rb @@ -1,6 +1,5 @@ class Notification::BundleMailerPreview < ActionMailer::Preview def notification - ApplicationRecord.current_tenant = "1065895976" Notification::BundleMailer.notification Notification::Bundle.take! end end