X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/030591e3187690b457ea9b0bf32e2e4fd1efa5c6..473d7cd179b2be697c8f1d9104fd3c556d14483e:/app/mailers/user_mailer.rb diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index e0f3bb5f6..a9c6b70f9 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -12,7 +12,7 @@ class UserMailer < ApplicationMailer def signup_confirm(user, token) with_recipient_locale user do - @url = url_for(:controller => "users", :action => "confirm", + @url = url_for(:controller => "confirmations", :action => "confirm", :display_name => user.display_name, :confirm_string => token.token) @@ -24,7 +24,7 @@ class UserMailer < ApplicationMailer def email_confirm(user, token) with_recipient_locale user do @address = user.new_email - @url = url_for(:controller => "users", :action => "confirm_email", + @url = url_for(:controller => "confirmations", :action => "confirm_email", :confirm_string => token.token) mail :to => user.new_email, @@ -34,7 +34,7 @@ class UserMailer < ApplicationMailer def lost_password(user, token) with_recipient_locale user do - @url = url_for(:controller => "users", :action => "reset_password", + @url = url_for(:controller => "passwords", :action => "reset_password", :token => token.token) mail :to => user.email, @@ -83,7 +83,7 @@ class UserMailer < ApplicationMailer mail :from => from_address(message.sender.display_name, "m", message.id, message.digest), :to => message.recipient.email, - :subject => I18n.t("user_mailer.message_notification.subject_header", :subject => message.title) + :subject => t(".subject", :message_title => message.title) end end @@ -123,7 +123,7 @@ class UserMailer < ApplicationMailer def note_comment_notification(comment, recipient) with_recipient_locale recipient do - @noteurl = browse_note_url(comment.note) + @noteurl = note_url(comment.note) @place = Nominatim.describe_location(comment.note.lat, comment.note.lon, 14, I18n.locale) @comment = comment.body @owner = recipient == comment.note.author @@ -183,24 +183,41 @@ class UserMailer < ApplicationMailer end def attach_project_logo - attachments.inline["logo.png"] = File.read(Rails.root.join("app/assets/images/osm_logo_30.png")) + attachments.inline["logo.png"] = Rails.root.join("app/assets/images/osm_logo_30.png").read 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) avatar = user&.avatar if avatar&.attached? if avatar.variable? - image = avatar.variant(:resize => "50x50>").processed - image.service.download(image.key) + avatar.variant(:resize_to_limit => [50, 50]).download else avatar.blob.download end else - File.read(Rails.root.join("app/assets/images/avatar_small.png")) + Rails.root.join("app/assets/images/avatar_small.png").read end end