From: Herve Saint-Amand Date: Thu, 29 Dec 2016 23:37:22 +0000 (+0000) Subject: avatar inline attachment X-Git-Tag: live~3653^2~39 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/689769cadad01bf6be271ecaf40a625c3edc7676 avatar inline attachment --- diff --git a/app/models/notifier.rb b/app/models/notifier.rb index b53210c30..ea10eeb7b 100644 --- a/app/models/notifier.rb +++ b/app/models/notifier.rb @@ -179,12 +179,25 @@ class Notifier < ActionMailer::Base content: @@osm_logo_png_bytes, } + File.open(user_avatar_file_path(comment.author), 'rb') do |file| + attachments.inline['avatar.png'] = file.read() + end + mail :to => recipient.email, :subject => subject end end private + def user_avatar_file_path(user) + image = user.image + if image.file? + return image.path.sub('/original/', '/small/') + else + return Rails.root.join('app', 'assets', 'images', 'users', 'images', 'small.png') + end + end + def with_recipient_locale(recipient) I18n.with_locale Locale.available.preferred(recipient.preferred_languages) do yield