Class: TranslationExportMailer
- Inherits:
-
ApplicationMailer
- Object
- ActionMailer::Base
- ApplicationMailer
- TranslationExportMailer
- Defined in:
- app/mailers/translation_export_mailer.rb
Overview
typed: ignore frozen_string_literal: true
Instance Method Summary collapse
- #package_export(user_id, attachment_id, target_locale, package_type) ⇒ Object
-
#restaurant_export(user_id, attachment_id, target_locale) ⇒ Object
Simplified signature: we now store a fully-qualified link in attachment.download_link.
Methods inherited from ApplicationMailer
Methods included from Workers::Helpers
Instance Method Details
#package_export(user_id, attachment_id, target_locale, package_type) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'app/mailers/translation_export_mailer.rb', line 43 def package_export(user_id, , target_locale, package_type) @user = User.find_by(id: user_id) @attachment = Attachment.find_by(id: ) return unless @user && @attachment @target_locale = target_locale.to_s @package_type = package_type.to_s @package_label = package_type_label(@package_type) raw_link = if @attachment.download_link.is_a?(Hash) @attachment.download_link['file_1'] || @attachment.download_link[:file_1] else @attachment.download_link end @download_link = raw_link subject = "#{@package_label} package translation export (#{@target_locale}) ready" if defined?(BUSINESS_LOGGER) log_mailer(subject: 'package_translation_export_mail', user_id: @user.id, locale: @target_locale, attachment_id: @attachment.id, package_type: @package_type, download_link_present: @download_link.present?) end # Explicit multipart: build text part programmatically so we can drop .text.erb template mail(to: @user.email, subject: subject) do |format| format.html # renders package_export.html.erb format.text do body = <<~TEXT Hello #{@user.name.presence || @user.email},\n\nYour requested #{@package_label} package translation export for target locale #{@target_locale} is ready.\nDownload link: #{@download_link}\n\nIf you did not request this export you can ignore this email.\n\nRegards,\nHungry Hub Team TEXT render plain: body end end end |
#restaurant_export(user_id, attachment_id, target_locale) ⇒ Object
Simplified signature: we now store a fully-qualified link in attachment.download_link
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/mailers/translation_export_mailer.rb', line 12 def restaurant_export(user_id, , target_locale) @user = User.find_by(id: user_id) @attachment = Attachment.find_by(id: ) return unless @user && @attachment @target_locale = target_locale.to_s raw_link = if @attachment.download_link.is_a?(Hash) @attachment.download_link['file_1'] || @attachment.download_link[:file_1] else @attachment.download_link end @download_link = raw_link subject = "Restaurant translation export (#{@target_locale}) ready" if defined?(BUSINESS_LOGGER) log_mailer(subject: 'translation_export_mail', user_id: @user.id, locale: @target_locale, attachment_id: @attachment.id, download_link_present: @download_link.present?) end # Explicit multipart: build text part programmatically so we can drop .text.erb template mail(to: @user.email, subject: subject) do |format| format.html # renders restaurant_export.html.erb format.text do body = <<~TEXT Hello #{@user.name.presence || @user.email},\n\nYour requested restaurant translation export for target locale #{@target_locale} is ready.\nDownload link: #{@download_link}\n\nIf you did not request this export you can ignore this email.\n\nRegards,\nHungry Hub Team TEXT render plain: body end end end |