Class | Notifier
In: | app/models/notifier.rb
Parent: | ActionMailer::Base

Clase para las notificaciones por email

### Methods

activate_person_account contact email_document journalist_event_alert password_reminder rejected_comment staff_event_alert welcome_journalist

### Constants

SERVICEURL | = | "www.irekia.euskadi.net"
SERVICENAME | = | "Irekia"
FROM_EMAIL | = | "robot@irekia.euskadi.net"
FROM | = | "#{Notifier::SERVICENAME} <#{Notifier::FROM_EMAIL}>"
REPLY_TO | = | "#{Notifier::SERVICENAME} <irekia@ej-gv.es>"
AGENCIAURL | = | "www.irekia.euskadi.net/prentsa"
AGENCIANAME | = | "Agencia Multimedia"

### Public Instance methods

activate_person_account(user)

Confirmación de identidad de un usuario. Se le envía un email con enlace para activar su cuenta

[Source]

        # File app/models/notifier.rb, line 64
    64:   def activate_person_account(user)
    65:     @recipients = user.email
    66:     @from = Notifier::FROM
    67:     @headers['Reply-to'] = Notifier::REPLY_TO
    68:     @subject = "[#{Notifier::SERVICENAME}] #{I18n.t('notifier.welcome_person')}"
    69:     @body["user"] = user
    70:   end

contact(sender_name, sender_email, message)

Formulario de contacto

[Source]

        # File app/models/notifier.rb, line 40
    40:   def contact(sender_name, sender_email, message)
    41:     # Email header info MUST be added here
    42:     @recipients = "irekia@ej-gv.es"
    43:     @from = Notifier::FROM
    44:     @headers['Reply-to'] = "#{sender_name} <#{sender_email}>"
    45:     @subject = "[#{Notifier::SERVICENAME}] Contacto en Irekia"
    46:
    47:     # Email body substitutions go here
    48:     @body["sender_name"] = sender_name
    49:     @body["sender_email"] = sender_email
    50:     @body["message"] = message
    51:   end

email_document(sender_name, recipient_name, recipient_email, document)

Enviar por email una noticia a un amigo

[Source]

        # File app/models/notifier.rb, line 26
    26:   def email_document(sender_name, recipient_name, recipient_email, document)
    27:     # Email header info MUST be added here
    28:     @recipients = recipient_email
    29:     @from = Notifier::FROM
    30:     @headers['Reply-to'] = Notifier::REPLY_TO
    31:     @subject = "[#{Notifier::SERVICENAME}] #{I18n.t('share.te_recomienda', :sender_name => sender_name)}"
    32:
    33:     # Email body substitutions go here
    34:     @body["sender_name"] = sender_name
    35:     @body["recipient_name"] = recipient_name
    36:     @body["document"] = document
    37:   end

journalist_event_alert(event_alert)

Email de alerta de evento para periodistas

[Source]

        # File app/models/notifier.rb, line 73
    73:   def journalist_event_alert(event_alert)
    74:     @recipients = event_alert.spammable.email
    75:     @headers['Reply-to'] = Notifier::REPLY_TO
    76:     @from = Notifier::FROM
    77:     @content_type = "multipart/alternative"
    78:
    79:     event_title = event_alert.event.send("title_#{event_alert.spammable.alerts_locale}").present? ? event_alert.event.send("title_#{event_alert.spammable.alerts_locale}") : event_alert.event.title
    80:     @subject = "[#{Notifier::SERVICENAME}] #{event_title.tildes}"
    81:
    82:     part "text/plain" do |p|
    83:       p.body = render_message("journalist_event_alert", :event_alert => event_alert, :event_title => event_title)
    84:     end
    85:
    86:     unless event_alert.event.deleted?
    87:       attachment "text/calendar" do |a|
    88:         event_ics = RiCal.Calendar do |cal|
    89:           cal.add_x_property('X-WR-CALNAME','Irekia::Eventos')
    90:           event_alert.event.to_ics(cal) {{:url => url_for(:controller => "/ma/events", :action => "show", :id => event_alert, :only_path => false, :host => Notifier::SERVICEURL)}}
    91:         end
    92:         a.body = event_ics.to_s
    93:         a.filename = "event#{event_alert.event_id}.ics"
    94:       end
    95:     end
    96:   end

password_reminder(user)

Recordatorio de contraseña

[Source]

        # File app/models/notifier.rb, line 14
    14:   def password_reminder(user)
    15:     # Email header info MUST be added here
    16:     @recipients = user.email
    17:     @from = Notifier::FROM
    18:     @headers['Reply-to'] = Notifier::REPLY_TO
    19:     @subject = "[#{Notifier::SERVICENAME}] #{I18n.t('notifier.info_acceso')}"
    20:
    21:     # Email body substitutions go here
    22:     @body["user"] = user
    23:   end

rejected_comment(comment)

Email que avisa a un comentarista de que su comentario ha sido rechazado

[Source]

         # File app/models/notifier.rb, line 126
    126:   def rejected_comment(comment)
    127:     @recipients = comment.user.email
    128:     @from = Notifier::FROM
    129:     @headers['Reply-to'] = Notifier::REPLY_TO
    130:     @subject = "[#{Notifier::SERVICENAME}] #{I18n.t('notifier.comentario_rechazado')}"
    131:
    132:     # Email body substitutions go here
    133:     @body["comment"] = comment
    134:
    135:   end

staff_event_alert(event_alert)

Email de alerta de evento con streaming, para responsable de sala o operador de streaming

[Source]

         # File app/models/notifier.rb, line 99
     99:   def staff_event_alert(event_alert)
    100:     @recipients = event_alert.spammable.email
    101:     @from = Notifier::FROM
    102:     @headers['Reply-to'] = Notifier::REPLY_TO
    103:     @content_type = "multipart/alternative"
    104:
    105:     locale = event_alert.spammable.respond_to?("alerts_locale") ? event_alert.spammable.alerts_locale : "es"
    106:     title = event_alert.event.send("title_#{locale}").present? ? event_alert.event.send("title_#{locale}").tildes : event_alert.event.title.tildes
    107:     @subject = "[#{Notifier::SERVICENAME}] Notificacion sobre streaming a #{User::TYPES.merge({'RoomManager' => 'Responsable de sala'})[event_alert.spammable_type]}"
    108:
    109:     part "text/plain" do |p|
    110:       p.body = render_message("staff_event_alert", :event_alert => event_alert)
    111:     end
    112:
    113:     unless event_alert.event.deleted?
    114:       attachment "text/calendar" do |a|
    115:         event_ics = RiCal.Calendar do |cal|
    116:           cal.add_x_property('X-WR-CALNAME','Irekia::Eventos')
    117:           event_alert.event.to_ics(cal) {{:url => url_for(:controller => "/ma/events", :action => "show", :id => event_alert, :only_path => false, :host => Notifier::SERVICEURL)}}
    118:         end
    119:         a.body = event_ics.to_s
    120:         a.filename = "event#{event_alert.event_id}.ics"
    121:       end
    122:     end
    123:   end

welcome_journalist(user)

     Email de bienvenida a un periodista. Se envía al aprobar a un periodista,

y se le manda la contraseña que se le acaba de generar

[Source]

        # File app/models/notifier.rb, line 55
    55:   def welcome_journalist(user)
    56:     @recipients = user.email
    57:     @from = Notifier::FROM
    58:     @headers['Reply-to'] = Notifier::REPLY_TO
    59:     @subject = "[#{Notifier::SERVICENAME}] #{I18n.t('notifier.welcome_journalist', :name => I18n.t('site.Agencia_multimedia'))}"
    60:     @body["user"] = user
    61:   end

[Validate]