X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/47362f432a9bd10196b27aa1667e6166b76f4b66..665f6d3d95f8a746b6453371ca76b9c3d30e8144:/app/mailers/user_mailer.rb diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index c5c0118e6..a9c6b70f9 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -187,7 +187,25 @@ class UserMailer < ApplicationMailer end def attach_user_avatar(user) - attachments.inline["avatar.png"] = user_avatar_file(user) + @avatar = user_avatar_filename(user) + attachments.inline[@avatar] = user_avatar_file(user) + end + + def user_avatar_filename(user) + avatar = user&.avatar + if avatar&.attached? + case avatar.content_type + when "image/png" then "avatar.png" + when "image/jpeg" then "avatar.jpg" + when "image/gif" then "avatar.gif" + when "image/bmp" then "avatar.bmp" + when "image/tiff" then "avatar.tif" + when "image/svg+xml" then "avatar.svg" + else "avatar" + end + else + "avatar.png" + end end def user_avatar_file(user)