Clase para las notificaciones por email
Confirmación de identidad de un usuario. Se le envía un email con enlace para activar su cuenta
# File app/models/notifier.rb, line 82 def activate_person_account(user) @recipients = user.email @from = Notifier::FROM @headers['Reply-to'] = Notifier::REPLY_TO @subject = "[#{Notifier::SERVICENAME}] #{I18n.t('notifier.welcome_person')}" @body["user"] = user 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
# File app/models/notifier.rb, line 91 def activate_person_from_proposal(user) @recipients = user.email @from = Notifier::FROM @headers['Reply-to'] = Notifier::REPLY_TO @subject = "[#{Notifier::SERVICENAME}] #{I18n.t('notifier.welcome_person_from_proposal')}" @body["user"] = user end
Formulario de contacto
# File app/models/notifier.rb, line 58 def contact(sender_name, sender_email, message) # Email header info MUST be added here @recipients = "irekia@ej-gv.es" @from = Notifier::FROM @headers['Reply-to'] = "#{sender_name} <#{sender_email}>" @subject = "[#{Notifier::SERVICENAME}] Danos tu opinión" # Email body substitutions go here @body["sender_name"] = sender_name @body["sender_email"] = sender_email @body["message"] = message end
Enviar por email una noticia a un amigo
# File app/models/notifier.rb, line 44 def email_document(sender_name, recipient_name, recipient_email, document) # Email header info MUST be added here @recipients = recipient_email @from = Notifier::FROM @headers['Reply-to'] = Notifier::REPLY_TO @subject = "[#{Notifier::SERVICENAME}] #{I18n.t('share.te_recomienda', :sender_name => sender_name)}" # Email body substitutions go here @body["sender_name"] = sender_name @body["recipient_name"] = recipient_name @body["document"] = document end
Email de alerta de evento para periodistas
# File app/models/notifier.rb, line 100 def journalist_event_alert(event_alert) @recipients = event_alert.spammable.email @headers['Reply-to'] = Notifier::REPLY_TO @from = Notifier::FROM @content_type = "multipart/alternative" 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 @subject = "[#{Notifier::SERVICENAME}] #{event_title}" part "text/plain" do |p| p.body = render_message("journalist_event_alert", :event_alert => event_alert, :event_title => event_title) end unless event_alert.event.deleted? attachment "text/calendar" do |a| event_ics = RiCal.Calendar do |cal| cal.add_x_property('X-WR-CALNAME','Irekia::Eventos') event_alert.event.to_ics(cal) {{:url => url_for(:controller => "/ma/events", :action => "show", :id => event_alert, :only_path => false, :host => Notifier::SERVICEURL)}} end a.body = event_ics.to_s a.filename = "event#{event_alert.event_id}.ics" end end end
# File app/models/notifier.rb, line 168 def new_proposal(proposal) @recipients = Contribution::MODERATORS @from = Notifier::FROM @headers['Reply-to'] = Notifier::REPLY_TO @subject = "[#{Notifier::SERVICENAME}] Nueva propuesta en Irekia" @body["proposal"] = proposal end
# File app/models/notifier.rb, line 204 def new_question(question) @recipients = Contribution::MODERATORS @from = Notifier::FROM @headers['Reply-to'] = Notifier::REPLY_TO @subject = "[#{Notifier::SERVICENAME}] Nueva pregunta en Irekia" @body["question"] = question end
Recordatorio de contraseña
# File app/models/notifier.rb, line 32 def password_reminder(user) # Email header info MUST be added here @recipients = user.email @from = Notifier::FROM @headers['Reply-to'] = Notifier::REPLY_TO @subject = "[#{Notifier::SERVICENAME}] #{I18n.t('notifier.info_acceso')}" # Email body substitutions go here @body["user"] = user end
# File app/models/notifier.rb, line 185 def proposal_approval(proposal) @recipients = proposal.user.email @from = Notifier::FROM @headers['Reply-to'] = Notifier::REPLY_TO @subject = "[#{Notifier::SERVICENAME}] #{I18n.t('notifier.proposal_approval.subject')}" @body["proposal"] = proposal end
# File app/models/notifier.rb, line 176 def proposal_organization(proposal) department = proposal.organization.department @recipients = department.department_editors.collect(&:email) + department.department_members_official_commenters.collect(&:email) @from = Notifier::FROM @headers['Reply-to'] = Notifier::REPLY_TO @subject = "[#{Notifier::SERVICENAME}] Nueva propuesta en Irekia" @body["proposal"] = proposal end
Email que avisa a un comentarista de que su comentario ha sido rechazado
# File app/models/notifier.rb, line 194 def proposal_rejection(proposal) @recipients = proposal.user.email @from = Notifier::FROM @headers['Reply-to'] = Notifier::REPLY_TO @subject = "[#{Notifier::SERVICENAME}] #{I18n.t('notifier.propuesta_rechazado')}" # Email body substitutions go here @body["proposal"] = proposal end
# File app/models/notifier.rb, line 237 def question_approval(question) @recipients = question.user.email @from = Notifier::FROM @headers['Reply-to'] = Notifier::REPLY_TO @subject = "[#{Notifier::SERVICENAME}] #{I18n.t('notifier.question_approval.subject')}" @body["question"] = question end
def new_question_for_politician(question)
@recipients = question.for_whom.email @from = Notifier::FROM @headers['Reply-to'] = Notifier::REPLY_TO @subject = "[#{Notifier::SERVICENAME}] #{I18n.t('notifier.new_question_for_politician.subject', :locale => question.for_whom.alerts_locale)}" @body["question"] = question
end
# File app/models/notifier.rb, line 220 def question_organization(question) department = question.organization.department @recipients = department.department_editors.collect(&:email) + department.department_members_official_commenters.collect(&:email) @from = Notifier::FROM @headers['Reply-to'] = Notifier::REPLY_TO @subject = "[#{Notifier::SERVICENAME}] Nueva pregunta en Irekia" @body["question"] = question end
# File app/models/notifier.rb, line 229 def question_receiver(question) @recipients = question.for_whom.email @from = Notifier::FROM @headers['Reply-to'] = Notifier::REPLY_TO @subject = "[#{Notifier::SERVICENAME}] #{I18n.t('notifier.new_question_for_politician.subject', :locale => question.for_whom.alerts_locale)}" @body["question"] = question end
Email que avisa a un comentarista de que su comentario ha sido rechazado
# File app/models/notifier.rb, line 158 def rejected_comment(comment) @recipients = comment.user.email @from = Notifier::FROM @headers['Reply-to'] = Notifier::REPLY_TO @subject = "[#{Notifier::SERVICENAME}] #{I18n.t('notifier.comentario_rechazado')}" # Email body substitutions go here @body["comment"] = comment end
Email de alerta de evento con streaming, para responsable de sala o operador de streaming
# File app/models/notifier.rb, line 126 def staff_event_alert(event_alert) @recipients = event_alert.spammable.email @from = Notifier::FROM @headers['Reply-to'] = Notifier::REPLY_TO @content_type = "multipart/alternative" locale = event_alert.spammable.respond_to?("alerts_locale") ? event_alert.spammable.alerts_locale : "es" title = event_alert.event.send("title_#{locale}").present? ? event_alert.event.send("title_#{locale}").tildes : event_alert.event.title.tildes notify_about = event_alert.notify_about.eql?('coverage') ? 'cobertura' : 'streaming' @subject = "[#{Notifier::SERVICENAME}] Notificacion sobre #{notify_about} a #{User::TYPES[event_alert.spammable_type]}" part "text/plain" do |p| p.body = render_message("staff_event_alert", :event_alert => event_alert) end # Enviamos el ics como attachement. unless event_alert.event.deleted? attachment "text/calendar" do |a| event_ics = RiCal.Calendar do |cal| cal.add_x_property('X-WR-CALNAME','Irekia::Eventos') event_alert.event.to_ics(cal) { {:url => url_for(:controller => "/sadmin/events", :action => "show", :id => event_alert, :only_path => false, :host => Notifier::SERVICEURL), :description => render_message("staff_event_alert", :event_alert => event_alert)} } end a.body = event_ics.to_s a.filename = "event#{event_alert.event_id}.ics" end end 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
# File app/models/notifier.rb, line 73 def welcome_journalist(user) @recipients = user.email @from = Notifier::FROM @headers['Reply-to'] = Notifier::REPLY_TO @subject = "[#{Notifier::SERVICENAME}] #{I18n.t('notifier.welcome_journalist', :name => I18n.t('site_name'))}" @body["user"] = user end