referthis 0.4.21 → 0.4.23
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/mailers/mailer.rb +2 -2
- data/lib/referral.rb +3 -3
- data/lib/referthis.rb +2 -2
- data/lib/sms.rb +2 -2
- metadata +2 -2
data/lib/mailers/mailer.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# http://stackoverflow.com/questions/6021372/best-way-to-create-unique-token-in-rails
|
2
2
|
class Mailer < ActionMailer::Base
|
3
|
-
def send_referral(referral, url, referrer_name, app_name)
|
4
|
-
mail(:to => Referee.find(referral.referee_id).endpoint, :subject => app_name, :body =>
|
3
|
+
def send_referral(referral, url, referrer_name, app_name, body)
|
4
|
+
mail(:to => Referee.find(referral.referee_id).endpoint, :subject => app_name, :body => body + Base64::encode64(referral.id.to_s).chop + '.')
|
5
5
|
end
|
6
6
|
end
|
data/lib/referral.rb
CHANGED
@@ -11,20 +11,20 @@ class Referral < ActiveRecord::Base
|
|
11
11
|
referral.save
|
12
12
|
return referral
|
13
13
|
end
|
14
|
-
def self.generate_referral(endpoints, user_current_id, url, referrer_name, app_name)
|
14
|
+
def self.generate_referral(endpoints, user_current_id, url, referrer_name, app_name, body)
|
15
15
|
threads = []
|
16
16
|
@user_current_id = user_current_id
|
17
17
|
if endpoints[:phone_number] != ''
|
18
18
|
threads << Thread.new('sms'){
|
19
19
|
phone_number = SMS.sieve(endpoints[:phone_number])
|
20
|
-
Referee.exists?(:endpoint => phone_number) ? SMS.send_referral(self.construct(Referee.find_by_endpoint(phone_number.to_s).id), url, referrer_name, app_name) : SMS.send_referral(self.construct(Referee.construct(phone_number.to_s).id), url, referrer_name, app_name)
|
20
|
+
Referee.exists?(:endpoint => phone_number) ? SMS.send_referral(self.construct(Referee.find_by_endpoint(phone_number.to_s).id), url, referrer_name, app_name, body) : SMS.send_referral(self.construct(Referee.construct(phone_number.to_s).id), url, referrer_name, app_name, body)
|
21
21
|
}
|
22
22
|
end
|
23
23
|
if endpoints[:email_address] != ''
|
24
24
|
threads << Thread.new('email'){
|
25
25
|
email_address = endpoints[:email_address]
|
26
26
|
begin
|
27
|
-
Referee.exists?(:endpoint => email_address) ? Mailer.send_referral(self.construct(Referee.find_by_endpoint(email_address).id), url, referrer_name, app_name).deliver : Mailer.send_referral(self.construct(Referee.construct(email_address).id), url, referrer_name, app_name).deliver
|
27
|
+
Referee.exists?(:endpoint => email_address) ? Mailer.send_referral(self.construct(Referee.find_by_endpoint(email_address).id), url, referrer_name, app_name, body).deliver : Mailer.send_referral(self.construct(Referee.construct(email_address).id), url, referrer_name, app_name, body).deliver
|
28
28
|
rescue Net::SMTPSyntaxError
|
29
29
|
puts 'Hello'
|
30
30
|
end
|
data/lib/referthis.rb
CHANGED
@@ -10,7 +10,7 @@ class ReferThis < Referral
|
|
10
10
|
system('cp -r ' + File.dirname(File.absolute_path(__FILE__)) + '/db/migrate/* ' + "'" + Rails.root.to_s.split('app/').first + "/db/migrate/'")
|
11
11
|
system('rake db:migrate')
|
12
12
|
end
|
13
|
-
def self.url(endpoints, user_current_id, url, referrer_name, app_name=Rails.application.class.to_s.split('::').first, body)
|
14
|
-
self.generate_referral(endpoints, user_current_id, url, referrer_name, app_name)
|
13
|
+
def self.url(endpoints, user_current_id, url, referrer_name, app_name=Rails.application.class.to_s.split('::').first, body=referrer_name + ' has referred you to ' + app_name + '! You might be interested in checking out the following: ' + url + '/')
|
14
|
+
self.generate_referral(endpoints, user_current_id, url, referrer_name, app_name, body)
|
15
15
|
end
|
16
16
|
end
|
data/lib/sms.rb
CHANGED
@@ -9,7 +9,7 @@ class SMS
|
|
9
9
|
def self.sieve(number)
|
10
10
|
return number.to_s.gsub(/\D/, '')
|
11
11
|
end
|
12
|
-
def self.send_referral(referral, url, referrer_name, app_name)
|
13
|
-
@@account.sms.messages.create(:from => '+18599030353', :to => Referee.find(referral.referee_id).endpoint, :body =>
|
12
|
+
def self.send_referral(referral, url, referrer_name, app_name, body)
|
13
|
+
@@account.sms.messages.create(:from => '+18599030353', :to => Referee.find(referral.referee_id).endpoint, :body => body + Base64::encode64(referral.id.to_s).chop + '.')
|
14
14
|
end
|
15
15
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: referthis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.23
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-07-
|
12
|
+
date: 2012-07-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: twilio-ruby
|