Class: FatFreeCRM::Cloudfuji::EventObservers::EmailObserver

Inherits:
Cloudfuji::EventObserver
  • Object
show all
Includes:
Base
Defined in:
lib/fat_free_crm/cloudfuji/event_observers/email_observer.rb

Instance Method Summary collapse

Methods included from Base

#find_lead_by_data, #find_or_create_activity_subject!

Instance Method Details

#email_clickedObject

:event=>“clicked” :recipient=>“[email protected]” :domain=>“cloudfuji.com” :campaign_id=>“cloudfuji_buddies” :campaign_name=>“Cloudfuji Buddies” :tag=>nil :mailing_list=>nil :custom_variables=>nil :url=>“cloudfuji.com/cas/invite/?invitation_token=8hswc7kqhPys6FsUJ1Nm&service=https://cloudfuji.com/users/service&redirect=https://cloudfuji.com/apps/new?app=fat_free_crm&src=icon” :human=>“[email protected] clicked on link in Cloudfuji Buddies to cloudfuji.com/cas/invite/?invitation_token=8hswc7kqhPys6FsUJ1Nm&service=https://cloudfuji.com/users/service&redirect=https://cloudfuji.com/apps/new?app=fat_free_crm&src=icon”}



50
51
52
53
54
55
# File 'lib/fat_free_crm/cloudfuji/event_observers/email_observer.rb', line 50

def email_clicked
  message = "#{email} clicked #{data['url']}"
  message += "in email campaign '#{campaign.titleize}'" if campaign

  note_email_activity(message)
end

#email_deliveredObject

“email_delivered” :message_headers => “[["Received", "by luna.mailgun.net with SMTP mgrt 7313261; Tue, 20 Mar 2012 19:00:58 0000"], ["Received", "from localhost.localdomain (ec2-23-20-14-40.compute-1.amazonaws.com [23.20.14.40]) by mxa.mailgun.org with ESMTP id 4f68d3e9.4ddcdf0-luna; Tue, 20 Mar 2012 19:00:57 -0000 (UTC)"], ["Date", "Tue, 20 Mar 2012 19:00:57 0000"], ["From", "Sean Grove <[email protected]>"], ["Reply-To", "Cloudfuji Team <[email protected]>"], ["Message-Id", "<[email protected]>"], ["X-Mailgun-Campaign-Id", "cloudfuji_buddies"], ["Repy-To", "[email protected]"], ["To", "[email protected]"], ["Subject", "Cloudfuji Beta: Thank you for your early support. Here’s a gift for you."], ["List-Unsubscribe", "<u+na6wcn3gmqzdszbsmrrdam3ghfstkzrxgbstgn3fgvtdgzjumvrgmyzgmm6tqnlkgetheplteuzeey3gmrsw23zfgqyge5ltnbus4zdpez2d2jjsietgipjrmi4a@email.cloudfuji.com>"], ["X-Mailgun-Sid", "WyI2NWQ4MSIsICJzK2NmZGVtb0BidXNoaS5kbyIsICIxYjgiXQ=="], ["Sender", "[email protected]"]]” :message_id =>“<[email protected]>” :recipient => “[email protected]” :domain => “cloudfuji.com” :custom_variables => nil :human =>“Mail to [email protected] successfully delievered.”}}



16
17
18
19
20
21
22
# File 'lib/fat_free_crm/cloudfuji/event_observers/email_observer.rb', line 16

def email_delivered
  message  = ""
  message += "Email delivered to #{email}"
  message += " in email campaign '#{campaign.titleize}'" if campaign

  note_email_activity( message.strip )
end

#email_openedObject

“email_opened” :recipient=>“[email protected]” :domain=>“cloudfuji.com” :campaign_id=>“cloudfuji_buddies” :campaign_name=>“Cloudfuji Buddies” :tag=>nil :mailing_list=>nil :custom_variables=>nil



32
33
34
35
36
37
38
# File 'lib/fat_free_crm/cloudfuji/event_observers/email_observer.rb', line 32

def email_opened
  message  = ""
  message += "Email opened by #{email}"
  message += " in email campaign '#{campaign.titleize}'" if campaign

  note_email_activity( message.strip )
end

#email_receivedObject



62
63
64
65
66
67
68
69
70
71
# File 'lib/fat_free_crm/cloudfuji/event_observers/email_observer.rb', line 62

def email_received
  user = 
  return unless user
  lead = Lead.find_by_email(data['from'])
  create_email_from_data(
    :direction => 'received',
    :mediator  => lead,
    :user      => user
  )
end

#email_sentObject



73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/fat_free_crm/cloudfuji/event_observers/email_observer.rb', line 73

def email_sent
  user = 
  return unless user
  # Find first Lead from 'to' email addresses
  lead = data['to'].to_s.split(";").detect do |email|
    lead = Lead.find_by_email(email)
  end
  create_email_from_data(
    :direction => 'sent',
    :mediator  => lead,
    :user      => user
  )
end

#email_subscribedObject



58
59
60
# File 'lib/fat_free_crm/cloudfuji/event_observers/email_observer.rb', line 58

def email_subscribed
  note_email_activity("#{email} subscribed to a mailing list")
end