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

Clase para las notificaciones por email

Methods

Constants

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

Public Instance methods

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

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

[Source]

    # File app/models/notifier.rb, line 73
73:   def activate_person_from_proposal(user)
74:     @recipients = user.email
75:     @from = Notifier::FROM
76:     @headers['Reply-to'] = Notifier::REPLY_TO
77:     @subject = "[#{Notifier::SERVICENAME}] #{I18n.t('notifier.welcome_person_from_proposal')}"
78:     @body["user"] = user
79:   end

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 OpenIrekia"
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

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

Email de alerta de evento para periodistas

[Source]

     # File app/models/notifier.rb, line 82
 82:   def journalist_event_alert(event_alert)
 83:     @recipients = event_alert.spammable.email
 84:     @headers['Reply-to'] = Notifier::REPLY_TO
 85:     @from = Notifier::FROM
 86:     @content_type = "multipart/alternative" 
 87: 
 88:     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 
 89:     @subject = "[#{Notifier::SERVICENAME}] #{event_title}"
 90:     
 91:     part "text/plain" do |p| 
 92:       p.body = render_message("journalist_event_alert", :event_alert => event_alert, :event_title => event_title)  
 93:     end 
 94: 
 95:     unless event_alert.event.deleted?
 96:       attachment "text/calendar" do |a|
 97:         event_ics = RiCal.Calendar do |cal|
 98:           cal.add_x_property('X-WR-CALNAME','OpenIrekia::Eventos')
 99:           event_alert.event.to_ics(cal) {{:url => url_for(:controller => "/ma/events", :action => "show", :id => event_alert, :only_path => false, :host => Notifier::SERVICEURL)}}
100:         end
101:         a.body = event_ics.to_s
102:         a.filename = "event#{event_alert.event_id}.ics"
103:       end    
104:     end
105:   end

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

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

[Source]

     # File app/models/notifier.rb, line 141
141:   def rejected_comment(comment)
142:     @recipients = comment.user.email
143:     @from = Notifier::FROM
144:     @headers['Reply-to'] = Notifier::REPLY_TO
145:     @subject = "[#{Notifier::SERVICENAME}] #{I18n.t('notifier.comentario_rechazado')}"
146: 
147:     # Email body substitutions go here
148:     @body["comment"] = comment
149:   end

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

[Source]

     # File app/models/notifier.rb, line 108
108:   def staff_event_alert(event_alert)
109:     @recipients = event_alert.spammable.email
110:     @from = Notifier::FROM
111:     @headers['Reply-to'] = Notifier::REPLY_TO
112:     @content_type = "multipart/alternative" 
113: 
114:     locale = event_alert.spammable.respond_to?("alerts_locale") ? event_alert.spammable.alerts_locale : "es"
115:     title = event_alert.event.send("title_#{locale}").present? ? event_alert.event.send("title_#{locale}").tildes : event_alert.event.title.tildes
116:     notify_about = event_alert.notify_about.eql?('coverage') ? 'cobertura' : 'streaming'
117:     @subject = "[#{Notifier::SERVICENAME}] Notificacion sobre #{notify_about} a #{User::TYPES[event_alert.spammable_type]}"
118:     
119:     part "text/plain" do |p| 
120:       p.body = render_message("staff_event_alert", :event_alert => event_alert)  
121:     end 
122: 
123:     # No enviamos el ics hasta que funcione bien con el iPhone.
124:     #
125:     # unless event_alert.event.deleted?
126:     #   attachment "text/calendar" do |a|
127:     #     event_ics = RiCal.Calendar do |cal|
128:     #       cal.add_x_property('X-WR-CALNAME','OpenIrekia::Eventos')
129:     #       event_alert.event.to_ics(cal) {
130:     #         {:url => url_for(:controller => "/sadmin/events", :action => "show", :id => event_alert, :only_path => false, :host => Notifier::SERVICEURL), 
131:     #          :description => render_message("staff_event_alert", :event_alert => event_alert)}
132:     #       }
133:     #     end
134:     #     a.body = event_ics.to_s
135:     #     a.filename = "event#{event_alert.event_id}.ics"
136:     #   end    
137:     # end
138:   end

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]