mejorar correos de mantenimiento
This commit is contained in:
parent
2c48730750
commit
fbffec6d46
8 changed files with 69 additions and 21 deletions
|
@ -14,13 +14,9 @@ class MaintenanceMailer < ApplicationMailer
|
|||
|
||||
# Notifica que volvimos
|
||||
def were_back
|
||||
params[:maintenance] = Maintenance.find(params[:maintenance_id])
|
||||
|
||||
Usuarie.all.find_each do |usuarie|
|
||||
I18n.with_locale usuarie.lang do
|
||||
mail to: usuarie.email,
|
||||
subject: I18n.t('maintenance_mailer.were_back.subject')
|
||||
end
|
||||
I18n.with_locale params[:lang] do
|
||||
mail to: params[:email],
|
||||
subject: I18n.t('maintenance_mailer.were_back.subject')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -5,4 +5,50 @@ class Maintenance < ApplicationRecord
|
|||
extend Mobility
|
||||
|
||||
translates :message, type: :string, locale_accessors: true
|
||||
|
||||
# Renderiza el mensaje una sola vez
|
||||
#
|
||||
# @return [String]
|
||||
def to_html
|
||||
@renderized_message ||= {}
|
||||
@renderized_message[message.hash.to_s] ||= CommonMarker.render_doc(message, %i[FOOTNOTES SMART], %i[table strikethrough autolink]).to_html.html_safe
|
||||
end
|
||||
|
||||
# Como no sabemos en qué zona horaria están les usuaries, generamos la
|
||||
# URL para convertir el tiempo estimado a la zona local, visitando
|
||||
# otro servicio.
|
||||
#
|
||||
# @return [String]
|
||||
def estimated_from_time_is
|
||||
@estimated_from_time_is ||= {}
|
||||
@estimated_from_time_is[cache_key_for_attr(estimated_from)] ||= time_is(estimated_from)
|
||||
end
|
||||
|
||||
# @see estimated_from_time_is
|
||||
# @return [String]
|
||||
def estimated_to_time_is
|
||||
@estimated_to_time_is ||= {}
|
||||
@estimated_to_time_is[cache_key_for_attr(estimated_to)] ||= time_is(estimated_to)
|
||||
end
|
||||
|
||||
# @see estimated_from_time_is
|
||||
# @return [String]
|
||||
def updated_at_time_is
|
||||
@updated_at_time_is ||= {}
|
||||
@updated_at_time_is[cache_key_for_attr(updated_at)] ||= time_is(updated_at)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def cache_key_for_attr(attr)
|
||||
attr.hash.to_s + I18n.locale.to_s
|
||||
end
|
||||
|
||||
# Devuelve la URL
|
||||
#
|
||||
# @param [Time]
|
||||
# @return [String]
|
||||
def time_is(time)
|
||||
"https://time.is/#{I18n.locale}/compare/#{time.utc.strftime('%H%M_%d_%B_%Y_in_%Z')}"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
%p= t('.hi')
|
||||
%p= t('.message')
|
||||
%p= t('.reason')
|
||||
%blockquote= params[:maintenance].message
|
||||
%p= t('.estimated_from', from: params[:maintenance].estimated_from)
|
||||
%p= t('.estimated_to', to: params[:maintenance].estimated_to)
|
||||
= params[:maintenance].to_html
|
||||
%p= t('.estimated_from_html', from: params[:maintenance].estimated_from, time_is: params[:maintenance].estimated_from_time_is)
|
||||
%p= t('.estimated_to_html', to: params[:maintenance].estimated_to, time_is: params[:maintenance].estimated_to_time_is)
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
\
|
||||
= params[:maintenance].message.html_safe
|
||||
\
|
||||
= t('.estimated_from', from: params[:maintenance].estimated_from).html_safe
|
||||
= t('.estimated_from', from: params[:maintenance].estimated_from, time_is: params[:maintenance].estimated_from_time_is).html_safe
|
||||
\
|
||||
= t('.estimated_to', to: params[:maintenance].estimated_to).html_safe
|
||||
= t('.estimated_to', to: params[:maintenance].estimated_to, time_is: params[:maintenance].estimated_to_time_is).html_safe
|
||||
\
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
%p= t('.hi')
|
||||
%p= t('.message')
|
||||
%blockquote= params[:maintenance].message
|
||||
%p= t('.message_html', updated_at: params[:maintenance].updated_at, time_is: params[:maintenance].updated_at_time_is)
|
||||
%p= params[:maintenance].to_html
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
= t('.hi')
|
||||
\
|
||||
= t('.message')
|
||||
= t('.message', updated_at: params[:maintenance].updated_at, time_is: params[:maintenance].updated_at_time_is)
|
||||
\
|
||||
= params[:maintenance].message
|
||||
\
|
||||
|
|
|
@ -94,13 +94,16 @@ en:
|
|||
hi: 'Hi!'
|
||||
message: "We're getting in contact with you to let you know we'll be doing maintenance work in our servers."
|
||||
reason: 'The reason is:'
|
||||
estimated_from: 'The maintenance period starts at %{from}'
|
||||
estimated_to: 'Up to %{to} (approximately)'
|
||||
estimated_from: 'The maintenance period starts at %{from} (visit %{time_is} to convert into your time zone)'
|
||||
estimated_to: 'Up to %{to} (approximately, visit %{time_is} to convert into your time zone)'
|
||||
estimated_from_html: 'The maintenance period starts at %{from} <a referrerpolicy="no-referrer" href="%{time_is}" target="_blank" rel="nofollow">(convert into your time zone)</a>'
|
||||
estimated_to_html: 'Up to %{to} (approximately, <a referrerpolicy="no-referrer" href="%{time_is}" target="_blank" rel="nofollow">convert into your time zone</a>)'
|
||||
thanks: 'Thanks for your patience'
|
||||
were_back:
|
||||
subject: 'Maintenance period ended'
|
||||
hi: 'Hi!'
|
||||
message: 'The maintenance period ended at %{created_at}'
|
||||
message: 'The maintenance period ended at %{updated_at} (visit %{time_is} to convert into your time zone)'
|
||||
message_html: 'The maintenance period ended at %{updated_at} <a referrerpolicy="no-referrer" href="%{time_is}" target="_blank" rel="nofollow">(convert into your timezone)</a>'
|
||||
ics:
|
||||
summary: 'Sutty - Maintenance'
|
||||
activerecord:
|
||||
|
|
|
@ -94,13 +94,16 @@ es:
|
|||
hi: '¡Hola!'
|
||||
message: 'Nos comunicamos con vos para informarte que estaremos realizando mantenimiento en nuestros servidores'
|
||||
reason: 'La razón de esta tarea es:'
|
||||
estimated_from: 'El mantenimiento se realizará a partir de %{from}'
|
||||
estimated_to: 'Hasta %{to} (aproximadamente)'
|
||||
estimated_from: 'El mantenimiento se realizará a partir de %{from} (%{time_is})'
|
||||
estimated_to: 'Hasta %{to} (aproximadamente, %{time_is})'
|
||||
estimated_from_html: 'El mantenimiento se realizará a partir de %{from} <a referrerpolicy="no-referrer" href="%{time_is}" target="_blank" rel="nofollow">(convertir a tu zona horaria).</a>'
|
||||
estimated_to_html: 'Hasta %{to} (aproximadamente, <a href="%{time_is}" referrerpolicy="no-referrer" target="_blank" rel="nofollow">convertir a tu zona horaria</a>)'
|
||||
thanks: 'Gracias por tu paciencia'
|
||||
were_back:
|
||||
subject: 'Fin del mantenimiento'
|
||||
hi: '¡Hola!'
|
||||
message: 'El período de mantenimiento terminó en %{created_at}'
|
||||
message: 'El período de mantenimiento terminó en %{updated_at} (visita %{time_is} para convertir a tu zona horaria)'
|
||||
message_html: 'El período de mantenimiento terminó en %{updated_at} <a referrerpolicy="no-referrer" href="%{time_is}" target="_blank" rel="nofollow">(convertir a tu zona horaria)</a>'
|
||||
ics:
|
||||
summary: 'Sutty - Mantenimiento'
|
||||
activerecord:
|
||||
|
|
Loading…
Reference in a new issue