talktome 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -0
- data/lib/talktome/app.rb +5 -1
- data/lib/talktome/version.rb +1 -1
- data/spec/app/test_app.rb +19 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a01f2b1e8706384a106f6418060f2d17a87c4d76e415e5cdd3235714c40339de
|
4
|
+
data.tar.gz: 87032bc365971d322428d0245cc9d1eced6644d19f8253eacd6f061ec891e684
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6484f97e7455db0484cd296be7ea5184f333897cdb953fac3d9ffe98dbcbdb7299779db00683bdfaf0ee970d223bb9f58e140a26732dea5543d700c621cfddc6
|
7
|
+
data.tar.gz: be7f825012c0bdaa44b10939c3a29be70f9249a65b5156de065dbf6cfee7ae44e97aa5fb15ab9963e18947c889a332829b2497d696a0a9619689f48d44a027bf
|
data/README.md
CHANGED
@@ -94,6 +94,9 @@ TALKTOME_EMAIL_DEFAULT_FROM default From: to use for email sending
|
|
94
94
|
TALKTOME_EMAIL_DEFAULT_REPLYTO default Reply-To: to use for email sending
|
95
95
|
TALKTOME_EMAIL_DEFAULT_TO default To: to use for email sending
|
96
96
|
|
97
|
+
TALKTOME_EMAIL_SUBJECT Set the subject of the default "contact us" email
|
98
|
+
TALKTOME_EMAIL_FOOTER Set the footer of the default "contact us" email
|
99
|
+
|
97
100
|
TALKTOME_SMTP_ADDRESS host address for smtp sending
|
98
101
|
TALKTOME_SMTP_PORT port of smtp server to use
|
99
102
|
TALKTOME_SMTP_DOMAIN sending domain
|
data/lib/talktome/app.rb
CHANGED
@@ -27,7 +27,11 @@ module Talktome
|
|
27
27
|
|
28
28
|
post %r{/([a-z-]+)/} do |action|
|
29
29
|
begin
|
30
|
-
|
30
|
+
as_array = info.map{|k,v| {'key' => k.capitalize, 'value' => v}}
|
31
|
+
subject = Talktome.env('TALKTOME_EMAIL_SUBJECT', 'Someone wants to reach you!')
|
32
|
+
footer = Talktome.env('TALKTOME_EMAIL_FOOTER', "Truly yours,\n
|
33
|
+
Sent by [Enspirit.be](https://enspirit.be/), contact us if you need help with any IT task.")
|
34
|
+
TALKTOME.talktome(action, {}, info.merge(allvars: as_array, subject: subject, footer: footer), [:email]){|email|
|
31
35
|
email.reply_to = info[:reply_to] if info.has_key?(:reply_to)
|
32
36
|
}
|
33
37
|
[ 200, { "Content-Type" => "text/plain"}, ["Ok"] ]
|
data/lib/talktome/version.rb
CHANGED
data/spec/app/test_app.rb
CHANGED
@@ -19,13 +19,31 @@ module Talktome
|
|
19
19
|
it 'works' do
|
20
20
|
post "/contact-us/", {
|
21
21
|
reply_to: 'hello@visitor.com',
|
22
|
-
message: 'Hello from visitor'
|
22
|
+
message: 'Hello from visitor',
|
23
|
+
key: 'value',
|
23
24
|
}.to_json, { "CONTENT_TYPE" => "application/json" }
|
24
25
|
expect(last_response).to be_ok
|
25
26
|
expect(Mail::TestMailer.deliveries.length).to eql(1)
|
26
27
|
expect(Mail::TestMailer.deliveries.first.to).to eql(["to@talktome.com"])
|
27
28
|
expect(Mail::TestMailer.deliveries.first.from).to eql(["from@talktome.com"])
|
28
29
|
expect(Mail::TestMailer.deliveries.first.subject).to eql("Someone wants to reach you!")
|
30
|
+
expect(Mail::TestMailer.deliveries.first.html_part.body).to include("<li>Key: value</li>")
|
31
|
+
expect(Mail::TestMailer.deliveries.first.html_part.body).to include("Truly yours")
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'allows to use environment variable to tune the subject and the footer' do
|
35
|
+
Talktome.set_env('TALKTOME_EMAIL_SUBJECT', "Subject from environment") do
|
36
|
+
Talktome.set_env('TALKTOME_EMAIL_FOOTER', "Footer from environment") do
|
37
|
+
post "/contact-us/", {
|
38
|
+
reply_to: 'info@domain.com',
|
39
|
+
message: 'This is the message.'
|
40
|
+
}.to_json, { "CONTENT_TYPE" => "application/json" }
|
41
|
+
expect(last_response).to be_ok
|
42
|
+
expect(Mail::TestMailer.deliveries.length).to eql(1)
|
43
|
+
expect(Mail::TestMailer.deliveries.first.subject).to eql("Subject from environment")
|
44
|
+
expect(Mail::TestMailer.deliveries.first.html_part.body).to include("Footer from environment")
|
45
|
+
end
|
46
|
+
end
|
29
47
|
end
|
30
48
|
|
31
49
|
it 'detects invalid emails' do
|
metadata
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: talktome
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bernard Lambeau
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2021-04-30 00:00:00.000000000 Z
|
@@ -199,7 +199,7 @@ homepage: http://github.com/enspirit/talktome
|
|
199
199
|
licenses:
|
200
200
|
- MIT
|
201
201
|
metadata: {}
|
202
|
-
post_install_message:
|
202
|
+
post_install_message:
|
203
203
|
rdoc_options: []
|
204
204
|
require_paths:
|
205
205
|
- lib
|
@@ -214,8 +214,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
214
214
|
- !ruby/object:Gem::Version
|
215
215
|
version: '0'
|
216
216
|
requirements: []
|
217
|
-
rubygems_version: 3.
|
218
|
-
signing_key:
|
217
|
+
rubygems_version: 3.1.2
|
218
|
+
signing_key:
|
219
219
|
specification_version: 4
|
220
220
|
summary: Talktome helps you talk to users by email, messaging, sms, etc.
|
221
221
|
test_files: []
|