X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/63303c22b704ca290c16ae908da1324f3ea25b2c..1a3a40772c9b8bb70d9b0f91b6de2ba550a153d7:/app/mailers/user_mailer.rb?ds=inline 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)