Class: RecsysMailer

Inherits:
ApplicationMailer show all
Defined in:
app/mailers/recsys_mailer.rb

Instance Method Summary collapse

Instance Method Details

#location(need) ⇒ Object



13
14
15
16
17
18
19
# File 'app/mailers/recsys_mailer.rb', line 13

def location(need)
  return "#{need.city}, #{need.country}" unless need.city.nil? || need.country.nil?
  return need.city.to_s unless need.city.nil?
  return need.country.to_s unless need.country.nil?

  ''
end

#recsys_recommendation(to, campaign_id, needs, scores) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/mailers/recsys_mailer.rb', line 21

def recsys_recommendation(to, campaign_id, needs, scores)
  @campaign_id = campaign_id
  @needs = needs
  @scores = scores
  @to = to

  # Postmark metadatas
  ['user-id-to'] = to.id
  ['needs'] = needs.map(&:id).join(', ')
  ['campaign_id'] = campaign_id
  ['scores'] = scores.join(', ')

  mail(
    to: "#{to.full_name} <#{to.email}>",
    from: "JOGL - Just One Giant Lab <recommendations@#{Rails.configuration.email}>",
    subject: "We've been thinking about you! 👋",
    tag: 'needs-recommendations',
    message_stream: 'recommendations',
    &:html
  )
end

#sanitize(string) ⇒ Object



9
10
11
# File 'app/mailers/recsys_mailer.rb', line 9

def sanitize(string)
  @sanitizer.sanitize(string, tags: [])
end