mattdm
(Matthew Miller)
8 Enero, 2022 16:31
8
@simon Compara
# No point in adding a reply-to header if it is going to be identical
# to the from address/alias. If the from option is not present, then
# the default reply-to address is used.
result['Reply-To'] = from_value if from_value != alias_email(@opts[:from])
end
end
result.merge(MessageBuilder.custom_headers(SiteSetting.email_custom_headers))
end
def self.custom_headers(string)
result = {}
string.split('|').each { |item|
header = item.split(':', 2)
if header.length == 2
name = header[0].strip
value = header[1].strip
result[name] = value if name.length > 0 && value.length > 0
end
} unless string.nil?
result
con
elsif SiteSetting.unsubscribe_via_email_footer
"unsubscribe_link_and_mail"
else
"unsubscribe_link"
end
@template_args[:unsubscribe_instructions] = I18n.t(unsubscribe_string, @template_args)
end
end
end
def subject
if @opts[:template] &&
TranslationOverride.exists?(locale: I18n.locale, translation_key: "#{@opts[:template]}.subject_template")
augmented_template_args = @template_args.merge({
site_name: @template_args[:email_prefix],
optional_re: @opts[:add_re_to_subject] ? I18n.t('subject_re') : '',
optional_pm: @opts[:private_reply] ? @template_args[:subject_pm] : '',
optional_cat: @template_args[:show_category_in_subject] ? "[#{@template_args[:show_category_in_subject]}] " : '',
optional_tags: @template_args[:show_tags_in_subject] ? "#{@template_args[:show_tags_in_subject]} " : '',
topic_title: @template_args[:topic_title] ? @template_args[:topic_title] : '',
})
Hay cierta complejidad con las plantillas frente a la configuración email_subject que no entiendo completamente; parece que esta última no se usa si hay una plantilla, ¡pero no estoy seguro de cuándo no hay una plantilla! Pero aparte de eso, lo básico es que si la función que construyó las cabeceras personalizadas usara el mismo sistema de plantillas, esto funcionaría y las cabeceras personalizadas podrían tener información dinámica útil.
2 Me gusta