mail_jack 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/mail_jack/interceptor.rb +24 -6
- data/lib/mail_jack/version.rb +1 -1
- metadata +2 -2
@@ -1,20 +1,38 @@
|
|
1
1
|
module MailJack
|
2
2
|
class Interceptor
|
3
3
|
def self.delivering_email(message)
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
querystr = generate_query_string(message)
|
5
|
+
|
6
|
+
if message.multipart?
|
7
|
+
message.parts.each do |part|
|
8
|
+
unless part.attachment?
|
9
|
+
part.body = append_links(part.body, querystr)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
else
|
13
|
+
message.body = append_links(message.body, querystr)
|
14
|
+
end
|
15
|
+
end
|
8
16
|
|
17
|
+
def self.generate_query_string(message)
|
9
18
|
querystr = MailJack.trackables.keys.inject({}) {|hash, a| hash[a] = message.send(a); hash}.to_query
|
10
19
|
if MailJack.config.enable_encoding?
|
11
20
|
querystr = "#{MailJack.config.encode_to}=#{Base64.encode64(querystr)}"
|
12
21
|
end
|
22
|
+
return querystr
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.append_links(text, querystr)
|
26
|
+
str = text.to_s
|
27
|
+
hrefs = str.scan(/href=\"(.*?)\"/).flatten
|
28
|
+
hrefs = hrefs.grep(MailJack.config.href_filter)
|
29
|
+
hrefs = hrefs.uniq
|
30
|
+
|
13
31
|
hrefs.each do |h|
|
14
32
|
q = h.include?("?") ? "&#{querystr}" : "?#{querystr}"
|
15
|
-
|
33
|
+
str.gsub!(h, "#{h}#{q}")
|
16
34
|
end
|
17
|
-
|
35
|
+
return str
|
18
36
|
end
|
19
37
|
end
|
20
38
|
end
|
data/lib/mail_jack/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mail_jack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
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: 2013-06-
|
12
|
+
date: 2013-06-18 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Autogenerate query parameters to links in emails to track click throughs
|
15
15
|
email:
|